We want to move to a model where firmware loads our kernel. To achieve this we need to be able to tell firmware where the kernel lies.
Let's copy the mechanism we already use for -M pseries and expose the kernel load address and size through the device tree. Signed-off-by: Alexander Graf <ag...@suse.de> --- hw/ppc/e500.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index b37ce9d..f8a76b7 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -128,6 +128,8 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args, hwaddr addr, hwaddr initrd_base, hwaddr initrd_size, + hwaddr kernel_base, + hwaddr kernel_size, bool dry_run) { CPUPPCState *env = first_cpu->env_ptr; @@ -204,6 +206,13 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args, if (ret < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); } + + } + + if (kernel_base != -1ULL) { + qemu_fdt_setprop_cells(fdt, "/chosen", "qemu,boot-kernel", + kernel_base >> 32, kernel_base, + kernel_size >> 32, kernel_size); } ret = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", @@ -389,20 +398,25 @@ typedef struct DeviceTreeParams { hwaddr addr; hwaddr initrd_base; hwaddr initrd_size; + hwaddr kernel_base; + hwaddr kernel_size; } DeviceTreeParams; static void ppce500_reset_device_tree(void *opaque) { DeviceTreeParams *p = opaque; ppce500_load_device_tree(&p->args, &p->params, p->addr, p->initrd_base, - p->initrd_size, false); + p->initrd_size, p->kernel_base, p->kernel_size, + false); } static int ppce500_prep_device_tree(QEMUMachineInitArgs *args, PPCE500Params *params, hwaddr addr, hwaddr initrd_base, - hwaddr initrd_size) + hwaddr initrd_size, + hwaddr kernel_base, + hwaddr kernel_size) { DeviceTreeParams *p = g_new(DeviceTreeParams, 1); p->args = *args; @@ -410,12 +424,15 @@ static int ppce500_prep_device_tree(QEMUMachineInitArgs *args, p->addr = addr; p->initrd_base = initrd_base; p->initrd_size = initrd_size; + p->kernel_base = kernel_base; + p->kernel_size = kernel_size; qemu_register_reset(ppce500_reset_device_tree, p); /* Issue the device tree loader once, so that we get the size of the blob */ return ppce500_load_device_tree(args, params, addr, initrd_base, - initrd_size, true); + initrd_size, kernel_base, kernel_size, + true); } /* Create -kernel TLB entries for BookE. */ @@ -782,7 +799,8 @@ void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params) int dt_size; dt_size = ppce500_prep_device_tree(args, params, dt_base, - initrd_base, initrd_size); + initrd_base, initrd_size, + loadaddr, kernel_size); if (dt_size < 0) { fprintf(stderr, "couldn't load device tree\n"); exit(1); -- 1.8.1.4