mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 11:04:58 -06:00
hw/riscv/virt.c: add aplic nodename helper
We'll change the aplic DT nodename in the next patch and the name is hardcoded in 2 different functions. Create a helper to change a single place later. While we're at it, in create_fdt_socket_aplic(), move 'aplic_name' inside the conditional to avoid allocating a string that won't be used when socket == NULL. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20240531202759.911601-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
190e0ae629
commit
02dd57b3f9
1 changed files with 8 additions and 5 deletions
|
@ -588,6 +588,12 @@ static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Caller must free string after use */
|
||||||
|
static char *fdt_get_aplic_nodename(unsigned long aplic_addr)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("/soc/aplic@%lx", aplic_addr);
|
||||||
|
}
|
||||||
|
|
||||||
static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
|
static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
|
||||||
unsigned long aplic_addr, uint32_t aplic_size,
|
unsigned long aplic_addr, uint32_t aplic_size,
|
||||||
uint32_t msi_phandle,
|
uint32_t msi_phandle,
|
||||||
|
@ -597,7 +603,7 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
|
||||||
bool m_mode, int num_harts)
|
bool m_mode, int num_harts)
|
||||||
{
|
{
|
||||||
int cpu;
|
int cpu;
|
||||||
g_autofree char *aplic_name = NULL;
|
g_autofree char *aplic_name = fdt_get_aplic_nodename(aplic_addr);
|
||||||
g_autofree uint32_t *aplic_cells = g_new0(uint32_t, num_harts * 2);
|
g_autofree uint32_t *aplic_cells = g_new0(uint32_t, num_harts * 2);
|
||||||
MachineState *ms = MACHINE(s);
|
MachineState *ms = MACHINE(s);
|
||||||
|
|
||||||
|
@ -606,7 +612,6 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
|
||||||
aplic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT);
|
aplic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr);
|
|
||||||
qemu_fdt_add_subnode(ms->fdt, aplic_name);
|
qemu_fdt_add_subnode(ms->fdt, aplic_name);
|
||||||
qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic");
|
qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic");
|
||||||
qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#address-cells",
|
qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#address-cells",
|
||||||
|
@ -648,7 +653,6 @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
|
||||||
uint32_t *aplic_phandles,
|
uint32_t *aplic_phandles,
|
||||||
int num_harts)
|
int num_harts)
|
||||||
{
|
{
|
||||||
g_autofree char *aplic_name = NULL;
|
|
||||||
unsigned long aplic_addr;
|
unsigned long aplic_addr;
|
||||||
MachineState *ms = MACHINE(s);
|
MachineState *ms = MACHINE(s);
|
||||||
uint32_t aplic_m_phandle, aplic_s_phandle;
|
uint32_t aplic_m_phandle, aplic_s_phandle;
|
||||||
|
@ -674,9 +678,8 @@ static void create_fdt_socket_aplic(RISCVVirtState *s,
|
||||||
aplic_s_phandle, 0,
|
aplic_s_phandle, 0,
|
||||||
false, num_harts);
|
false, num_harts);
|
||||||
|
|
||||||
aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr);
|
|
||||||
|
|
||||||
if (!socket) {
|
if (!socket) {
|
||||||
|
g_autofree char *aplic_name = fdt_get_aplic_nodename(aplic_addr);
|
||||||
platform_bus_add_all_fdt_nodes(ms->fdt, aplic_name,
|
platform_bus_add_all_fdt_nodes(ms->fdt, aplic_name,
|
||||||
memmap[VIRT_PLATFORM_BUS].base,
|
memmap[VIRT_PLATFORM_BUS].base,
|
||||||
memmap[VIRT_PLATFORM_BUS].size,
|
memmap[VIRT_PLATFORM_BUS].size,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue