#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) {
+ 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) {
// in case some device PCI_ROM_ADDRESS can not be set or readonly
rom_address = dev->rom_address;
- } else {
+ 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 = %x\n", dev_path(dev), rom_address);
-
if(!dev->on_mainboard) {
/* enable expansion ROM address decoding */
pci_write_config32(dev, PCI_ROM_ADDRESS,
struct rom_header *pci_rom_load(struct device *dev, struct rom_header *rom_header)
{
struct pci_data * rom_data;
- unsigned long rom_address;
unsigned int rom_size;
unsigned int image_size=0;
- rom_address = pci_read_config32(dev, PCI_ROM_ADDRESS);
-
do {
rom_header = (struct rom_header *)((void *) rom_header + image_size); // get next image
rom_data = (struct pci_data *)((void *) rom_header + le32_to_cpu(rom_header->data));
image_size = le32_to_cpu(rom_data->ilen) * 512;
} while ((rom_data->type!=0) && (rom_data->indicator!=0)); // make sure we got x86 version
- if(rom_data->type!=0) return NULL;
+ if (rom_data->type != 0)
+ return NULL;
rom_size = rom_header->size * 512;
extern device_t vga_pri; // the primary vga device, defined in device.c
if (dev != vga_pri) return NULL; // only one VGA supported
#endif
- printk_debug("copying VGA ROM Image from 0x%x to 0x%x, 0x%x bytes\n",
+ if ((void *)PCI_VGA_RAM_IMAGE_START != rom_header) {
+ printk_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);
+ memcpy((void *)PCI_VGA_RAM_IMAGE_START, rom_header, rom_size);
+ }
return (struct rom_header *) (PCI_VGA_RAM_IMAGE_START);
- } else {
- printk_debug("copying non-VGA ROM Image from 0x%x to 0x%x, 0x%x bytes\n",
- rom_header, pci_ram_image_start, rom_size);
- memcpy(pci_ram_image_start, rom_header, rom_size);
- pci_ram_image_start += rom_size;
- return (struct rom_header *) (pci_ram_image_start-rom_size);
}
- /* disable expansion ROM address decoding */
- pci_write_config32(dev, PCI_ROM_ADDRESS, rom_address & ~PCI_ROM_ADDRESS_ENABLE);
-
- return NULL;
+
+ printk_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);
+ pci_ram_image_start += rom_size;
+ return (struct rom_header *) (pci_ram_image_start-rom_size);
}