qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <andreas.faerber@web.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <andreas.faerber@web.de>,
	hpoussin@reactos.org, agraf@suse.de
Subject: [Qemu-devel] [PATCH 2/4] prep: Add ELF support
Date: Tue, 14 Dec 2010 01:49:16 +0100	[thread overview]
Message-ID: <1292287758-8009-3-git-send-email-andreas.faerber@web.de> (raw)
In-Reply-To: <1292287758-8009-2-git-send-email-andreas.faerber@web.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 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 <agraf@suse.de>
Cc: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Andreas Färber <andreas.faerber@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

  reply	other threads:[~2010-12-14  0:51 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14  0:49 [Qemu-devel] [PATCH 0/4] ppc: Fix PReP emulation Andreas Färber
2010-12-14  0:49 ` [Qemu-devel] [PATCH 1/4] prep: Remove bogus BIOS size check Andreas Färber
2010-12-14  0:49   ` Andreas Färber [this message]
2010-12-14  0:49     ` [Qemu-devel] [PATCH, RFC 3/4] prep: Fix duplicate ISA IDE IRQ Andreas Färber
2010-12-14  0:49       ` [Qemu-devel] [FYI 4/4] prep: Quickfix for ioport Andreas Färber
2010-12-26 23:28         ` Andreas Färber
2010-12-27  0:11           ` Alexander Graf
2010-12-27  0:25             ` Andreas Färber
2011-01-04 20:57               ` Alexander Graf
2011-01-04 21:36                 ` Andreas Färber
2011-01-04 21:43                   ` Alexander Graf
2011-01-04 21:59                     ` Andreas Färber
2011-01-04 22:02                       ` Alexander Graf
2010-12-20  6:37       ` [Qemu-devel] [PATCH, RFC 3/4] prep: Fix duplicate ISA IDE IRQ Andreas Färber
2010-12-20  9:07         ` Alexander Graf
2011-01-16 23:34       ` Aurelien Jarno
2010-12-19  9:52   ` [Qemu-devel] Re: [PATCH 1/4] prep: Remove bogus BIOS size check Alexander Graf
2010-12-19 12:26     ` Andreas Färber
2010-12-19 15:27       ` Alexander Graf
2010-12-19  9:54 ` [Qemu-devel] Re: [PATCH 0/4] ppc: Fix PReP emulation Alexander Graf
2010-12-19 15:04   ` Andreas Färber
2010-12-19 15:34     ` Alexander Graf
2010-12-19 19:12       ` Andreas Färber
2010-12-20  9:04         ` Alexander Graf
2010-12-20 23:00           ` Andreas Färber
2010-12-20 23:07             ` Alexander Graf
2010-12-21  0:33               ` Andreas Färber
2010-12-21  0:46                 ` Alexander Graf
2010-12-21 23:51                   ` Andreas Färber
2010-12-22  8:10                     ` Alexander Graf
2010-12-27  1:01           ` Rob Landley
2011-01-04 21:00             ` Alexander Graf
2011-01-05 12:07               ` Rob Landley
2011-01-05 12:31                 ` Alexander Graf
2011-01-06  9:31                   ` Rob Landley
2010-12-27  1:03       ` Rob Landley
2010-12-27  1:00     ` Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292287758-8009-3-git-send-email-andreas.faerber@web.de \
    --to=andreas.faerber@web.de \
    --cc=agraf@suse.de \
    --cc=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).