X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fpci.c;h=e7927b7d2de5e27d5bb7cede3f43bac211f45df0;hb=cad2a42f98571ec27228d6e20f5d76910dc0e4a0;hp=8abf45e434b54474d00e9aad69b0073e9818d599;hpb=2137016ed7c531b573ef8aef0d0d545d75a01098;p=palacios-OLD.git diff --git a/palacios/src/devices/pci.c b/palacios/src/devices/pci.c index 8abf45e..e7927b7 100644 --- a/palacios/src/devices/pci.c +++ b/palacios/src/devices/pci.c @@ -125,7 +125,7 @@ static int get_free_dev_num(struct pci_bus * bus) { // availability for (j = 0; j < 8; j++) { if (!(bus->dev_map[i] & (0x1 << j))) { - return i * 8 + j; + return ((i * 8) + j) * 8; } } } @@ -135,7 +135,7 @@ static int get_free_dev_num(struct pci_bus * bus) { } static void allocate_dev_num(struct pci_bus * bus, int dev_num) { - int major = dev_num / 8; + int major = (dev_num / 8) / 8; int minor = dev_num % 8; bus->dev_map[major] |= (0x1 << minor); @@ -488,7 +488,6 @@ static int init_i440fx(struct vm_device * dev) { pci_dev->config_header.revision = 0x0002; pci_dev->config_header.subclass = 0x00; // SubClass: host2pci pci_dev->config_header.class = 0x06; // Class: PCI bridge - pci_dev->config_header.header_type = 0x00; pci_dev->bus_num = 0; return 0; @@ -565,9 +564,10 @@ static inline int init_bars(struct pci_device * pci_dev) { int bar_offset = 0x10 + 4 * i; if (pci_dev->bar[i].type == PCI_BAR_IO) { + pci_dev->bar[i].mask = 0x0000fffd; *(uint32_t *)(pci_dev->config_space + bar_offset) = 0x00000001; } else if (pci_dev->bar[i].type == PCI_BAR_MEM32) { - pci_dev->bar[i].mask = (pci_dev->bar[i].num_pages << 12) - 1; + pci_dev->bar[i].mask = ~((pci_dev->bar[i].num_pages << 12) - 1); pci_dev->bar[i].mask |= 0xf; // preserve the configuration flags *(uint32_t *)(pci_dev->config_space + bar_offset) = 0x00000008;