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.


functional DMA reads for IDE disks
[palacios.git] / palacios / src / palacios / vmm_config.c
index 631fe5c..eb03b0e 100644 (file)
 #include <devices/8254.h>
 #include <devices/nvram.h>
 #include <devices/generic.h>
-#include <devices/ramdisk.h>
-#include <devices/cdrom.h>
+#include <devices/ide.h>
+#include <devices/ram_cd.h>
+#include <devices/ram_hd.h>
 #include <devices/bochs_debug.h>
 #include <devices/os_debug.h>
 #include <devices/apic.h>
 #include <devices/io_apic.h>
 #include <devices/para_net.h>
 #include <devices/pci.h>
-
+#include <devices/i440fx.h>
+#include <devices/piix3.h>
 
 
 #include <palacios/vmm_host_events.h>
@@ -88,10 +90,12 @@ int v3_config_guest(struct guest_info * info, struct v3_vm_config * config_ptr)
     
     v3_init_hypercall_map(info);
     
-  
-    if (v3_cpu_type == V3_SVM_REV3_CPU) {
+    if ((v3_cpu_type == V3_SVM_REV3_CPU) && 
+       (config_ptr->enable_nested_paging == 1)) {
+       PrintDebug("Guest Page Mode: NESTED_PAGING\n");
        info->shdw_pg_mode = NESTED_PAGING;
     } else {
+       PrintDebug("Guest Page Mode: SHADOW_PAGING\n");
        v3_init_shadow_page_state(info);
        info->shdw_pg_mode = SHADOW_PAGING;
     }
@@ -277,13 +281,15 @@ static int setup_memory_map(struct guest_info * info, struct v3_vm_config * conf
 
 
 static int setup_devices(struct guest_info * info, struct v3_vm_config * config_ptr) {
+
+    struct vm_device * ide = NULL;
     struct vm_device * ramdisk = NULL;
-    struct vm_device * cdrom = NULL;
-#ifdef DEBUG_PCI
-    struct vm_device * pci = v3_create_pci();
-#endif
-    struct vm_device * nvram = v3_create_nvram();
-    //struct vm_device * timer = v3_create_timer();
+    
+    struct vm_device * pci = NULL;
+    struct vm_device * northbridge = NULL;
+    struct vm_device * southbridge = NULL;
+
+    struct vm_device * nvram = NULL;
     struct vm_device * pic = v3_create_pic();
     struct vm_device * keyboard = v3_create_keyboard();
     struct vm_device * pit = v3_create_pit(); 
@@ -293,17 +299,36 @@ static int setup_devices(struct guest_info * info, struct v3_vm_config * config_
     struct vm_device * ioapic = v3_create_io_apic(apic);
     struct vm_device * para_net = v3_create_para_net();
 
+
     //struct vm_device * serial = v3_create_serial();
     struct vm_device * generic = NULL;
 
-    int use_ramdisk = config_ptr->use_ramdisk;
+
     int use_generic = USE_GENERIC;
 
+    if (config_ptr->enable_pci == 1) {
+       pci = v3_create_pci();
+       northbridge = v3_create_i440fx(pci);
+       southbridge = v3_create_piix3(pci);
+       ide = v3_create_ide(pci, southbridge);
+    } else {
+       ide = v3_create_ide(NULL, NULL);
+    }
+
+
 
-    if (use_ramdisk) {
-       PrintDebug("Creating Ramdisk\n");
-       ramdisk = v3_create_ramdisk();
-       cdrom = v3_create_cdrom(ramdisk, config_ptr->ramdisk, config_ptr->ramdisk_size);
+    nvram = v3_create_nvram(ide);
+
+    if (config_ptr->use_ram_cd == 1) {
+       PrintDebug("Creating Ram CD\n");
+       ramdisk = v3_create_ram_cd(ide, 0, 0, 
+                                  (addr_t)(config_ptr->ramdisk), 
+                                  config_ptr->ramdisk_size);
+    } else if (config_ptr->use_ram_hd == 1) {
+       PrintDebug("Creating Ram HD\n");
+       ramdisk = v3_create_ram_hd(ide, 0, 0, 
+                                  (addr_t)(config_ptr->ramdisk), 
+                                  config_ptr->ramdisk_size);
     }
     
     
@@ -311,12 +336,10 @@ static int setup_devices(struct guest_info * info, struct v3_vm_config * config_
        generic = configure_generic(info, config_ptr);
     }
 
-#ifdef DEBUG_PCI
-    v3_attach_device(info, pci);
-#endif
 
-    v3_attach_device(info, nvram);
-    //v3_attach_device(info, timer);
+
+
+
     v3_attach_device(info, pic);
     v3_attach_device(info, pit);
     v3_attach_device(info, keyboard);
@@ -329,39 +352,31 @@ static int setup_devices(struct guest_info * info, struct v3_vm_config * config_
 
     v3_attach_device(info, para_net);
 
-    if (use_ramdisk) {
+    if (config_ptr->enable_pci == 1) {
+       PrintDebug("Attaching PCI\n");
+       v3_attach_device(info, pci);
+       PrintDebug("Attaching Northbridge\n");
+       v3_attach_device(info, northbridge);
+       PrintDebug("Attaching Southbridge\n");
+       v3_attach_device(info, southbridge);
+    }
+
+    PrintDebug("Attaching IDE\n");
+    v3_attach_device(info, ide);
+
+    if (ramdisk != NULL) {
        v3_attach_device(info, ramdisk);
-       v3_attach_device(info, cdrom);
     }
 
     if (use_generic) {
        // Important that this be attached last!
        v3_attach_device(info, generic);
     }
-    
-    PrintDebugDevMgr(info);
 
-
-    // give keyboard interrupts to vm
-    // no longer needed since we have a keyboard device
-    //hook_irq(&vm_info, 1);
-    
-#if 0
-    // give floppy controller to vm
-    v3_hook_passthrough_irq(info, 6);
-#endif
-    
-    
-    if (!use_ramdisk) {
-       PrintDebug("Hooking IDE IRQs\n");
-       
-       //primary ide
-       v3_hook_passthrough_irq(info, 14);
-       
-       // secondary ide
-       v3_hook_passthrough_irq(info, 15);    
-    }  
+    // This should go last because it contains the hardware state
+    v3_attach_device(info, nvram);
     
+    PrintDebugDevMgr(info);
 
     return 0;
 }
@@ -405,8 +420,8 @@ static struct vm_device *  configure_generic(struct guest_info * info, struct v3
 
     // Make the PCI bus invisible (at least it's configuration)
     
-    v3_generic_add_port_range(generic, 0xcf8, 0xcf8, GENERIC_PRINT_AND_IGNORE); // PCI Config Address
-    v3_generic_add_port_range(generic, 0xcfc, 0xcfc, GENERIC_PRINT_AND_IGNORE); // PCI Config Data
+    //v3_generic_add_port_range(generic, 0xcf8, 0xcf8, GENERIC_PRINT_AND_IGNORE); // PCI Config Address
+    //v3_generic_add_port_range(generic, 0xcfc, 0xcfc, GENERIC_PRINT_AND_IGNORE); // PCI Config Data