seabios: pciinit: make bar offset calculation pci bridge aware.
authorIsaku Yamahata <yamahata@valinux.co.jp>
Tue, 22 Jun 2010 08:57:51 +0000 (17:57 +0900)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 4 Jul 2010 12:52:44 +0000 (08:52 -0400)
This patch makes pci bar offset calculation pci bridge aware.
The offset of pci bridge rom is different from normal device.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
src/pciinit.c

index 9109739e4abb0c17087da82e3679a2286caff709..23b79bcb5728a68673e945f5dcdc3347d6104c6a 100644 (file)
@@ -27,7 +27,11 @@ static u32 pci_bar(u16 bdf, int region_num)
     if (region_num != PCI_ROM_SLOT) {
         return PCI_BASE_ADDRESS_0 + region_num * 4;
     }
-    return PCI_ROM_ADDRESS;
+
+#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
+    u8 type = pci_config_readb(bdf, PCI_HEADER_TYPE);
+    type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+    return type == PCI_HEADER_TYPE_BRIDGE ? PCI_ROM_ADDRESS1 : PCI_ROM_ADDRESS;
 }
 
 static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr)