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

[Xen-changelog] [xen-unstable] device tree: add device_tree_dump() to print a flat device tree



# HG changeset patch
# User David Vrabel <david.vrabel@xxxxxxxxxx>
# Date 1332426406 0
# Node ID eb2dc06f68e69f87d5e018349c3c239fcc59753f
# Parent  cb2e700ce5bb459ecc98c62e4f73ad9d35f4101a
device tree: add device_tree_dump() to print a flat device tree

Add a device_tree_dump() function which prints to main structure and
properties names of a flat device tree (but not the properties values
yet).

This will be useful for debugging problems with the device tree
generated for dom0.

Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r cb2e700ce5bb -r eb2dc06f68e6 xen/common/device_tree.c
--- a/xen/common/device_tree.c  Thu Mar 22 14:26:45 2012 +0000
+++ b/xen/common/device_tree.c  Thu Mar 22 14:26:46 2012 +0000
@@ -103,6 +103,44 @@
     return 0;
 }
 
+static int dump_node(const void *fdt, int node, const char *name, int depth,
+                     u32 address_cells, u32 size_cells, void *data)
+{
+    char prefix[2*MAX_DEPTH + 1] = "";
+    int i;
+    int prop;
+
+    for ( i = 0; i < depth; i++ )
+        safe_strcat(prefix, "  ");
+
+    if ( name[0] == '\0' )
+        name = "/";
+    printk("%s%s:\n", prefix, name);
+
+    for ( prop = fdt_first_property_offset(fdt, node);
+          prop >= 0;
+          prop = fdt_next_property_offset(fdt, prop) )
+    {
+        const struct fdt_property *p;
+
+        p = fdt_get_property_by_offset(fdt, prop, NULL);
+
+        printk("%s  %s\n", prefix, fdt_string(fdt, fdt32_to_cpu(p->nameoff)));
+    }
+
+    return 0;
+}
+
+/**
+ * device_tree_dump - print a text representation of a device tree
+ * @fdt: flat device tree to print
+ */
+void device_tree_dump(const void *fdt)
+{
+    device_tree_for_each_node(fdt, dump_node, NULL);
+}
+
+
 static void __init process_memory_node(const void *fdt, int node,
                                        const char *name,
                                        u32 address_cells, u32 size_cells)
diff -r cb2e700ce5bb -r eb2dc06f68e6 xen/include/xen/device_tree.h
--- a/xen/include/xen/device_tree.h     Thu Mar 22 14:26:45 2012 +0000
+++ b/xen/include/xen/device_tree.h     Thu Mar 22 14:26:46 2012 +0000
@@ -41,5 +41,6 @@
 
 int device_tree_for_each_node(const void *fdt,
                               device_tree_node_func func, void *data);
+void device_tree_dump(const void *fdt);
 
 #endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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