mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-06 20:16:37 +00:00
riscv: sifive_u: Add support for loading initrd
Add support for loading initrd with "-initrd <filename>" to the sifive_u machine. This lets us boot into Linux without disk drive. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
parent
f8c3db33a5
commit
0f8d446249
@ -67,7 +67,7 @@ static const struct MemmapEntry {
|
||||
|
||||
#define GEM_REVISION 0x10070109
|
||||
|
||||
static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
|
||||
static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
|
||||
uint64_t mem_size, const char *cmdline)
|
||||
{
|
||||
void *fdt;
|
||||
@ -244,11 +244,14 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
|
||||
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
|
||||
}
|
||||
g_free(nodename);
|
||||
|
||||
return fdt;
|
||||
}
|
||||
|
||||
static void riscv_sifive_u_init(MachineState *machine)
|
||||
{
|
||||
const struct MemmapEntry *memmap = sifive_u_memmap;
|
||||
void *fdt;
|
||||
|
||||
SiFiveUState *s = g_new0(SiFiveUState, 1);
|
||||
MemoryRegion *system_memory = get_system_memory();
|
||||
@ -269,13 +272,24 @@ static void riscv_sifive_u_init(MachineState *machine)
|
||||
main_mem);
|
||||
|
||||
/* create device tree */
|
||||
create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline);
|
||||
fdt = create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline);
|
||||
|
||||
riscv_find_and_load_firmware(machine, BIOS_FILENAME,
|
||||
memmap[SIFIVE_U_DRAM].base);
|
||||
|
||||
if (machine->kernel_filename) {
|
||||
riscv_load_kernel(machine->kernel_filename);
|
||||
uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename);
|
||||
|
||||
if (machine->initrd_filename) {
|
||||
hwaddr start;
|
||||
hwaddr end = riscv_load_initrd(machine->initrd_filename,
|
||||
machine->ram_size, kernel_entry,
|
||||
&start);
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen",
|
||||
"linux,initrd-start", start);
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
|
||||
end);
|
||||
}
|
||||
}
|
||||
|
||||
/* reset vector */
|
||||
|
Loading…
x
Reference in New Issue
Block a user