From patchwork Tue Dec 14 00:49:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 75451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 365F91007D2 for ; Tue, 14 Dec 2010 12:02:19 +1100 (EST) Received: from localhost ([127.0.0.1]:59856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSJHL-0007g4-8i for incoming@patchwork.ozlabs.org; Mon, 13 Dec 2010 20:02:07 -0500 Received: from [140.186.70.92] (port=54777 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSJ6e-0003H6-Ji for qemu-devel@nongnu.org; Mon, 13 Dec 2010 19:51:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSJ6M-0005N3-Mv for qemu-devel@nongnu.org; Mon, 13 Dec 2010 19:50:47 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:38820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSJ6M-0005MK-C1 for qemu-devel@nongnu.org; Mon, 13 Dec 2010 19:50:46 -0500 Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate02.web.de (Postfix) with ESMTP id 67F4718D7351B; Tue, 14 Dec 2010 01:50:44 +0100 (CET) Received: from [84.148.38.31] (helo=localhost.localdomain) by smtp04.web.de with asmtp (WEB.DE 4.110 #24) id 1PSJ6K-0007dg-00; Tue, 14 Dec 2010 01:50:44 +0100 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 14 Dec 2010 01:49:16 +0100 Message-Id: <1292287758-8009-3-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1292287758-8009-2-git-send-email-andreas.faerber@web.de> References: <1292287758-8009-1-git-send-email-andreas.faerber@web.de> <1292287758-8009-2-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 X-Sender: Andreas.Faerber@web.de X-Provags-ID: V01U2FsdGVkX19GlTpI3ogvOvPEIuwYhpTvV8FymJRnIuON1xVe +2MFj3I/kcIJX7oVkgtrs8CRTnmwxBbT5GGa1A/R+5vTBqg1zt QYmyk1EG3qzrxUC6lrJg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , hpoussin@reactos.org, agraf@suse.de Subject: [Qemu-devel] [PATCH 2/4] prep: Add ELF support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Cc: Hervé Poussineau Signed-off-by: Andreas Färber --- 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); }