hw/riscv: virt: Allow passing custom DTB
Extend virt machine to allow passing custom DTB using "-dtb" command-line parameter. This will help users pass modified DTB to virt machine. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20201022053225.2596110-2-anup.patel@wdc.com Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
d5c90cf3f6
commit
4e1e3003fb
@ -181,6 +181,7 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
|
|||||||
{
|
{
|
||||||
void *fdt;
|
void *fdt;
|
||||||
int i, cpu, socket;
|
int i, cpu, socket;
|
||||||
|
const char *dtb_filename;
|
||||||
MachineState *mc = MACHINE(s);
|
MachineState *mc = MACHINE(s);
|
||||||
uint64_t addr, size;
|
uint64_t addr, size;
|
||||||
uint32_t *clint_cells, *plic_cells;
|
uint32_t *clint_cells, *plic_cells;
|
||||||
@ -194,11 +195,21 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
|
|||||||
hwaddr flashsize = virt_memmap[VIRT_FLASH].size / 2;
|
hwaddr flashsize = virt_memmap[VIRT_FLASH].size / 2;
|
||||||
hwaddr flashbase = virt_memmap[VIRT_FLASH].base;
|
hwaddr flashbase = virt_memmap[VIRT_FLASH].base;
|
||||||
|
|
||||||
|
dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
|
||||||
|
if (dtb_filename) {
|
||||||
|
fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size);
|
||||||
|
if (!fdt) {
|
||||||
|
error_report("load_device_tree() failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
goto update_bootargs;
|
||||||
|
} else {
|
||||||
fdt = s->fdt = create_device_tree(&s->fdt_size);
|
fdt = s->fdt = create_device_tree(&s->fdt_size);
|
||||||
if (!fdt) {
|
if (!fdt) {
|
||||||
error_report("create_device_tree() failed");
|
error_report("create_device_tree() failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qemu_fdt_setprop_string(fdt, "/", "model", "riscv-virtio,qemu");
|
qemu_fdt_setprop_string(fdt, "/", "model", "riscv-virtio,qemu");
|
||||||
qemu_fdt_setprop_string(fdt, "/", "compatible", "riscv-virtio");
|
qemu_fdt_setprop_string(fdt, "/", "compatible", "riscv-virtio");
|
||||||
@ -418,9 +429,6 @@ static void create_fdt(RISCVVirtState *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", name);
|
qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", name);
|
||||||
if (cmdline) {
|
|
||||||
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
|
|
||||||
}
|
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
name = g_strdup_printf("/soc/rtc@%lx", (long)memmap[VIRT_RTC].base);
|
name = g_strdup_printf("/soc/rtc@%lx", (long)memmap[VIRT_RTC].base);
|
||||||
@ -441,6 +449,11 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
|
|||||||
2, flashbase + flashsize, 2, flashsize);
|
2, flashbase + flashsize, 2, flashsize);
|
||||||
qemu_fdt_setprop_cell(s->fdt, name, "bank-width", 4);
|
qemu_fdt_setprop_cell(s->fdt, name, "bank-width", 4);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
|
update_bootargs:
|
||||||
|
if (cmdline) {
|
||||||
|
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,
|
static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,
|
||||||
|
Loading…
Reference in New Issue
Block a user