[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCHv3 5/6] plat/common: Introduce fdt_get_interrupt helper
From: Wei Chen <wei.chen@xxxxxxx> This helper will be used very frequently for devices to get their interrupts. Signed-off-by: Wei Chen <wei.chen@xxxxxxx> Signed-off-by: Jia He <justin.he@xxxxxxx> --- plat/common/arm/irq_fdt.c | 29 +++++++++++++++++++++++++++++ plat/common/include/arm/irq_fdt.h | 12 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/plat/common/arm/irq_fdt.c b/plat/common/arm/irq_fdt.c index a13b04d..393975b 100644 --- a/plat/common/arm/irq_fdt.c +++ b/plat/common/arm/irq_fdt.c @@ -177,3 +177,32 @@ int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset, return FDT_ERR_NOTFOUND; } + +const void *fdt_get_interrupt(const void *fdt, int nodeoffset, + int index, int *size) +{ + int nintr, len, term_size; + const void *regs; + + nintr = fdt_interrupt_cells(fdt, nodeoffset); + if (nintr < 0 || nintr >= FDT_MAX_NCELLS) + return NULL; + + /* "interrupts-extended" is not supported */ + regs = fdt_getprop(fdt, nodeoffset, "interrupts-extended", &len); + if (regs) { + uk_pr_warn("property interrupts-extended is not supported\n"); + return NULL; + } + /* + * Interrupt content must cover the index specific irq information. + */ + regs = fdt_getprop(fdt, nodeoffset, "interrupts", &len); + term_size = (int)sizeof(fdt32_t) * nintr; + if (regs == NULL || len < term_size * (index + 1)) + return NULL; + + *size = nintr; + + return regs + term_size * index; +} diff --git a/plat/common/include/arm/irq_fdt.h b/plat/common/include/arm/irq_fdt.h index 9d7c802..c9c377c 100644 --- a/plat/common/include/arm/irq_fdt.h +++ b/plat/common/include/arm/irq_fdt.h @@ -117,3 +117,15 @@ int fdt_get_address(const void *fdt, int nodeoffset, int index, int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset, const char *compatibles[]); +/** + * fdt_get_interrupt - retrieve device interrupt of a given index + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node to find the address for + * @index: the index of interrupt we want to retrieve + * @size: interrupt cell size in fdt32_t + * + * returns: + * NULL on failed, non-NULL on success + */ +const void *fdt_get_interrupt(const void *fdt, int nodeoffset, + int index, int *size); -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |