callrom(struct rom_header *rom, u16 offset, u16 bdf)
{
u16 seg = FLATPTR_TO_SEG(rom);
- dprintf(1, "Running option rom at %x:%x\n", seg, offset);
+ dprintf(1, "Running option rom at %04x:%04x\n", seg, offset);
struct bregs br;
memset(&br, 0, sizeof(br));
&& ((OPTIONROM_VENDEV_2 >> 16)
| ((OPTIONROM_VENDEV_2 & 0xffff)) << 16) == vendev)
return copy_rom((struct rom_header *)OPTIONROM_MEM_2);
- struct rom_header *rom = cb_find_optionrom(vendev);
- if (rom)
- return copy_rom(rom);
- return NULL;
+ int ret = cbfs_copy_optionrom((void*)next_rom, BUILD_BIOS_ADDR - next_rom
+ , vendev);
+ if (ret < 0)
+ return NULL;
+ return (struct rom_header *)next_rom;
}
// Map the option rom of a given PCI device.
static struct rom_header *
map_optionrom(u16 bdf, u32 vendev)
{
- dprintf(6, "Attempting to map option rom on dev %x\n", bdf);
+ dprintf(6, "Attempting to map option rom on dev %02x:%02x.%x\n"
+ , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf));
u8 htype = pci_config_readb(bdf, PCI_HEADER_TYPE);
if ((htype & 0x7f) != PCI_HEADER_TYPE_NORMAL) {
return NULL;
}
-// Attempt to map and initialize the option rom on a given PCI device.
+// Adjust for the size of an option rom; allow it to resize.
static struct rom_header *
-init_optionrom(u16 bdf)
+verifysize_optionrom(struct rom_header *rom, u16 bdf)
{
- u32 vendev = pci_config_readl(bdf, PCI_VENDOR_ID);
- dprintf(4, "Attempting to init PCI bdf %x (dev/ven %x)\n", bdf, vendev);
- struct rom_header *rom = lookup_hardcode(vendev);
- if (! rom)
- rom = map_optionrom(bdf, vendev);
- if (! rom)
- // No ROM present.
- return NULL;
-
if (! is_valid_rom(rom))
return NULL;
return rom;
}
+// Attempt to map and initialize the option rom on a given PCI device.
+static struct rom_header *
+init_optionrom(u16 bdf)
+{
+ u32 vendev = pci_config_readl(bdf, PCI_VENDOR_ID);
+ dprintf(4, "Attempting to init PCI bdf %02x:%02x.%x (dev/ven %x)\n"
+ , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)
+ , vendev);
+ struct rom_header *rom = lookup_hardcode(vendev);
+ if (! rom)
+ rom = map_optionrom(bdf, vendev);
+ if (! rom)
+ // No ROM present.
+ return NULL;
+ return verifysize_optionrom(rom, bdf);
+}
+
/****************************************************************
* Non-VGA option rom init
continue;
init_optionrom(bdf);
}
+
+ // Find and deploy CBFS roms not associated with a device.
+ struct cbfs_file *tmp = NULL;
+ for (;;) {
+ tmp = cbfs_copy_gen_optionrom(
+ (void*)next_rom, BUILD_BIOS_ADDR - next_rom, tmp);
+ if (!tmp)
+ break;
+ verifysize_optionrom((void*)next_rom, 0);
+ }
}
// All option roms found and deployed - now build BEV/BCV vectors.