qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <alex@csgraf.de>
Subject: [Qemu-devel] [PATCH] Mac99: Enable -kernel option
Date: Sat, 28 Feb 2009 16:09:55 +0100	[thread overview]
Message-ID: <1235833795-30441-1-git-send-email-agraf@suse.de> (raw)

Right now -kernel on the Mac99 (newworld) is broken.

For starters, the kernel is 1:1 mapped into to virtual machine, which
is not what OpenBIOS expects - it wants a preprocessed ELF image.
So I just copied over the code from oldworld.c that loads the kernel.

While this is not overly pretty, it works so far and keeps working
code working. I don't feel comfortable on restructuring newworld and
oldworld just yet - AFAIK newworld is not exactly is a good shape anyways.

The second issue is the NVRAM. It doesn't get initialized, so the
firmware has no idea that a kernel image was actually loaded!

I first tried to use the macio nvram device that was specified there,
but that didn't work out, so in order to get something working for now,
I took the code from oldworld.c again, which works at least with
OpenBIOS.

Using this patch I can use -kernel on the Mac99 machine.

Signed-off-by: Alexander Graf <alex@csgraf.de>
---
 hw/ppc_newworld.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 6f60e49..a086f33 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -94,6 +94,8 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
     uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
     PCIBus *pci_bus;
     MacIONVRAMState *nvr;
+    nvram_t nvram;
+    m48t59_t *m48t59;
     int nvram_mem_index;
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
@@ -166,9 +168,23 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
     }
 
     if (linux_boot) {
+        uint64_t lowaddr = 0;
         kernel_base = KERNEL_LOAD_ADDR;
-        /* now we can load the kernel */
-        kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
+        /* Now we can load the kernel. The first step tries to load the kernel
+           supposing PhysAddr = 0x00000000. If that was wrong the kernel is
+           loaded again, the new PhysAddr being computed from lowaddr. */
+        kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
+        if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
+            kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
+                                   NULL, 0, NULL);
+        }
+        if (kernel_size < 0)
+            kernel_size = load_aout(kernel_filename, kernel_base,
+                                    ram_size - kernel_base);
+        if (kernel_size < 0)
+            kernel_size = load_image_targphys(kernel_filename,
+                                              kernel_base,
+                                              ram_size - kernel_base);
         if (kernel_size < 0) {
             cpu_abort(env, "qemu: could not load kernel '%s'\n",
                       kernel_filename);
@@ -313,7 +329,27 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
     /* The NewWorld NVRAM is not located in the MacIO device */
     nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1);
     pmac_format_nvram_partition(nvr, 0x2000);
+# if 0
     macio_nvram_map(nvr, 0xFFF04000);
+
+    nvram.opaque = nvr;
+    nvram.read_fn = &macio_nvram_read;
+    nvram.write_fn = &macio_nvram_write;
+#else
+    m48t59 = m48t59_init(0, 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
+    nvram.opaque = m48t59;
+    nvram.read_fn = &m48t59_read;
+    nvram.write_fn = &m48t59_write;
+#endif
+    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size,
+                         ppc_boot_device, kernel_base, kernel_size,
+                         kernel_cmdline,
+                         initrd_base, initrd_size,
+                         /* XXX: need an option to load a NVRAM image */
+                         0,
+                         graphic_width, graphic_height, graphic_depth);
+
+
     /* No PCI init: the BIOS will do it */
 
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
-- 
1.5.3.1

             reply	other threads:[~2009-02-28 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-28 15:09 Alexander Graf [this message]
2009-02-28 15:42 ` [Qemu-devel] [PATCH] Mac99: Enable -kernel option Blue Swirl
2009-03-01 20:42   ` Aurelien Jarno
2009-03-02 18:48     ` Blue Swirl

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=1235833795-30441-1-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=alex@csgraf.de \
    --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).