[PATCH] Dump flat device tree before scanning

Michael Ellerman michael at ellerman.id.au
Tue Aug 16 18:13:56 EST 2005


Hi,

This patch is just for people debugging flat device tree code. It dumps the 
content of the device tree before scanning it, giving you a chance to look 
over things before it all blows up.

I also have a python script that will turn this into something dtc can read, 
if anyone wants it.

You need some sort of early debugging enabled to see anything BTW. See setup.c

cheers

# Bazaar-NG changeset v0.0.5
# 
# committer: Michael Ellerman <michael at concordia>
# date: Tue 2005-08-16 17:54:46.513325930 +1000
# message:
#    Add dumping of flat DT in prom.c
# 

--- orig/arch/ppc64/kernel/prom.c 
+++ mod/arch/ppc64/kernel/prom.c 
@@ -1218,6 +1218,31 @@
 #endif
 }
 
+#ifdef DEBUG
+static void dump_flat_dt(char *p)
+{
+	struct boot_param_header *hdr = (struct boot_param_header*)p;
+	unsigned char buf[64];
+	int i, j;
+
+	DBG("Dumping flat dt ...\n");
+
+	for (i = j = 0; i < hdr->totalsize; i += 2) {
+		if (i % 4 == 0)
+			j += snprintf(buf + j, sizeof(buf) - j, " ");
+
+		if (i % 16 == 0) {
+			DBG("%s\n", buf);
+			j = 0;
+		}
+
+		j += snprintf(buf + j, sizeof(buf) - j,
+				"%.2x%.2x ", p[i], p[i + 1]);
+	}
+	DBG("%s\n", buf);
+}
+#endif
+
 void __init early_init_devtree(void *params)
 {
 	DBG(" -> early_init_devtree()\n");
@@ -1227,6 +1252,10 @@
 
 	/* By default, hash size is not set */
 	ppc64_pft_size = 0;
+
+#ifdef DEBUG
+	dump_flat_dt((char *)params);
+#endif
 
 	/* Retreive various informations from the /chosen node of the
 	 * device-tree, including the platform type, initrd location and
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050816/8fc61768/attachment.pgp 


More information about the Linuxppc64-dev mailing list