PERFORCE change 173045 for review

Rafal Jaworowski raj at FreeBSD.org
Tue Jan 12 22:14:01 UTC 2010


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

Change 173045 by raj at raj_fdt on 2010/01/12 22:13:55

	loader(8) cleanups.
	
	- Prevent endianess when modifying DT property.
	- Supply '/chosen/stdin' property if not present (this will be
	  required by the reworked uart console FDT attachment).
	- Assorted minor typos and cosmetic fixes.

Affected files ...

.. //depot/projects/fdt/sys/boot/uboot/common/main.c#3 edit
.. //depot/projects/fdt/sys/boot/uboot/lib/fdt.c#3 edit

Differences ...

==== //depot/projects/fdt/sys/boot/uboot/common/main.c#3 (text+ko) ====

@@ -53,6 +53,8 @@
 extern unsigned char __sbss_end[];
 extern unsigned char _end[];
 
+extern int command_fdt_internal(int argc, char *argv[]);
+
 static void
 dump_sig(struct api_signature *sig)
 {
@@ -259,4 +261,17 @@
 	return (CMD_OK);
 }
 
+/*
+ * Since proper fdt command handling function is defined in fdt.c, and
+ * declaring it as extern is in contradiction with COMMAND_SET() macro
+ * (which uses static pointer), we're defining wrapper function, which
+ * calls the proper fdt handling routine.
+ */
+static int
+command_fdt(int argc, char *argv[])
+{
+
+	return (command_fdt_internal(argc, argv));
+}
+
 COMMAND_SET(fdt, "fdt", "flattened device tree handling", command_fdt);

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

@@ -100,7 +100,7 @@
 	int err;
 
 	/*
-	 * Find the device tree blob
+	 * Find the device tree blob.
 	 */
 	bfp = file_findfile(NULL, "dtb");
 	if (bfp == NULL) {
@@ -110,7 +110,7 @@
 	fdtp = (struct fdt_header *)bfp->f_addr;
 
 	/*
-	 * Validate the blob
+	 * Validate the blob.
 	 */
 	err = fdt_check_header(fdtp);
 	if (err < 0) {
@@ -127,7 +127,6 @@
 	return (CMD_OK);
 }
 
-
 #define fdt_strtovect(str, cellbuf, lim, cellsize) _fdt_strtovect((str), \
     (cellbuf), (lim), (cellsize), 0);
 
@@ -160,7 +159,8 @@
 			buf++;
 
 		if (u32buf != NULL)
-			u32buf[cnt] = (uint32_t)strtol(buf, NULL, base);
+			u32buf[cnt] =
+			    cpu_to_fdt32((uint32_t)strtol(buf, NULL, base));
 
 		else
 			u8buf[cnt] = (uint8_t)strtol(buf, NULL, base);
@@ -260,7 +260,6 @@
 
 		lo = MIN(o, o2);
 	}
-
 }
 
 void
@@ -331,13 +330,14 @@
 void
 fixup_stdout(const char *env)
 {
-	const char *str = ub_env_get(env);
+	const char *str;
 	char *ptr;
 	int serialno;
 	int len, no, sero;
 	const struct fdt_property *prop;
 	char *tmp[10];
 
+	str = ub_env_get(env);
 	ptr = (char *)str + strlen(str) - 1;
 	while (ptr > str && isdigit(*(str - 1)))
 		str--;
@@ -351,6 +351,8 @@
 		return;
 
 	prop = fdt_get_property(fdtp, no, "stdout", &len);
+
+	/* If /chosen/stdout does not extist, create it */
 	if (prop == NULL || (prop != NULL && len == 0)) {
 
 		bzero(tmp, 10 * sizeof(char));
@@ -370,6 +372,8 @@
 
 		fdt_setprop(fdtp, no, "stdout", &tmp,
 		    strlen((char *)&tmp) + 1);
+		fdt_setprop(fdtp, no, "stdin", &tmp,
+		    strlen((char *)&tmp) + 1);
 	}
 }
 
@@ -446,7 +450,7 @@
 }
 
 int
-command_fdt(int argc, char *argv[])
+command_fdt_internal(int argc, char *argv[])
 {
 	cmdf_t *cmdh;
 	char *cmd;
@@ -458,7 +462,7 @@
 	}
 
 	/*
-	 * Validate fdt <command>
+	 * Validate fdt <command>.
 	 */
 	cmd = strdup(argv[1]);
 	i = 0;
@@ -486,7 +490,7 @@
 		fdt_fixup();
 
 	/*
-	 * Call command handler
+	 * Call command handler.
 	 */
 	err = (*cmdh)(argc, argv);
 
@@ -1045,8 +1049,7 @@
 		rv = fdt_modprop(o, propname, value, 0);
 		if (rv)
 			return (CMD_ERROR);
-		else
-			return (CMD_OK);
+		return (CMD_OK);
 
 	}
 	/* User wants to display properties */


More information about the p4-projects mailing list