Introduce a RISC-V specific function to create an interrupt controller
Device Tree node for DomU domains during dom0less build.

Add make_intc_domU_node() to the dom0less build path and wire it to
a new generic helper, intc_make_domu_dt_node(), which delegates DT
node creation to the active interrupt controller implementation via
intc_hw_ops.

Extend struct intc_hw_operations with a make_dom_dt_node callback
and expose the required interfaces in the interrupt controller header,
allowing individual interrupt controller drivers to populate DomU DT
nodes as needed.

Signed-off-by: Oleksii Kurochko <[email protected]>
---
 xen/arch/riscv/dom0less-build.c   |  9 +++++++++
 xen/arch/riscv/include/asm/intc.h | 10 ++++++++--
 xen/arch/riscv/intc.c             |  8 ++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-build.c
index 10863cffc96b..312c5d7d4979 100644
--- a/xen/arch/riscv/dom0less-build.c
+++ b/xen/arch/riscv/dom0less-build.c
@@ -3,6 +3,15 @@
 #include <xen/fdt-kernel.h>
 #include <xen/init.h>
 
+#include <asm/intc.h>
+
+int __init make_intc_domU_node(struct kernel_info *kinfo)
+{
+    intc_make_domu_dt_node(kinfo);
+
+    return 0;
+}
+
 int __init make_arch_nodes(struct kernel_info *kinfo)
 {
     /* No RISC-V specific nodes need to be made, at the moment. */
diff --git a/xen/arch/riscv/include/asm/intc.h 
b/xen/arch/riscv/include/asm/intc.h
index ecdc8a5e6577..8300d71d472f 100644
--- a/xen/arch/riscv/include/asm/intc.h
+++ b/xen/arch/riscv/include/asm/intc.h
@@ -8,14 +8,14 @@
 #ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H
 #define ASM__RISCV__INTERRUPT_CONTOLLER_H
 
-struct dt_device_node;
-
 enum intc_version {
     INTC_APLIC,
 };
 
 struct cpu_user_regs;
+struct dt_device_node;
 struct irq_desc;
+struct kernel_info;
 
 struct intc_info {
     enum intc_version hw_version;
@@ -41,6 +41,10 @@ struct intc_hw_operations {
 
     /* handle external interrupt */
     void (*handle_interrupt)(struct cpu_user_regs *regs);
+
+    /* Create interrupt controller node for domain */
+    int (*make_dom_dt_node)(const struct kernel_info *kinfo,
+                            const struct dt_device_node *intc);
 };
 
 void intc_preinit(void);
@@ -53,4 +57,6 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsigned 
int priority);
 
 void intc_handle_external_irqs(struct cpu_user_regs *regs);
 
+int intc_make_domu_dt_node(const struct kernel_info *kinfo);
+
 #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */
diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c
index ea317aea5ad8..a6f8c30f4771 100644
--- a/xen/arch/riscv/intc.c
+++ b/xen/arch/riscv/intc.c
@@ -67,3 +67,11 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsigned 
int priority)
     intc_set_irq_type(desc, desc->arch.type);
     intc_set_irq_priority(desc, priority);
 }
+
+int __init intc_make_domu_dt_node(const struct kernel_info *kinfo)
+{
+    if ( intc_hw_ops && intc_hw_ops->make_dom_dt_node )
+        return intc_hw_ops->make_dom_dt_node(kinfo, intc_hw_ops->info->node);
+
+    return -ENOSYS;
+}
-- 
2.53.0


Reply via email to