Makefile: split romstage linking to separate rules
[coreboot.git] / src / devices / pci_rom.c
index 1ae79e137dd315339af8142bdea74801f192ac91..800776e8df9d23d44f24dafa92f5b3c4c2836cbe 100644 (file)
@@ -37,6 +37,19 @@ struct rom_header *pci_rom_probe(struct device *dev)
        /* If it's in FLASH, then don't check device for ROM. */
        rom_header = cbfs_load_optionrom(dev->vendor, dev->device, NULL);
 
+       u32 vendev = dev->vendor | (dev->device << 16);
+       u32 mapped_vendev = vendev;
+
+       if (map_oprom_vendev)
+               mapped_vendev = map_oprom_vendev(vendev);
+
+       if (!rom_header) {
+               if (vendev != mapped_vendev) {
+                       rom_header = cbfs_load_optionrom(mapped_vendev &
+                                       0xffff, mapped_vendev >> 16, NULL);
+               }
+       }
+
        if (rom_header) {
                printk(BIOS_DEBUG, "In CBFS, ROM address for %s = %p\n",
                       dev_path(dev), rom_header);
@@ -46,7 +59,7 @@ struct rom_header *pci_rom_probe(struct device *dev)
                rom_address = pci_read_config32(dev, PCI_ROM_ADDRESS);
 
                if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
-#if defined(CONFIG_BOARD_EMULATION_QEMU_X86) && CONFIG_BOARD_EMULATION_QEMU_X86
+#if CONFIG_BOARD_EMULATION_QEMU_X86
                        if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
                                rom_address = 0xc0000;
                        else
@@ -58,9 +71,15 @@ struct rom_header *pci_rom_probe(struct device *dev)
                                           rom_address|PCI_ROM_ADDRESS_ENABLE);
                }
 
-               printk(BIOS_DEBUG, "On card, ROM address for %s = %lx\n",
+#if CONFIG_ON_DEVICE_ROM_RUN
+               printk(BIOS_DEBUG, "Option ROM address for %s = %lx\n",
                       dev_path(dev), (unsigned long)rom_address);
                rom_header = (struct rom_header *)rom_address;
+#else
+               printk(BIOS_DEBUG, "Option ROM execution disabled "
+                       "for %s\n", dev_path(dev));
+               return NULL;
+#endif
        }
 
        printk(BIOS_SPEW, "PCI expansion ROM, signature 0x%04x, "
@@ -78,8 +97,10 @@ struct rom_header *pci_rom_probe(struct device *dev)
 
        printk(BIOS_SPEW, "PCI ROM image, vendor ID %04x, device ID %04x,\n",
               rom_data->vendor, rom_data->device);
-       if (dev->vendor != rom_data->vendor
-           || dev->device != rom_data->device) {
+       /* If the device id is mapped, a mismatch is expected */
+       if ((dev->vendor != rom_data->vendor
+           || dev->device != rom_data->device)
+           && (vendev == mapped_vendev)) {
                printk(BIOS_ERR, "ID mismatch: vendor ID %04x, "
                       "device ID %04x\n", rom_data->vendor, rom_data->device);
                return NULL;
@@ -130,7 +151,7 @@ struct rom_header *pci_rom_load(struct device *dev,
         * devices have a mismatch between the hardware and the ROM.
         */
        if (PCI_CLASS_DISPLAY_VGA == (dev->class >> 8)) {
-#if CONFIG_CONSOLE_VGA == 1 && CONFIG_CONSOLE_VGA_MULTI == 0
+#if CONFIG_MULTIPLE_VGA_ADAPTERS == 0
                extern device_t vga_pri; /* Primary VGA device (device.c). */
                if (dev != vga_pri) return NULL; /* Only one VGA supported. */
 #endif