[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCHv2 6/8] lib/fdt: Add fdt_get_interrupt helper



Hi,

On 11/03/2019 09:14, Jia He wrote:
From: Wei Chen <wei.chen@xxxxxxx>
This helper will be used very frequently for devices to
get their interrupts.

Jira: ENTOS-860

What is it for?

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Jia He <justin.he@xxxxxxx>
---
  lib/fdt/exportsyms.uk    |  1 +
  lib/fdt/fdt_interrupts.c | 23 +++++++++++++++++++++++
  lib/fdt/include/libfdt.h | 12 ++++++++++++
  3 files changed, 36 insertions(+)

diff --git a/lib/fdt/exportsyms.uk b/lib/fdt/exportsyms.uk
index c893caf..bdef33c 100644
--- a/lib/fdt/exportsyms.uk
+++ b/lib/fdt/exportsyms.uk
@@ -63,3 +63,4 @@ fdt_overlay_apply
  fdt_getprop_u32_by_offset
  fdt_interrupt_cells
  fdt_get_address
+fdt_get_interrupt
diff --git a/lib/fdt/fdt_interrupts.c b/lib/fdt/fdt_interrupts.c
index 45ae963..ed8b716 100644
--- a/lib/fdt/fdt_interrupts.c
+++ b/lib/fdt/fdt_interrupts.c
@@ -87,3 +87,26 @@ int fdt_interrupt_cells(const void *fdt, int offset)
return fdt_get_cells(fdt, "#interrupt-cells", intc_offset);
  }
+
+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;
+
+       /*
+        * Interrupt content must cover the index specific irq information.
+        */
+       regs = fdt_getprop(fdt, nodeoffset, "interrupts", &len);

How about #interrupts-extended?

+       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/lib/fdt/include/libfdt.h b/lib/fdt/include/libfdt.h
index d43e710..d546b81 100644
--- a/lib/fdt/include/libfdt.h
+++ b/lib/fdt/include/libfdt.h
@@ -1178,6 +1178,18 @@ int fdt_interrupt_cells(const void *fdt, int nodeoffset);
   */
  int fdt_get_address(const void *fdt, int nodeoffset, int index,
                        uint64_t *addr, uint64_t *size);
+/**
+ * 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);
/**********************************************************************/
  /* Write-in-place functions                                           */


Cheers,

--
Julien Grall

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.