Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Reflowed some files to conform to Kitten style guide and
Trammell Hudson [Tue, 21 Oct 2008 23:01:32 +0000 (18:01 -0500)]
replaced structure declarations with designated initializers.

kitten/include/lwk/palacios.h
kitten/init/main.c
kitten/palacios-glue/vm.c
kitten/palacios-glue/vmm_stubs.c

index f17f08f..fecaac3 100644 (file)
 #include <palacios/vmm_host_events.h>
 
 
+extern void v3vee_init_stubs( struct guest_info * info );
 
 extern int
-RunVMM( void );
+v3vee_run_vmm( void );
 
 extern struct v3_os_hooks v3vee_os_hooks;
 
@@ -21,7 +22,6 @@ extern struct v3_os_hooks v3vee_os_hooks;
  * stubs called by geekos....
  * 
  ***/
-extern void Init_Stubs(struct guest_info * info);
 void send_key_to_vmm(unsigned char status, unsigned char scancode);
 void send_mouse_to_vmm(unsigned char packet[3]);
 void send_tick_to_vmm(unsigned int period_us);
index 16369d3..709a0ab 100644 (file)
@@ -118,7 +118,7 @@ start_kernel()
        }
 
 #ifdef CONFIG_V3VEE
-       RunVMM();
+       v3vee_run_vmm();
 #else
        /*
         * Start up user-space...
index be49efb..3ba421c 100644 (file)
 #include <palacios/vmm_io.h>
 
 
+int
+v3vee_run_vmm( void )
+{
+       struct v3_ctrl_ops v3_ops = {};
 
+       void * ramdiskImage=initrd_start;
+       uintptr_t ramdiskSize=initrd_end-initrd_start;
 
-int RunVMM() {
-  struct v3_ctrl_ops v3_ops = {};
-  struct guest_info * vm_info = 0;
+       Init_V3( &v3vee_os_hooks, &v3_ops );
 
-  void * ramdiskImage=initrd_start;
-  uintptr_t ramdiskSize=initrd_end-initrd_start;
-
-
-  
-  Init_V3(&v3vee_os_hooks, &v3_ops);
-
-  
        struct v3_vm_config vm_config = {
-               .rombios = &rombios_start,
-               .rombios_size = (&rombios_end)-(&rombios_start),
-               .vgabios = &vgabios_start,
-               .vgabios_size = (&vgabios_end)-(&vgabios_start),
+               .rombios                = &rombios_start,
+               .rombios_size           = (&rombios_end)-(&rombios_start),
+               .vgabios                = &vgabios_start,
+               .vgabios_size           = (&vgabios_end)-(&vgabios_start),
+               .use_ramdisk            = ramdiskImage != NULL,
+               .ramdisk                = ramdiskImage,
+               .ramdisk_size           = ramdiskSize,
        };
-  
-  
-  if (ramdiskImage != NULL) {
-    vm_config.use_ramdisk = 1;
-    vm_config.ramdisk = ramdiskImage;
-    vm_config.ramdisk_size = ramdiskSize;
-  }
-
-
-
-  vm_info = (v3_ops).allocate_guest();
-
-  Init_Stubs(vm_info);
-
-  //PrintBoth("Allocated Guest\n");
-
-  (v3_ops).config_guest(vm_info, &vm_config);
 
-  //PrintBoth("Configured guest\n");
+       struct guest_info * vm_info = (v3_ops).allocate_guest();
+       v3vee_init_stubs(vm_info);
 
-  (v3_ops).init_guest(vm_info);
-  printk("Starting Guest\n");
-  //Clear_Screen();
+       v3_ops.config_guest(vm_info, &vm_config);
 
-  (v3_ops).start_guest(vm_info);
+       v3_ops.init_guest(vm_info);
+       printk("Starting Guest\n");
+       v3_ops.start_guest(vm_info);
   
-    return 0;
+       return 0;
 }
index 789eee7..672ca6c 100644 (file)
@@ -41,151 +41,184 @@ struct guest_info * irq_to_guest_map[256];
 
 
 
-void Init_Stubs(struct guest_info * info) {
-  memset(irq_to_guest_map, 0, sizeof(struct guest_info *) * 256);
-  g_vm_guest = info;
+void
+v3vee_init_stubs(
+       struct guest_info * info
+)
+{
+       memset(irq_to_guest_map, 0, sizeof(struct guest_info *) * 256);
+       g_vm_guest = info;
 }
 
 
-void * kitten_pa_to_va(void *ptr)
+static void *
+kitten_pa_to_va(void *ptr)
 {
-  return (void*) __va(ptr);
+       return (void*) __va(ptr);
 }
 
-void * kitten_va_to_pa(void *ptr)
+
+static void *
+kitten_va_to_pa(
+       void *                  ptr
+)
 {
-  return (void*) __pa(ptr);
+       return (void*) __pa(ptr);
 }
 
-void * Allocate_VMM_Pages(int num_pages) 
+
+static void *
+Allocate_VMM_Pages(
+       int                     num_pages
+) 
 {
-  int rc;
-  struct pmem_region result;
+       struct pmem_region result;
   
-  rc=pmem_alloc_umem(num_pages*PAGE_SIZE,PAGE_SIZE,&result);
-  
-  if (rc) {
-    return 0;
-  } else {
-    return result.start;
-  }
+       int rc = pmem_alloc_umem( num_pages*PAGE_SIZE,PAGE_SIZE, &result );
+       if( rc )
+               return 0;
+
+       return result.start;
 }
 
-void Free_VMM_Page(void * page) 
+static void
+Free_VMM_Page(
+       void *                  page
+) 
 {
-  int rc;
-  struct pmem_region query;
-  struct pmem_region result;
+       struct pmem_region      query;
+       struct pmem_region      result;
 
-  pmem_region_unset_all(&query);
+       pmem_region_unset_all(&query);
 
-  query.start=page;
-  query.end=page+PAGE_SIZE;
+       query.start     = page;
+       query.end       = page+PAGE_SIZE;
 
-  rc=pmem_query(&query,&result);
+       int rc = pmem_query(&query,&result);
 
-  if (!rc) { 
-    result.allocated=0;
-    pmem_update(&result);
-  } else {
-    // BAD
-  }
-}
+       if (rc)
+               panic( "BAD" );
 
+       result.allocated = 0;
+       pmem_update(&result);
+}
 
 
 
-void send_key_to_vmm(unsigned char status, unsigned char scancode) {
-  struct v3_keyboard_event evt;
+void
+send_key_to_vmm(
+       unsigned char           status,
+       unsigned char           scancode
+)
+{
+       if( !g_vm_guest )
+               return;
 
-  evt.status = status;
-  evt.scan_code = scancode;
+       struct v3_keyboard_event evt = {
+               .status         = status,
+               .scan_code      = scancode,
+       };
 
-  if (g_vm_guest) {
-    v3_deliver_keyboard_event(g_vm_guest, &evt);
-  }
+       v3_deliver_keyboard_event( g_vm_guest, &evt );
 }
 
 
-void send_mouse_to_vmm(unsigned char packet[3]) {
-  struct v3_mouse_event evt;
-
-  memcpy(evt.data, packet, 3);
-
-  if (g_vm_guest) {
-    v3_deliver_mouse_event(g_vm_guest, &evt);
-  }
-}
-
-void send_tick_to_vmm(unsigned int period_us) {
-  struct v3_timer_event evt;
+void
+send_mouse_to_vmm(
+       unsigned char           packet[3]
+)
+{
+       if( !g_vm_guest )
+               return;
 
-  evt.period_us = period_us;
+       struct v3_mouse_event evt;
+       memcpy(evt.data, packet, 3);
 
-  if (g_vm_guest) {
-    v3_deliver_timer_event(g_vm_guest, &evt);
-  }
+       v3_deliver_mouse_event(g_vm_guest, &evt);
 }
 
 
-void translate_intr_handler(struct pt_regs *regs, unsigned int vector) 
+void
+send_tick_to_vmm(
+       unsigned int            period_us
+)
 {
-  struct v3_interrupt intr;
+       if( !g_vm_guest )
+               return;
 
-  intr.irq = vector-32;
-  intr.error = regs->orig_rax;
-  intr.should_ack = 0;
+       struct v3_timer_event evt = {
+               .period_us      = period_us,
+       };
 
-  //  PrintBoth("translate_intr_handler: opaque=0x%x\n",mystate.opaque);
+       v3_deliver_timer_event( g_vm_guest, &evt );
+}
 
-  v3_deliver_irq(irq_to_guest_map[intr.irq], &intr);
 
+void
+translate_intr_handler(
+       struct pt_regs *        regs,
+       unsigned int            vector
+) 
+{
+       struct v3_interrupt intr = {
+               .irq            = vector-32,
+               .error          = regs->orig_rax,
+               .should_ack     = 0,
+       };
+
+       //  PrintBoth("translate_intr_handler: opaque=0x%x\n",mystate.opaque);
+       v3_deliver_irq( irq_to_guest_map[intr.irq], &intr );
 }
 
 
-
-int kitten_hook_interrupt(struct guest_info * vm, unsigned int  irq)
+int
+kitten_hook_interrupt(
+       struct guest_info *     vm,
+       unsigned int            irq
+)
 {
-  if (irq_to_guest_map[irq]) { 
-    //PrintBoth("Attempt to hook interrupt that is already hooked\n");
-    return -1;
-  } else {
-    //PrintBoth("Hooked interrupt 0x%x with opaque 0x%x\n", irq, vm);
-    irq_to_guest_map[irq] = vm;
-  }
-
-  set_idtvec_handler(irq,translate_intr_handler);
-  return 0;
+       if( irq_to_guest_map[irq] ) {
+               //PrintBoth("Attempt to hook interrupt that is already hooked\n");
+               return -1;
+       }
+
+       //PrintBoth("Hooked interrupt 0x%x with opaque 0x%x\n", irq, vm);
+       irq_to_guest_map[irq] = vm;
+
+       set_idtvec_handler( irq, translate_intr_handler );
+       return 0;
 }
 
 
-int ack_irq(int irq) 
+static int
+ack_irq(
+       int                     irq
+) 
 {
-  lapic_ack_interrupt();
-  return 0;
+       lapic_ack_interrupt();
+       return 0;
 }
 
   
-
-
-unsigned int get_cpu_khz() 
+static unsigned int
+get_cpu_khz( void ) 
 {
-  return   cpu_info[0].arch.cur_cpu_khz;
+       return cpu_info[0].arch.cur_cpu_khz;
 }
 
 
 struct v3_os_hooks v3vee_os_hooks = {
-       .print_debug = &printk,  // serial print ideally
-       .print_info = &printk,   // serial print ideally
-       .print_trace = &printk,  // serial print ideally
-       .allocate_pages = &Allocate_VMM_Pages, // defined in vmm_stubs
-       .free_page = &Free_VMM_Page, // defined in vmm_stubs
-       .malloc = &kmem_alloc,
-       .free = &kmem_free,
-       .vaddr_to_paddr = &kitten_va_to_pa,
-       .paddr_to_vaddr = &kitten_pa_to_va,
-       .hook_interrupt = &kitten_hook_interrupt,
-       .ack_irq = &ack_irq,
-       .get_cpu_khz = &get_cpu_khz,
+       .print_debug            = printk,  // serial print ideally
+       .print_info             = printk,   // serial print ideally
+       .print_trace            = printk,  // serial print ideally
+       .allocate_pages         = Allocate_VMM_Pages, // defined in vmm_stubs
+       .free_page              = Free_VMM_Page, // defined in vmm_stubs
+       .malloc                 = kmem_alloc,
+       .free                   = kmem_free,
+       .vaddr_to_paddr         = kitten_va_to_pa,
+       .paddr_to_vaddr         = kitten_pa_to_va,
+       .hook_interrupt         = kitten_hook_interrupt,
+       .ack_irq                = ack_irq,
+       .get_cpu_khz            = get_cpu_khz,
 };