* [Qemu-devel] [PATCH] Mac99: Enable -kernel option
@ 2009-02-28 15:09 Alexander Graf
2009-02-28 15:42 ` Blue Swirl
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2009-02-28 15:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexander Graf
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Mac99: Enable -kernel option
2009-02-28 15:09 [Qemu-devel] [PATCH] Mac99: Enable -kernel option Alexander Graf
@ 2009-02-28 15:42 ` Blue Swirl
2009-03-01 20:42 ` Aurelien Jarno
0 siblings, 1 reply; 4+ messages in thread
From: Blue Swirl @ 2009-02-28 15:42 UTC (permalink / raw)
To: qemu-devel, Aurelien Jarno
[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]
On 2/28/09, Alexander Graf <agraf@suse.de> wrote:
> 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.
There have been some discussions to switch to using the firmware
configuration device for the kernel address etc. Then the NVRAM
structure would not be used. These patches (by Aurelien and myself)
should do the switch.
[-- Attachment #2: openbios-0002-Add-new-entries-to-firmware-configuration-device.patch --]
[-- Type: application/x-patch, Size: 1091 bytes --]
[-- Attachment #3: openbios-0003-Use-firmware-configuration-instead-of-NVRAM.patch --]
[-- Type: application/x-patch, Size: 12650 bytes --]
[-- Attachment #4: qemu-0001-Add-new-entries-to-firmware-configuration-device.patch --]
[-- Type: application/x-patch, Size: 1005 bytes --]
[-- Attachment #5: qemu-0002-Use-firmware-configuration-instead-of.patch --]
[-- Type: application/x-patch, Size: 18104 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Mac99: Enable -kernel option
2009-02-28 15:42 ` Blue Swirl
@ 2009-03-01 20:42 ` Aurelien Jarno
2009-03-02 18:48 ` Blue Swirl
0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2009-03-01 20:42 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
On Sat, Feb 28, 2009 at 05:42:11PM +0200, Blue Swirl wrote:
> On 2/28/09, Alexander Graf <agraf@suse.de> wrote:
> > 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.
>
> There have been some discussions to switch to using the firmware
> configuration device for the kernel address etc. Then the NVRAM
> structure would not be used. These patches (by Aurelien and myself)
> should do the switch.
I wanted to work a bit on those patches, but never found the time to do
that. The best is to commit them as they are know, as they are already
an improvement. They can be improved later.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Mac99: Enable -kernel option
2009-03-01 20:42 ` Aurelien Jarno
@ 2009-03-02 18:48 ` Blue Swirl
0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2009-03-02 18:48 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: qemu-devel
On 3/1/09, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On Sat, Feb 28, 2009 at 05:42:11PM +0200, Blue Swirl wrote:
> > On 2/28/09, Alexander Graf <agraf@suse.de> wrote:
> > > 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.
> >
> > There have been some discussions to switch to using the firmware
> > configuration device for the kernel address etc. Then the NVRAM
> > structure would not be used. These patches (by Aurelien and myself)
> > should do the switch.
>
>
> I wanted to work a bit on those patches, but never found the time to do
> that. The best is to commit them as they are know, as they are already
> an improvement. They can be improved later.
Maybe, though I'd hate to update the OpenBIOS images just after the release.
I think there was also some doubt whether the configuration device is
suitable for kernel/initrd stuff.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-02 18:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-28 15:09 [Qemu-devel] [PATCH] Mac99: Enable -kernel option Alexander Graf
2009-02-28 15:42 ` Blue Swirl
2009-03-01 20:42 ` Aurelien Jarno
2009-03-02 18:48 ` Blue Swirl
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).