At the time of bev/bcv initialization the device rom was loaded from is no longer know. Only memory address where rom resides is know at this point. This patch create mapping between boot priority and rom address at rom initialization time for use during bev/bcv init.
Signed-off-by: Gleb Natapov gleb@redhat.com --- src/optionroms.c | 35 ++++++++++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/optionroms.c b/src/optionroms.c index 854c33f..33f2a03 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -74,6 +74,23 @@ struct pnp_data { // The end of the last deployed rom. u32 RomEnd = BUILD_ROM_START;
+static struct rom_dev { + u32 addr; + u8 prio; +} rom2prio[92]; + +static int rom2prio_cnt; + +static void map_rom2prio(void *addr, u8 prio) +{ + if (rom2prio_cnt < ARRAY_SIZE(rom2prio)) { + rom2prio[rom2prio_cnt].addr = (u32)addr; + rom2prio[rom2prio_cnt].prio = prio; + dprintf(3, "pci rom at memory address %x has boot prio %d\n", + rom2prio[rom2prio_cnt].addr, rom2prio[rom2prio_cnt].prio); + rom2prio_cnt++; + } +}
/**************************************************************** * Helper functions @@ -248,8 +265,12 @@ run_file_roms(const char *prefix, int isvga) if (!file) break; int ret = romfile_copy(file, (void*)RomEnd, max_rom() - RomEnd); - if (ret > 0) - init_optionrom((void*)RomEnd, 0, isvga); + if (ret > 0) { + void *rom = (void*)RomEnd; + ret = init_optionrom(rom, 0, isvga); + if (!ret && is_valid_rom(rom)) + map_rom2prio(rom, bootprio_find_named_rom(romfile_name(file))); + } } }
@@ -342,7 +363,15 @@ init_pcirom(u16 bdf, int isvga) if (! rom) // No ROM present. return -1; - return init_optionrom(rom, bdf, isvga); + + int r = init_optionrom(rom, bdf, isvga); + + if (r || !is_valid_rom(rom)) + return r; + + map_rom2prio(rom, bootprio_find_pci_device(bdf)); + + return r; }