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.


Working (apparently) emulated keyboard support
[palacios.git] / palacios / src / geekos / vm.c
index adef732..1b46b2f 100644 (file)
@@ -5,20 +5,21 @@
 #include <geekos/vm.h>
 #include <geekos/screen.h>
 
+#include <devices/generic.h>
 #include <devices/nvram.h>
 #include <devices/timer.h>
 #include <devices/simple_pic.h>
 #include <devices/8259a.h>
+#include <devices/8254.h>
+#include <devices/keyboard.h>
 
 #include <palacios/vmm_intr.h>
 #include <palacios/vmm_dev_mgr.h>
+#include <palacios/vmm_time.h>
 
 #define SPEAKER_PORT 0x61
 
-
-
-
-inline void VM_Out_Byte(ushort_t port, uchar_t value)
+static inline void VM_Out_Byte(ushort_t port, uchar_t value)
 {
     __asm__ __volatile__ (
        "outb %b0, %w1"
@@ -30,7 +31,7 @@ inline void VM_Out_Byte(ushort_t port, uchar_t value)
 /*
  * Read a byte from an I/O port.
  */
-inline uchar_t VM_In_Byte(ushort_t port)
+static inline uchar_t VM_In_Byte(ushort_t port)
 {
     uchar_t value;
 
@@ -45,6 +46,7 @@ inline uchar_t VM_In_Byte(ushort_t port)
 
 
 
+
 int IO_Read(ushort_t port, void * dst, uint_t length, void * priv_data) {
 
   if (length != 1) {
@@ -181,7 +183,7 @@ int RunVMM(struct Boot_Info * bootInfo) {
     os_hooks.paddr_to_vaddr = &Identity;
     os_hooks.hook_interrupt = &hook_irq_stub;
     os_hooks.ack_irq = &ack_irq;
+    os_hooks.get_cpu_khz = &get_cpu_khz;
 
     Init_VMM(&os_hooks, &vmm_ops);
   
@@ -189,6 +191,7 @@ int RunVMM(struct Boot_Info * bootInfo) {
     /* MOVE THIS TO AN INIT GUEST ROUTINE */
     init_shadow_map(&(vm_info.mem_map));
     init_shadow_page_state(&(vm_info.shdw_pg_state));
+    v3_init_time(&(vm_info.time_state));
     vm_info.page_mode = SHADOW_PAGING;
 
     vm_info.cpu_mode = REAL;
@@ -303,7 +306,7 @@ int RunVMM(struct Boot_Info * bootInfo) {
       print_shadow_map(&(vm_info.mem_map));
 
       hook_io_port(&(vm_info.io_map), 0x61, &IO_Read, &IO_Write, NULL);
-      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
+      //hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
 
 
       hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial, NULL);
@@ -312,19 +315,40 @@ int RunVMM(struct Boot_Info * bootInfo) {
       hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial, NULL);
 
       {
+       
        struct vm_device * nvram = create_nvram();
-       //struct vm_device * timer = create_timer();
+       struct vm_device * timer = create_timer();
        struct vm_device * pic = create_pic();
+       struct vm_device * keyboard = create_keyboard();
+       //struct vm_device * pit = create_pit();
+
+       //generic_port_range_type range = {0,1024} ; // hook first 1024 ports if not already hooked
+
+       //struct vm_device * generic = create_generic(&range,1,NULL,0,NULL,0);
+       
 
        attach_device(&(vm_info), nvram);
-       //attach_device(&(vm_info), timer);
+       attach_device(&(vm_info), timer);
        attach_device(&(vm_info), pic);
+       //attach_device(&(vm_info), pit);
+       attach_device(&(vm_info), keyboard);
+
+       // Important that this be attached last!
+       //attach_device(&(vm_info), generic);
 
        PrintDebugDevMgr(&(vm_info.dev_mgr));
       }
 
+      // give keyboard interrupts to vm
+      //hook_irq(&vm_info, 1);
+      
+      // give floppy controller to vm
       hook_irq(&vm_info, 6);
+
+      // primary ide
       hook_irq(&vm_info, 14);
+
+      // secondary ide
       hook_irq(&vm_info, 15);