Skip to contentSkip to conversation

powerpc: Export flat device tree via debugfs for debugging

PATCH In review Michael Ellerman 2 participants 4 messages May 1, 2006 – May 2, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Export flat device tree via debugfs for debugging

If DEBUG is turned on in prom.c, export the flat device tree via debugfs. This has been handy on several occasions.

To look at it:

 # mount -t debugfs none /sys/kernel/debug
 # od -a /sys/kernel/debug/powerpc/flat-device-tree
 and/or
 # dtc -fI dtb /sys/kernel/debug/powerpc/flat-device-tree -O dts

---

 arch/powerpc/kernel/prom.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/powerpc/kernel/prom.c +25 -0
Index: to-merge/arch/powerpc/kernel/prom.c
===================================================================
@@ -30,6 +30,7 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/kexec.h>
+#include <linux/debugfs.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>
@@ -2009,3 +2010,27 @@ void kdump_move_device_tree(void)
 	/* XXX should we unreserve the old DT? */
 }
 #endif /* CONFIG_KEXEC */
+
+#ifdef DEBUG
+static struct debugfs_blob_wrapper flat_dt_blob;
+
+static int __init export_flat_device_tree(void)
+{
+	struct dentry *d;
+
+	d = debugfs_create_dir("powerpc", NULL);
+	if (!d)
+		return 1;
+
+	flat_dt_blob.data = initial_boot_params;
+	flat_dt_blob.size = initial_boot_params->totalsize;
+
+	d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
+				d, &flat_dt_blob);
+	if (!d)
+		return 1;
+
+	return 0;
+}
+__initcall(export_flat_device_tree);
+#endif
#1 lore raw
Quoted 28 lines · Michael Ellerman

If DEBUG is turned on in prom.c, export the flat device tree via debugfs. This has been handy on several occasions.

To look at it:

 # mount -t debugfs none /sys/kernel/debug
 # od -a /sys/kernel/debug/powerpc/flat-device-tree
 and/or
 # dtc -fI dtb /sys/kernel/debug/powerpc/flat-device-tree -O dts

---

 arch/powerpc/kernel/prom.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Index: to-merge/arch/powerpc/kernel/prom.c
===================================================================

arch/powerpc/kernel/prom.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/kexec.h>
+#include <linux/debugfs.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>

arch/powerpc/kernel/prom.c void kdump_move_device_tree(void) · line 2014

Quoted 5 lines
arch/powerpc/kernel/prom.c +2 -0
@@ -2009,3 +2010,27 @@ void kdump_move_device_tree(void)
 	/* XXX should we unreserve the old DT? */
 }
 #endif /* CONFIG_KEXEC */
+
+#ifdef DEBUG

Shouldn't this also depend on DEBUGFS being built in.

Quoted 26 lines
arch/powerpc/kernel/prom.c +22 -0
+static struct debugfs_blob_wrapper flat_dt_blob;
+
+static int __init export_flat_device_tree(void)
+{
+	struct dentry *d;
+
+	d = debugfs_create_dir("powerpc", NULL);
+	if (!d)
+		return 1;
+
+	flat_dt_blob.data = initial_boot_params;
+	flat_dt_blob.size = initial_boot_params->totalsize;
+
+	d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
+				d, &flat_dt_blob);
+	if (!d)
+		return 1;
+
+	return 0;
+}
+__initcall(export_flat_device_tree);
+#endif

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#2 lore raw
Quoted 28 lines · Kumar Gala
Quoted 26 lines · Michael Ellerman

If DEBUG is turned on in prom.c, export the flat device tree via debugfs.
This has been handy on several occasions.

To look at it:

 # mount -t debugfs none /sys/kernel/debug
 # od -a /sys/kernel/debug/powerpc/flat-device-tree
 and/or
 # dtc -fI dtb /sys/kernel/debug/powerpc/flat-device-tree -O dts

---

 arch/powerpc/kernel/prom.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Index: to-merge/arch/powerpc/kernel/prom.c
===================================================================

arch/powerpc/kernel/prom.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/kexec.h>
+#include <linux/debugfs.h>
 
Quoted 10 lines

arch/powerpc/kernel/prom.c void kdump_move_device_tree(void) · line 2014

Quoted 8 lines
arch/powerpc/kernel/prom.c +2 -0
 #include <asm/prom.h>
 #include <asm/rtas.h>
@@ -2009,3 +2010,27 @@ void kdump_move_device_tree(void)
 	/* XXX should we unreserve the old DT? */
 }
 #endif /* CONFIG_KEXEC */
+
+#ifdef DEBUG

Shouldn't this also depend on DEBUGFS being built in.

It could, but DEBUG_FS is written so that you don't have to care, so I didn't :)

cheers

Signature · 8 lines
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#3 lore raw
Quoted 40 lines · Michael Ellerman
Quoted 28 lines · Kumar Gala
Quoted 26 lines · Michael Ellerman

If DEBUG is turned on in prom.c, export the flat device tree via debugfs.
This has been handy on several occasions.

To look at it:

 # mount -t debugfs none /sys/kernel/debug
 # od -a /sys/kernel/debug/powerpc/flat-device-tree
 and/or
 # dtc -fI dtb /sys/kernel/debug/powerpc/flat-device-tree -O dts

---

 arch/powerpc/kernel/prom.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Index: to-merge/arch/powerpc/kernel/prom.c
===================================================================

arch/powerpc/kernel/prom.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/kexec.h>
+#include <linux/debugfs.h>
 
Quoted 10 lines

arch/powerpc/kernel/prom.c void kdump_move_device_tree(void) · line 2014

Quoted 8 lines
arch/powerpc/kernel/prom.c +2 -0
 #include <asm/prom.h>
 #include <asm/rtas.h>
@@ -2009,3 +2010,27 @@ void kdump_move_device_tree(void)
 	/* XXX should we unreserve the old DT? */
 }
 #endif /* CONFIG_KEXEC */
+
+#ifdef DEBUG

Shouldn't this also depend on DEBUGFS being built in.

Quoted 2 lines

It could, but DEBUG_FS is written so that you don't have to care, so I didn't :)

Cool. Haven't messed with DEBUG_FS.

- k