aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/device_tree.c
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@citrix.com>2012-03-22 14:26:46 +0000
committerDavid Vrabel <david.vrabel@citrix.com>2012-03-22 14:26:46 +0000
commite7df25ebdf8f302c440412c5eae3818a82dd5386 (patch)
tree6034c6881ee40adfc65d6a6f57d94ab7ec395987 /xen/common/device_tree.c
parent9cf4a9a467171c8a2c3d97c2bfadb1bc8b15a3d6 (diff)
downloadxen-e7df25ebdf8f302c440412c5eae3818a82dd5386.tar.gz
xen-e7df25ebdf8f302c440412c5eae3818a82dd5386.tar.bz2
xen-e7df25ebdf8f302c440412c5eae3818a82dd5386.zip
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@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'xen/common/device_tree.c')
-rw-r--r--xen/common/device_tree.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 8f5d8997da..d4b15569ff 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -103,6 +103,44 @@ int device_tree_for_each_node(const void *fdt,
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)