PPC: e500: Expose kernel load address in dt

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 <agraf@suse.de>
This commit is contained in:
Alexander Graf 2014-01-20 00:21:04 +01:00
parent 4d09d5291d
commit 903585dec6

View File

@ -128,6 +128,8 @@ static int ppce500_load_device_tree(MachineState *machine,
hwaddr addr, hwaddr addr,
hwaddr initrd_base, hwaddr initrd_base,
hwaddr initrd_size, hwaddr initrd_size,
hwaddr kernel_base,
hwaddr kernel_size,
bool dry_run) bool dry_run)
{ {
CPUPPCState *env = first_cpu->env_ptr; CPUPPCState *env = first_cpu->env_ptr;
@ -204,6 +206,13 @@ static int ppce500_load_device_tree(MachineState *machine,
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); 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", ret = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
@ -392,20 +401,25 @@ typedef struct DeviceTreeParams {
hwaddr addr; hwaddr addr;
hwaddr initrd_base; hwaddr initrd_base;
hwaddr initrd_size; hwaddr initrd_size;
hwaddr kernel_base;
hwaddr kernel_size;
} DeviceTreeParams; } DeviceTreeParams;
static void ppce500_reset_device_tree(void *opaque) static void ppce500_reset_device_tree(void *opaque)
{ {
DeviceTreeParams *p = opaque; DeviceTreeParams *p = opaque;
ppce500_load_device_tree(p->machine, &p->params, p->addr, p->initrd_base, ppce500_load_device_tree(&p->machine, &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(MachineState *machine, static int ppce500_prep_device_tree(MachineState *machine,
PPCE500Params *params, PPCE500Params *params,
hwaddr addr, hwaddr addr,
hwaddr initrd_base, hwaddr initrd_base,
hwaddr initrd_size) hwaddr initrd_size,
hwaddr kernel_base,
hwaddr kernel_size)
{ {
DeviceTreeParams *p = g_new(DeviceTreeParams, 1); DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
p->machine = machine; p->machine = machine;
@ -413,12 +427,15 @@ static int ppce500_prep_device_tree(MachineState *machine,
p->addr = addr; p->addr = addr;
p->initrd_base = initrd_base; p->initrd_base = initrd_base;
p->initrd_size = initrd_size; p->initrd_size = initrd_size;
p->kernel_base = kernel_base;
p->kernel_size = kernel_size;
qemu_register_reset(ppce500_reset_device_tree, p); qemu_register_reset(ppce500_reset_device_tree, p);
/* Issue the device tree loader once, so that we get the size of the blob */ /* Issue the device tree loader once, so that we get the size of the blob */
return ppce500_load_device_tree(machine, params, addr, initrd_base, return ppce500_load_device_tree(machine, params, addr, initrd_base,
initrd_size, true); initrd_size, kernel_base, kernel_size,
true);
} }
/* Create -kernel TLB entries for BookE. */ /* Create -kernel TLB entries for BookE. */
@ -787,7 +804,8 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
int dt_size; int dt_size;
dt_size = ppce500_prep_device_tree(machine, params, dt_base, dt_size = ppce500_prep_device_tree(machine, params, dt_base,
initrd_base, initrd_size); initrd_base, initrd_size,
loadaddr, kernel_size);
if (dt_size < 0) { if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n"); fprintf(stderr, "couldn't load device tree\n");
exit(1); exit(1);