struct rom_header * pci_rom_probe(struct device *dev)
{
- unsigned long rom_address = 0;
struct rom_header *rom_header;
struct pci_data *rom_data;
- 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 = %p\n",
- dev_path(dev), v);
- if (v) {
- dev->rom_address = (u32)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);
+ /* If it's in FLASH, then don't check device for ROM. */
+ rom_header = cbfs_load_optionrom(dev->vendor, dev->device, NULL);
+
+ if (rom_header) {
+ printk(BIOS_DEBUG, "In cbfs, rom address for %s = %p\n",
+ dev_path(dev), rom_header);
} else {
+ unsigned long rom_address;
+
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;
- }
+ if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
+ #if defined(CONFIG_BOARD_EMULATION_QEMU_X86) \
+ && CONFIG_BOARD_EMULATION_QEMU_X86
+ if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+ rom_address = 0xc0000;
+ else
+ #endif
+ return NULL;
+ } else {
+ /* enable expansion ROM address decoding */
+ pci_write_config32(dev, PCI_ROM_ADDRESS,
+ rom_address|PCI_ROM_ADDRESS_ENABLE);
+ }
- if(!dev->on_mainboard) {
- /* enable expansion ROM address decoding */
- pci_write_config32(dev, PCI_ROM_ADDRESS,
- rom_address|PCI_ROM_ADDRESS_ENABLE);
+ printk(BIOS_DEBUG, "On card, rom address for %s = %lx\n",
+ dev_path(dev), rom_address);
+ rom_header = (struct rom_header *)rom_address;
}
- rom_header = (struct rom_header *)rom_address;
- printk_spew("PCI Expansion ROM, signature 0x%04x, INIT size 0x%04x, data ptr 0x%04x\n",
+ printk(BIOS_SPEW, "PCI Expansion ROM, signature 0x%04x, INIT size 0x%04x, data ptr 0x%04x\n",
le32_to_cpu(rom_header->signature),
rom_header->size * 512, le32_to_cpu(rom_header->data));
if (le32_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
- printk_err("Incorrect Expansion ROM Header Signature %04x\n",
+ printk(BIOS_ERR, "Incorrect Expansion ROM Header Signature %04x\n",
le32_to_cpu(rom_header->signature));
return NULL;
}
- rom_data = (struct pci_data *) ((void *)rom_header + le32_to_cpu(rom_header->data));
- printk_spew("PCI ROM Image, Vendor %04x, Device %04x,\n",
+ rom_data = (((void *)rom_header) + le32_to_cpu(rom_header->data));
+
+ printk(BIOS_SPEW, "PCI ROM Image, Vendor %04x, Device %04x,\n",
rom_data->vendor, rom_data->device);
if (dev->vendor != rom_data->vendor || dev->device != rom_data->device) {
- printk_err("Device or Vendor ID mismatch Vendor %04x, Device %04x\n",
+ printk(BIOS_ERR, "ID mismatch: Vendor ID %04x, Device ID %04x\n",
rom_data->vendor, rom_data->device);
return NULL;
}
- printk_spew("PCI ROM Image, Class Code %04x%02x, Code Type %02x\n",
+ printk(BIOS_SPEW, "PCI ROM Image, Class Code %04x%02x, Code Type %02x\n",
rom_data->class_hi, rom_data->class_lo,
rom_data->type);
if (dev->class != ((rom_data->class_hi << 8) | rom_data->class_lo)) {
- printk_debug("Class Code mismatch ROM %08x, dev %08x\n",
- (rom_data->class_hi << 8) | rom_data->class_lo, dev->class);
+ printk(BIOS_DEBUG, "Class Code mismatch ROM %08x, dev %08x\n",
+ (rom_data->class_hi << 8) | rom_data->class_lo,
+ dev->class);
//return NULL;
}
rom_size = rom_header->size * 512;
- if (PCI_CLASS_DISPLAY_VGA == rom_data->class_hi) {
+ // We check to see if the device thinks it is a VGA device not
+ // whether the ROM image is for a VGA device because some
+ // 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
extern device_t vga_pri; // the primary vga device, defined in device.c
if (dev != vga_pri) return NULL; // only one VGA supported
#endif
if ((void *)PCI_VGA_RAM_IMAGE_START != rom_header) {
- printk_debug("copying VGA ROM Image from %p to 0x%x, 0x%x bytes\n",
+ printk(BIOS_DEBUG, "copying VGA ROM Image from %p to 0x%x, 0x%x bytes\n",
rom_header, PCI_VGA_RAM_IMAGE_START, rom_size);
memcpy((void *)PCI_VGA_RAM_IMAGE_START, rom_header, rom_size);
}
return (struct rom_header *) (PCI_VGA_RAM_IMAGE_START);
}
- printk_debug("copying non-VGA ROM Image from %p to %p, 0x%x bytes\n",
+ printk(BIOS_DEBUG, "copying non-VGA ROM Image from %p to %p, 0x%x bytes\n",
rom_header, pci_ram_image_start, rom_size);
memcpy(pci_ram_image_start, rom_header, rom_size);