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 different pci device types
Jack Lange [Mon, 16 Mar 2009 19:20:50 +0000 (14:20 -0500)]
palacios/include/devices/pci.h
palacios/src/devices/pci.c

index 6b246a7..003096c 100644 (file)
@@ -33,6 +33,8 @@
 
 typedef enum {PCI_BAR_IO, PCI_BAR_MEM16, PCI_BAR_MEM32, PCI_BAR_MEM64_LOW, PCI_BAR_MEM64_HIGH, PCI_BAR_NONE} pci_bar_type_t;
 
+typedef enum {PCI_STD_DEVICE, PCI_TO_PCI_BRIDGE, PCI_CARDBUS, PCI_MULTIFUNCTION} pci_device_type_t;
+
 struct pci_device;
 
 struct v3_pci_bar {
@@ -86,6 +88,7 @@ struct vm_device * v3_create_pci();
 
 struct pci_device * 
 v3_pci_register_device(struct vm_device * pci,
+                      pci_device_type_t dev_type, 
                       uint_t bus_num,
                       const char * name,
                       int dev_num,
index f1d5395..8abf45e 100644 (file)
@@ -465,11 +465,22 @@ static int pci_deinit_device(struct vm_device * dev) {
 
 
 static int init_i440fx(struct vm_device * dev) {
-    /*struct pci_device * pci_dev = v3_pci_register_device(dev, 0, "i440FX", 0, 
-                                                        NULL, NULL, NULL);
+    struct pci_device * pci_dev = NULL;
+    struct v3_pci_bar bars[6];
+    int i;
+    
+    for (i = 0; i < 6; i++) {
+       bars[i].type = PCI_BAR_NONE;
+       bars[i].mem_hook = 0;
+       bars[i].num_pages = 0;
+       bars[i].bar_update = NULL;
+    }    
+
+    pci_dev = v3_pci_register_device(dev, PCI_STD_DEVICE, 0, "i440FX", 0, bars,
+                                    NULL, NULL, NULL, NULL);
     
     if (!pci_dev) {
-       return -1;
+       return -1;
     }
     
     pci_dev->config_header.vendor_id = 0x8086;
@@ -480,7 +491,6 @@ static int init_i440fx(struct vm_device * dev) {
     pci_dev->config_header.header_type = 0x00;
 
     pci_dev->bus_num = 0;
-    */
     return 0;
 }
 
@@ -585,6 +595,7 @@ static inline int init_bars(struct pci_device * pci_dev) {
 
 // if dev_num == -1, auto assign 
 struct pci_device * v3_pci_register_device(struct vm_device * pci,
+                                          pci_device_type_t dev_type, 
                                           uint_t bus_num,
                                           const char * name,
                                           int dev_num,
@@ -627,6 +638,15 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci,
     memset(pci_dev, 0, sizeof(struct pci_device));
     
     
+    switch (dev_type) {
+       case PCI_STD_DEVICE:
+           pci_dev->config_header.header_type = 0x00;
+           break;
+       default:
+           PrintError("Unhandled PCI Device Type: %d\n", dev_type);
+           return NULL;
+    }
+
     pci_dev->bus_num = bus_num;
     pci_dev->dev_num = dev_num;