[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Mac99: Enable -kernel option
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH] Mac99: Enable -kernel option |
Date: |
Sat, 28 Feb 2009 16:09:55 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH] Mac99: Enable -kernel option,
Alexander Graf <=