Introduce the intc_hw_operations structure to encapsulate interrupt controller-specific data and operations. This structure includes: - A pointer to interrupt controller information (`intc_info`) - Callbacks to initialize the controller and set IRQ type/priority - A reference to an interupt controller descriptor (`host_irq_type`) - number of interrupt controller irqs.
Add function register_intc_ops() to mentioned above structure. Co-developed-by: Romain Caritey <romain.cari...@microchip.com> Signed-off-by: Oleksii Kurochko <oleksii.kuroc...@gmail.com> --- Changes in V3: - Drop inclusion of xen/irq.h in asm/intc.h as forward declaration is enogh for types used in asm/intc.h. - Drop forward declaration for dt_device_node and hw_irq_controller. - Declare intc_hw_ops as: const struct intc_hw_operations * __ro_after_init intc_hw_ops; --- Changes in V2: - Declare host_irq_type member of intc_hw_operations as pointer-to-const. - Moved up forward declaration of irq_desc. - Use attribute __init for register_intc_ops(). - Use attribute __ro_after_init for intc_hw_ops variable. - Update prototype of register_intc_ops() because of what mention in the previous point. --- xen/arch/riscv/include/asm/intc.h | 19 +++++++++++++++++++ xen/arch/riscv/intc.c | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm/intc.h index 52ba196d87..860737f965 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -12,11 +12,30 @@ enum intc_version { INTC_APLIC, }; +struct irq_desc; + struct intc_info { enum intc_version hw_version; const struct dt_device_node *node; }; +struct intc_hw_operations { + /* Hold intc hw information */ + const struct intc_info *info; + /* Initialize the intc and the boot CPU */ + int (*init)(void); + + /* hw_irq_controller to enable/disable/eoi host irq */ + const struct hw_interrupt_type *host_irq_type; + + /* Set IRQ type */ + void (*set_irq_type)(struct irq_desc *desc, unsigned int type); + /* Set IRQ priority */ + void (*set_irq_priority)(struct irq_desc *desc, unsigned int priority); +}; + void intc_preinit(void); +void register_intc_ops(const struct intc_hw_operations *ops); + #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index 4061a3c457..1ecd651bf3 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -5,6 +5,15 @@ #include <xen/init.h> #include <xen/lib.h> +#include <asm/intc.h> + +static const struct intc_hw_operations *__ro_after_init intc_hw_ops; + +void __init register_intc_ops(const struct intc_hw_operations *ops) +{ + intc_hw_ops = ops; +} + void __init intc_preinit(void) { if ( acpi_disabled ) -- 2.49.0