PERFORCE change 174255 for review

Rafal Jaworowski raj at FreeBSD.org
Wed Feb 3 20:05:28 UTC 2010


http://p4web.freebsd.org/chv.cgi?CH=174255

Change 174255 by raj at raj_fdt on 2010/02/03 20:04:33

	Improve FDT fixup handling in loader.
	
	Fixup were not applied previously upon DTB unload and consecutive
	loading. This is now fixed with a run-time created 'fixup-applied'
	prop in the /chosen node.

Affected files ...

.. //depot/projects/fdt/sys/boot/uboot/lib/fdt.c#4 edit

Differences ...

==== //depot/projects/fdt/sys/boot/uboot/lib/fdt.c#4 (text+ko) ====

@@ -91,7 +91,6 @@
 };
 
 static char cwd[FDT_CWD_LEN] = "/";
-static unsigned char fdt_fixup_applied = 0;
 
 static int
 fdt_setup_fdtp()
@@ -382,15 +381,12 @@
 {
 	const char *env;
 	char *ethstr;
-	int err, eth_no, len;
+	int chosen, err, eth_no, len;
 	struct sys_info *si;
 
 	env = NULL;
 	eth_no = 0;
 
-	if (fdt_fixup_applied)
-		return (CMD_OK);
-
 	if (!fdtp) {
 		err = fdt_setup_fdtp();
 		if (err) {
@@ -401,8 +397,13 @@
 	}
 
 	/* Create /chosen node (if not exists) */
-	if (fdt_subnode_offset(fdtp, 0, "chosen") == -FDT_ERR_NOTFOUND)
-		fdt_add_subnode(fdtp, 0, "chosen");
+	if ((chosen = fdt_subnode_offset(fdtp, 0, "chosen")) ==
+	    -FDT_ERR_NOTFOUND)
+		chosen = fdt_add_subnode(fdtp, 0, "chosen");
+
+	/* Value assigned to fixup-applied does not matter. */
+	if (fdt_getprop(fdtp, chosen, "fixup-applied", NULL))
+		return (CMD_OK);
 
 	/* Acquire sys_info */
 	si = ub_get_sys_info();
@@ -444,7 +445,7 @@
 	/* Fixup memory regions */
 	fixup_memory(si);
 
-	fdt_fixup_applied = 1;
+	fdt_setprop(fdtp, chosen, "fixup-applied", NULL, 0);
 
 	return (CMD_OK);
 }
@@ -462,6 +463,11 @@
 	}
 
 	/*
+	 * Check if uboot env vars were parsed already. If not, do it now.
+	 */
+	fdt_fixup();
+
+	/*
 	 * Validate fdt <command>.
 	 */
 	cmd = strdup(argv[1]);
@@ -483,11 +489,6 @@
 	if (!fdtp)
 		if (fdt_setup_fdtp())
 			return (CMD_ERROR);
-	/*
-	 * Check if uboot env vars were parsed already. If not, do it now.
-	 */
-	if (!fdt_fixup_applied)
-		fdt_fixup();
 
 	/*
 	 * Call command handler.


More information about the p4-projects mailing list