In order to switch from abondoned OpenHack'Ware to OpenBIOS firmware, the PReP machine needs to be able to load an ELF BIOS.
ELF loading is adapted from ppc_newworld, the fallback mechanism from sun4m. Note that since we must register the maximum amount of ROM before attempting to load an ELF BIOS and since there is no cpu_unregister_physical_memory(), raw BIOS files such as OHW may now be preceded by unused ROM memory. Cc: Alexander Graf <ag...@suse.de> Cc: Hervé Poussineau <hpous...@reactos.org> Signed-off-by: Andreas Färber <andreas.faer...@web.de> --- hw/ppc_prep.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 6b22122..3575dee 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -36,6 +36,7 @@ #include "qemu-log.h" #include "ide.h" #include "loader.h" +#include "elf.h" #include "mc146818rtc.h" #include "blockdev.h" @@ -582,18 +583,23 @@ static void ppc_prep_init (ram_addr_t ram_size, bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size = get_image_size(filename); + cpu_register_physical_memory(0xfff00000, BIOS_SIZE, + bios_offset | IO_MEM_ROM); + bios_size = load_elf(filename, NULL, NULL, NULL, + NULL, NULL, 1, ELF_MACHINE, 0); + if (bios_size < 0 || bios_size > BIOS_SIZE) { + bios_size = get_image_size(filename); + if (bios_size > 0 && bios_size <= BIOS_SIZE) { + target_phys_addr_t bios_addr; + bios_size = (bios_size + 0xfff) & ~0xfff; + bios_addr = (uint32_t)(-bios_size); + bios_size = load_image_targphys(filename, bios_addr, + bios_size); + } + } } else { bios_size = -1; } - if (bios_size > 0 && bios_size <= BIOS_SIZE) { - target_phys_addr_t bios_addr; - bios_size = (bios_size + 0xfff) & ~0xfff; - bios_addr = (uint32_t)(-bios_size); - cpu_register_physical_memory(bios_addr, bios_size, - bios_offset | IO_MEM_ROM); - bios_size = load_image_targphys(filename, bios_addr, bios_size); - } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name); } -- 1.7.3