summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>2026-08-28 17:39:08 -0300
committerAlistair Francis <alistair.francis@wdc.com>2026-09-04 09:34:21 +1000
commitabda691fc69a03f2389e6642cc095e0567bf0413 (patch)
tree0284da9f9b284fbed93f52b504e6568308755e8d /include
parent265194bcba0e44372ec9f2e26c675fa0a982830c (diff)
downloadqemu-abda691fc69a03f2389e6642cc095e0567bf0413.tar.gz
qemu-abda691fc69a03f2389e6642cc095e0567bf0413.zip
hw/riscv/fdt_common, virt.c: add riscv_create_fdt_imsic()
The FDT related to interrupt controllers should definitely be put into helpers, even if only 'virt' benefits from it, due to the amount of code that is relieved from the board alone. We'll start with 'imsic'. For this endeavor we're going to use a helper struct that will carry all the extra FDT arguments in a human format. The alternative would be to add 8 more function arguments, on top of 4 phandle arguments that we're passing around in all these controllers, and that's not only a poor reading experience but it's quite error prone too. We do not want to crowd the fdt-helper with non-FDT logic, hence we're handling the !kvm_enabled() cond in virt.c using the imsic_m_base argument. This is a pattern that we'll fall back on in the next patches too. No FDT changes made. Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Chao Liu <chao.liu@processmission.com> Message-ID: <20260828203918.350131-7-daniel.barboza@oss.qualcomm.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'include')
-rw-r--r--include/hw/riscv/fdt-common.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/hw/riscv/fdt-common.h b/include/hw/riscv/fdt-common.h
index 3750230865..182c03d8ce 100644
--- a/include/hw/riscv/fdt-common.h
+++ b/include/hw/riscv/fdt-common.h
@@ -10,6 +10,8 @@
#define RISCV_VIRT_FDT_H
#include "target/riscv/cpu.h"
+#include "hw/core/boards.h"
+#include "hw/riscv/riscv_hart.h"
#define FDT_PCI_ADDR_CELLS 3
#define FDT_PCI_INT_CELLS 1
@@ -32,6 +34,22 @@ typedef enum RISCVAIAType {
AIA_TYPE_APLIC_IMSIC,
} RISCVAIAType;
+typedef struct IMSICFdtProps {
+ /*
+ * Machines will statically allocate RISCVHartArrayState[] pointer,
+ * e.g. "RISCVHartArrayState soc[VIRT_SOCKETS_MAX]". We'll have
+ * to use a void* pointer to handle a soc with variable sizes.
+ */
+ void *soc;
+ hwaddr imsic_m_base;
+ hwaddr imsic_s_base;
+ int socket_count;
+ int smp_cpus;
+ int imsic_group_max_size;
+ int irqchip_num_msis;
+ int aia_guests;
+} IMSICFdtProps;
+
void *riscv_create_board_device_tree(const char *model, const char *compatible,
int *fdt_size);
void riscv_create_fdt_socket_memory(void *fdt, hwaddr addr, uint64_t size,
@@ -77,4 +95,7 @@ void riscv_create_fdt_pcie(void *fdt, int aia_type, bool has_iommu_sys,
uint32_t irq_pcie_phandle,
uint32_t msi_pcie_phandle,
uint32_t iommu_sys_phandle, uint32_t pcie_irq);
+void riscv_create_fdt_imsic(void *fdt, IMSICFdtProps *fdt_props,
+ uint32_t *next_phandle, uint32_t *intc_phandles,
+ uint32_t *msi_m_phandle, uint32_t *msi_s_phandle);
#endif