From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 14 Dec 2010 01:49:16 +0100 Message-Id: <1292287758-8009-3-git-send-email-andreas.faerber@web.de> 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 Content-Type: text/plain; charset=UTF-8 Sender: andreas.faerber@web.de Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/4] prep: Add ELF support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , hpoussin@reactos.org, agraf@suse.de 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 sun= 4m. Note that since we must register the maximum amount of ROM before attempt= ing 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=C3=A9 Poussineau Signed-off-by: Andreas F=C3=A4rber --- 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" =20 @@ -582,18 +583,23 @@ static void ppc_prep_init (ram_addr_t ram_size, bios_name =3D BIOS_FILENAME; filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size =3D get_image_size(filename); + cpu_register_physical_memory(0xfff00000, BIOS_SIZE, + bios_offset | IO_MEM_ROM); + bios_size =3D load_elf(filename, NULL, NULL, NULL, + NULL, NULL, 1, ELF_MACHINE, 0); + if (bios_size < 0 || bios_size > BIOS_SIZE) { + bios_size =3D get_image_size(filename); + if (bios_size > 0 && bios_size <=3D BIOS_SIZE) { + target_phys_addr_t bios_addr; + bios_size =3D (bios_size + 0xfff) & ~0xfff; + bios_addr =3D (uint32_t)(-bios_size); + bios_size =3D load_image_targphys(filename, bios_addr, + bios_size); + } + } } else { bios_size =3D -1; } - if (bios_size > 0 && bios_size <=3D BIOS_SIZE) { - target_phys_addr_t bios_addr; - bios_size =3D (bios_size + 0xfff) & ~0xfff; - bios_addr =3D (uint32_t)(-bios_size); - cpu_register_physical_memory(bios_addr, bios_size, - bios_offset | IO_MEM_ROM); - bios_size =3D 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)= ; } --=20 1.7.3