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.


bug fixes
Jack Lange [Mon, 16 Mar 2009 19:04:40 +0000 (14:04 -0500)]
palacios/include/devices/pci.h
palacios/src/devices/pci.c

index 5d96168..6b246a7 100644 (file)
@@ -33,7 +33,9 @@
 
 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;
 
-struct v3_bar_reg {
+struct pci_device;
+
+struct v3_pci_bar {
     pci_bar_type_t type;
     int mem_hook;
     int num_pages;
@@ -56,7 +58,7 @@ struct pci_device {
 
 
 
-    struct v3_bar_reg bar[6];
+    struct v3_pci_bar bar[6];
 
     uint_t bus_num;
     struct rb_node dev_tree_node;
@@ -87,8 +89,10 @@ v3_pci_register_device(struct vm_device * pci,
                       uint_t bus_num,
                       const char * name,
                       int dev_num,
+                      struct v3_pci_bar * bars,
                       int (*config_update)(struct pci_device * pci_dev, uint_t reg_num, int length),
-                      int (*bar_update)(struct pci_device * pci_dev, uint_t bar),
+                      int (*cmd_update)(struct pci_device *pci_dev, uchar_t io_enabled, uchar_t mem_enabled),
+                      int (*ext_rom_update)(struct pci_device *pci_dev),
                       void * private_data);
 
 
index 1db0134..de3e0ea 100644 (file)
@@ -330,10 +330,6 @@ static inline int is_cfg_reg_writable(uchar_t header_type, int reg_num) {
            default:
                return 1;
  
-           // case (non writable reg list):
-           
-           default:
-               return 1;
        }
     } else {
        // PCI to PCI Bridge = 0x01
@@ -384,7 +380,7 @@ static int data_port_write(ushort_t port, void * src, uint_t length, struct vm_d
                    pci_dev->bar[bar_reg].updated = 1;
                }
            } else if ((cur_reg >= 0x30) && (cur_reg < 0x34)) {
-               pci_dev->ext_rom_updated = 1;
+               pci_dev->ext_rom_update_flag = 1;
            } else if ((cur_reg == 0x04) || (cur_reg == 0x05)) {
                // COMMAND update
            } else if (cur_reg == 0x0f) {
@@ -404,7 +400,7 @@ static int data_port_write(ushort_t port, void * src, uint_t length, struct vm_d
            if (pci_dev->bar[i].updated) {
                int bar_offset = 0x10 + 4 * i;
 
-               *(uint32_t *)pci_dev->config_space + bar_offset) &= pci_dev->bar[i].mask;
+               *(uint32_t *)(pci_dev->config_space + bar_offset) &= pci_dev->bar[i].mask;
 
                if (pci_dev->bar[i].bar_update) {
                    pci_dev->bar[i].bar_update(pci_dev, i);
@@ -460,7 +456,7 @@ 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, 
+    /*struct pci_device * pci_dev = v3_pci_register_device(dev, 0, "i440FX", 0, 
                                                         NULL, NULL, NULL);
     
     if (!pci_dev) {
@@ -475,7 +471,7 @@ static int init_i440fx(struct vm_device * dev) {
     pci_dev->config_header.header_type = 0x00;
 
     pci_dev->bus_num = 0;
-    
+    */
     return 0;
 }
 
@@ -511,7 +507,7 @@ static int pci_init_device(struct vm_device * dev) {
        return -1;
     }
 
-    PrintDebug("Sizeof config header=%d\n", sizeof(struct pci_config_header));
+    PrintDebug("Sizeof config header=%d\n", (int)sizeof(struct pci_config_header));
     
     for (i = 0; i < 4; i++) {
        v3_dev_hook_io(dev, CONFIG_ADDR_PORT + i, &addr_port_read, &addr_port_write);
@@ -572,6 +568,8 @@ static inline int init_bars(struct pci_device * pci_dev) {
            
 
     }
+
+    return 0;
 }
 
 
@@ -584,7 +582,7 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci,
                                           struct v3_pci_bar * bars,
                                           int (*config_update)(struct pci_device * pci_dev, uint_t reg_num, int length),
                                           int (*cmd_update)(struct pci_device *pci_dev, uchar_t io_enabled, uchar_t mem_enabled),
-                                          int (*bar_update)(struct pci_device * pci_dev, uint_t bar),
+                                          int (*ext_rom_update)(struct pci_device * pci_dev),
                                           void * private_data) {
 
     struct pci_internal * pci_state = (struct pci_internal *)pci->private_data;
@@ -628,7 +626,8 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci,
 
     // register update callbacks
     pci_dev->config_update = config_update;
-    pci_dev->bar_update = bar_update;
+    pci_dev->cmd_update = cmd_update;
+    pci_dev->ext_rom_update = ext_rom_update;
 
     pci_dev->priv_data = private_data;
 
@@ -636,7 +635,8 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci,
     //copy bars
     for (i = 0; i < 6; i ++){
       pci_dev->bar[i].type = bars[i].type;
-      pci_dev->bar[i].num_resources = bars[i].num_resources;
+      pci_dev->bar[i].num_pages = bars[i].num_pages;
+      pci_dev->bar[i].mem_hook = bars[i].mem_hook;
       pci_dev->bar[i].bar_update = bars[i].bar_update;
     }