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

[Xen-devel] [PATCH ARM v4 11/12] mini-os: get GIC addresses from FDT



Signed-off-by: Thomas Leonard <talex5@xxxxxxxxx>
---
 extras/mini-os/drivers/gic.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/extras/mini-os/drivers/gic.c b/extras/mini-os/drivers/gic.c
index 3141830..8a9e427 100644
--- a/extras/mini-os/drivers/gic.c
+++ b/extras/mini-os/drivers/gic.c
@@ -2,6 +2,7 @@
 
 #include <mini-os/os.h>
 #include <mini-os/hypervisor.h>
+#include <libfdt.h>
 
 //#define VGIC_DEBUG
 #ifdef VGIC_DEBUG
@@ -168,9 +169,38 @@ static void gic_handler(void) {
 }
 
 void gic_init(void) {
-    // FIXME Get from dt!
-    gic.gicd_base = (char *)0x2c001000ULL;
-    gic.gicc_base = (char *)0x2c002000ULL;
+    gic.gicd_base = NULL;
+    int node = 0;
+    int depth = 0;
+    for (;;)
+    {
+        node = fdt_next_node(device_tree, node, &depth);
+        if (node <= 0 || depth < 0)
+            break;
+
+        /*
+           int name_len = 0;
+           const char *name = fdt_get_name(device_tree, node, &name_len);
+           printk("Found node: %d (%.*s)\n", node, name_len, name);
+         */
+
+        if (fdt_getprop(device_tree, node, "interrupt-controller", NULL)) {
+            int len = 0;
+            const uint64_t *reg = fdt_getprop(device_tree, node, "reg", &len);
+            if (reg == NULL || len != 32) {
+                printk("Bad 'reg' property: %p %d\n", reg, len);
+                continue;
+            }
+            gic.gicd_base = (char *) (long) fdt64_to_cpu(reg[0]);
+            gic.gicc_base = (char *) (long) fdt64_to_cpu(reg[2]);
+            printk("Found GIC: gicd_base = %p, gicc_base = %p\n", 
gic.gicd_base, gic.gicc_base);
+            break;
+        }
+    }
+    if (!gic.gicd_base) {
+        printk("GIC not found!\n");
+        BUG();
+    }
     wmb();
 
     IRQ_handler = gic_handler;
-- 
2.0.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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