summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAndreas Färber <andreas.faerber@web.de>2013-04-27 21:23:23 +0200
committerAndreas Färber <andreas.faerber@web.de>2013-05-05 20:44:26 +0200
commit97c42c3c93d58e14960bfd78771ed154a860acf8 (patch)
tree723feb373891440dfbcee59fa29aaac04c150cfc /hw
parent88432756ead526d9c321c20f10fafdbe40e5eaba (diff)
downloadqemu-97c42c3c93d58e14960bfd78771ed154a860acf8.zip
prep: Add ELF support for -bios
This prepares for switching from OpenHack'Ware to OpenBIOS. While touching the error handling code, switch from aborting hw_error() to fprintf()+exit() and suppress failing without -bios for qtest. Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Diffstat (limited to 'hw')
-rw-r--r--hw/ppc/prep.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 2ad5b41f1d..afa62d7783 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -40,7 +40,9 @@
#include "hw/isa/pc87312.h"
#include "sysemu/blockdev.h"
#include "sysemu/arch_init.h"
+#include "sysemu/qtest.h"
#include "exec/address-spaces.h"
+#include "elf.h"
//#define HARD_DEBUG_PPC_IO
//#define DEBUG_PPC_IO
@@ -505,18 +507,29 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
- bios_size = get_image_size(filename);
+ bios_size = load_elf(filename, NULL, NULL, NULL,
+ NULL, NULL, 1, ELF_MACHINE, 0);
+ if (bios_size < 0) {
+ bios_size = get_image_size(filename);
+ if (bios_size > 0 && bios_size <= BIOS_SIZE) {
+ hwaddr bios_addr;
+ bios_size = (bios_size + 0xfff) & ~0xfff;
+ bios_addr = (uint32_t)(-bios_size);
+ bios_size = load_image_targphys(filename, bios_addr, bios_size);
+ }
+ if (bios_size > BIOS_SIZE) {
+ fprintf(stderr, "qemu: PReP bios '%s' is too large (0x%x)\n",
+ bios_name, bios_size);
+ exit(1);
+ }
+ }
} else {
bios_size = -1;
}
- if (bios_size > 0 && bios_size <= BIOS_SIZE) {
- hwaddr bios_addr;
- bios_size = (bios_size + 0xfff) & ~0xfff;
- bios_addr = (uint32_t)(-bios_size);
- 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);
+ if (bios_size < 0 && !qtest_enabled()) {
+ fprintf(stderr, "qemu: could not load PPC PReP bios '%s'\n",
+ bios_name);
+ exit(1);
}
if (filename) {
g_free(filename);