hw/riscv: sifive_u: Allow passing custom DTB
Extend sifive_u machine to allow passing custom DTB using "-dtb" command-line parameter. This will help users pass modified DTB or Linux SiFive DTB to sifive_u machine. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20201022053225.2596110-1-anup.patel@wdc.com Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
83851c7c60
commit
d5c90cf3f6
@ -100,14 +100,25 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
|
|||||||
int cpu;
|
int cpu;
|
||||||
uint32_t *cells;
|
uint32_t *cells;
|
||||||
char *nodename;
|
char *nodename;
|
||||||
|
const char *dtb_filename;
|
||||||
char ethclk_names[] = "pclk\0hclk";
|
char ethclk_names[] = "pclk\0hclk";
|
||||||
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
|
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
|
||||||
uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle;
|
uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle;
|
||||||
|
|
||||||
fdt = s->fdt = create_device_tree(&s->fdt_size);
|
dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
|
||||||
if (!fdt) {
|
if (dtb_filename) {
|
||||||
error_report("create_device_tree() failed");
|
fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size);
|
||||||
exit(1);
|
if (!fdt) {
|
||||||
|
error_report("load_device_tree() failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
goto update_bootargs;
|
||||||
|
} else {
|
||||||
|
fdt = s->fdt = create_device_tree(&s->fdt_size);
|
||||||
|
if (!fdt) {
|
||||||
|
error_report("create_device_tree() failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_fdt_setprop_string(fdt, "/", "model", "SiFive HiFive Unleashed A00");
|
qemu_fdt_setprop_string(fdt, "/", "model", "SiFive HiFive Unleashed A00");
|
||||||
@ -390,13 +401,14 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
|
|||||||
|
|
||||||
qemu_fdt_add_subnode(fdt, "/chosen");
|
qemu_fdt_add_subnode(fdt, "/chosen");
|
||||||
qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename);
|
qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename);
|
||||||
if (cmdline) {
|
|
||||||
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename);
|
qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename);
|
||||||
|
|
||||||
g_free(nodename);
|
g_free(nodename);
|
||||||
|
|
||||||
|
update_bootargs:
|
||||||
|
if (cmdline) {
|
||||||
|
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sifive_u_machine_reset(void *opaque, int n, int level)
|
static void sifive_u_machine_reset(void *opaque, int n, int level)
|
||||||
|
Loading…
Reference in New Issue
Block a user