From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZ9RQ-0006Nw-8u for qemu-devel@nongnu.org; Sun, 05 May 2013 20:38:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZ9RO-0005XD-PT for qemu-devel@nongnu.org; Sun, 05 May 2013 20:38:08 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 6 May 2013 02:37:51 +0200 Message-Id: <1367800672-2914-3-git-send-email-andreas.faerber@web.de> In-Reply-To: <1367800672-2914-1-git-send-email-andreas.faerber@web.de> References: <1367800672-2914-1-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 2/3] prep: Add ELF support for -bios List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-ppc@nongnu.org, Alexander Graf 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 Signed-off-by: Andreas Färber --- hw/ppc/prep.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 2ad5b41..afa62d7 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); -- 1.8.1.4