hw/riscv/sifive_u: use 'fdt' from MachineState
The MachineState object provides a 'fdt' pointer that is already being used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP command. Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt instead. Cc: Palmer Dabbelt <palmer@dabbelt.com> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Message-Id: <20230102115241.25733-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
3139929da4
commit
60c7dfa2a3
@ -98,7 +98,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
|
|||||||
{
|
{
|
||||||
MachineState *ms = MACHINE(qdev_get_machine());
|
MachineState *ms = MACHINE(qdev_get_machine());
|
||||||
void *fdt;
|
void *fdt;
|
||||||
int cpu;
|
int cpu, fdt_size;
|
||||||
uint32_t *cells;
|
uint32_t *cells;
|
||||||
char *nodename;
|
char *nodename;
|
||||||
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
|
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
|
||||||
@ -112,14 +112,14 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (ms->dtb) {
|
if (ms->dtb) {
|
||||||
fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size);
|
fdt = ms->fdt = load_device_tree(ms->dtb, &fdt_size);
|
||||||
if (!fdt) {
|
if (!fdt) {
|
||||||
error_report("load_device_tree() failed");
|
error_report("load_device_tree() failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
goto update_bootargs;
|
goto update_bootargs;
|
||||||
} else {
|
} else {
|
||||||
fdt = s->fdt = create_device_tree(&s->fdt_size);
|
fdt = ms->fdt = create_device_tree(&fdt_size);
|
||||||
if (!fdt) {
|
if (!fdt) {
|
||||||
error_report("create_device_tree() failed");
|
error_report("create_device_tree() failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -612,9 +612,9 @@ static void sifive_u_machine_init(MachineState *machine)
|
|||||||
hwaddr end = riscv_load_initrd(machine->initrd_filename,
|
hwaddr end = riscv_load_initrd(machine->initrd_filename,
|
||||||
machine->ram_size, kernel_entry,
|
machine->ram_size, kernel_entry,
|
||||||
&start);
|
&start);
|
||||||
qemu_fdt_setprop_cell(s->fdt, "/chosen",
|
qemu_fdt_setprop_cell(machine->fdt, "/chosen",
|
||||||
"linux,initrd-start", start);
|
"linux,initrd-start", start);
|
||||||
qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end",
|
qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-end",
|
||||||
end);
|
end);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -627,14 +627,11 @@ static void sifive_u_machine_init(MachineState *machine)
|
|||||||
|
|
||||||
/* Compute the fdt load address in dram */
|
/* Compute the fdt load address in dram */
|
||||||
fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DEV_DRAM].base,
|
fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DEV_DRAM].base,
|
||||||
machine->ram_size, s->fdt);
|
machine->ram_size, machine->fdt);
|
||||||
if (!riscv_is_32bit(&s->soc.u_cpus)) {
|
if (!riscv_is_32bit(&s->soc.u_cpus)) {
|
||||||
start_addr_hi32 = (uint64_t)start_addr >> 32;
|
start_addr_hi32 = (uint64_t)start_addr >> 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set machine->fdt for 'dumpdtb' QMP/HMP command */
|
|
||||||
machine->fdt = s->fdt;
|
|
||||||
|
|
||||||
/* reset vector */
|
/* reset vector */
|
||||||
uint32_t reset_vec[12] = {
|
uint32_t reset_vec[12] = {
|
||||||
s->msel, /* MSEL pin state */
|
s->msel, /* MSEL pin state */
|
||||||
|
@ -69,9 +69,6 @@ typedef struct SiFiveUState {
|
|||||||
/*< public >*/
|
/*< public >*/
|
||||||
SiFiveUSoCState soc;
|
SiFiveUSoCState soc;
|
||||||
|
|
||||||
void *fdt;
|
|
||||||
int fdt_size;
|
|
||||||
|
|
||||||
bool start_in_flash;
|
bool start_in_flash;
|
||||||
uint32_t msel;
|
uint32_t msel;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user