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.


added full device support
[palacios.git] / palacios / src / geekos / vm.c
index abce2ac..a8ef613 100644 (file)
@@ -4,6 +4,8 @@
 #include <geekos/serial.h>
 #include <geekos/vm.h>
 #include <geekos/screen.h>
+#include <palacios/vmm_dev_mgr.h>
+#include <devices/nvram.h>
 
 #define SPEAKER_PORT 0x61
 
@@ -37,7 +39,7 @@ inline uchar_t VM_In_Byte(ushort_t port)
 
 
 
-int IO_Read(ushort_t port, void * dst, uint_t length) {
+int IO_Read(ushort_t port, void * dst, uint_t length, void * priv_data) {
   uchar_t * iter = dst;
   uint_t i;
 
@@ -51,7 +53,7 @@ int IO_Read(ushort_t port, void * dst, uint_t length) {
 
 
 
-int IO_Write(ushort_t port, void * src, uint_t length) {
+int IO_Write(ushort_t port, void * src, uint_t length, void * priv_data) {
   uchar_t * iter = src;
   uint_t i;
 
@@ -65,7 +67,7 @@ int IO_Write(ushort_t port, void * src, uint_t length) {
 }
 
 
-int IO_Read_to_Serial(ushort_t port, void * dst, uint_t length) {
+int IO_Read_to_Serial(ushort_t port, void * dst, uint_t length, void * priv_data) {
   PrintBoth("Input from Guest on port %d (0x%x) Length=%d\n", port, port, length);
   
   return 0;
@@ -76,7 +78,7 @@ char * bochs_debug_buf = NULL;
 int bochs_debug_offset = 0;
 
 
-int IO_BOCHS_debug(ushort_t port, void * src, uint_t length) {
+int IO_BOCHS_debug(ushort_t port, void * src, uint_t length, void * priv_data) {
   if (!bochs_debug_buf) {
     bochs_debug_buf = (char*)Malloc(1024);
   }
@@ -93,7 +95,7 @@ int IO_BOCHS_debug(ushort_t port, void * src, uint_t length) {
 }
 
 
-int IO_Write_to_Serial(ushort_t port, void * src, uint_t length) {
+int IO_Write_to_Serial(ushort_t port, void * src, uint_t length, void * priv_data) {
  SerialPrint("Output from Guest on port %d (0x%x) Length=%d\n", port, port, length);
   switch (length) {
 
@@ -172,7 +174,7 @@ int RunVMM(struct Boot_Info * bootInfo) {
     os_hooks.vaddr_to_paddr = &Identity;
     os_hooks.paddr_to_vaddr = &Identity;
 
-
     //   DumpGDT();
     Init_VMM(&os_hooks, &vmm_ops);
   
@@ -183,6 +185,7 @@ int RunVMM(struct Boot_Info * bootInfo) {
     vm_info.cpu_mode = REAL;
 
     init_vmm_io_map(&(vm_info.io_map));
+    init_interrupt_state(&(vm_info.intr_state));
 
     
     if (0) {
@@ -213,8 +216,8 @@ int RunVMM(struct Boot_Info * bootInfo) {
 
       add_shadow_region_passthrough(&vm_info, 0x0, 0x100000, 0x100000);
 
-      hook_io_port(&(vm_info.io_map), 0x61, &IO_Read, &IO_Write);
-      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial);
+      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);
       
       /*
        vm_info.cr0 = 0;
@@ -270,18 +273,26 @@ 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);
-      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial);
+      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), 0x20, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x21, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0xa0, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0xa1, &IO_Read, &IO_Write_to_Serial, NULL);
 
-      hook_io_port(&(vm_info.io_map), 0x20, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0x21, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0xa0, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0xa1, &IO_Read, &IO_Write_to_Serial);
+      hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x401, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x402, &IO_Read, &IO_BOCHS_debug, NULL);
+      hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial, NULL);
 
-      hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0x401, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0x402, &IO_Read, &IO_BOCHS_debug);
-      hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial);
+      {
+       struct vm_device * nvram = nvram_create();
+       attach_device(&(vm_info), nvram);
+       
+       PrintDebugDevMgr(&(vm_info.dev_mgr));
+       
+      }
 
       vm_info.rip = 0xfff0;
       vm_info.vm_regs.rsp = 0x0;