v2/src romfs->cbfs rename
[coreboot.git] / src / devices / pci_rom.c
index 1d1024c9da59264105d4b19366ca7159199451d0..5df13a421432b715919320a30a762bf29cf17a90 100644 (file)
 #include <device/pci_ids.h>
 #include <device/pci_ops.h>
 #include <string.h>
+#include <cbfs.h>
 
 struct rom_header * pci_rom_probe(struct device *dev)
 {
-       unsigned long rom_address;
+       unsigned long rom_address = 0;
        struct rom_header *rom_header;
        struct pci_data *rom_data;
 
-        if (dev->on_mainboard) {
+       if (CONFIG_CBFS) {
+               void *v;
+               /* if it's in FLASH, then it's as if dev->on_mainboard was true */
+               v = cbfs_load_optionrom(dev->vendor, dev->device, NULL);
+               printk_debug("In cbfs, rom address for %s = %lx\n", 
+                               dev_path(dev), rom_address);
+               if (v) {
+                       dev->rom_address = v;
+                       dev->on_mainboard = 1;
+               }
+       } 
+
+       if (dev->on_mainboard) {
+               /* this is here as a legacy path. We hope it goes away soon. Users should not have to 
+                * compute the ROM address at build time!
+                */
                 // in case some device PCI_ROM_ADDRESS can not be set or readonly 
                rom_address = dev->rom_address;
+               printk_debug("On mainboard, rom address for %s = %lx\n", 
+                       dev_path(dev), rom_address);
         } else {
                rom_address = pci_read_config32(dev, PCI_ROM_ADDRESS);
+               printk_debug("On card, rom address for %s = %lx\n", 
+                               dev_path(dev), rom_address);
        }
 
        if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
                return NULL;
        }
 
-       printk_debug("rom address for %s = %lx\n", dev_path(dev), rom_address);
-       
        if(!dev->on_mainboard) {
                /* enable expansion ROM address decoding */
                pci_write_config32(dev, PCI_ROM_ADDRESS,