svn commit: r247045 - head/sys/boot/fdt

Tim Kientzle kientzle at FreeBSD.org
Wed Feb 20 16:32:39 UTC 2013


Author: kientzle
Date: Wed Feb 20 16:32:38 2013
New Revision: 247045
URL: http://svnweb.freebsd.org/changeset/base/247045

Log:
  Fix "fdt addr" to accept literal addresses rather than va offsets.
  When initializing the fdt, query U-Boot as well.
  
  With this change, it is now feasible to have U-Boot load
  the FDT, ubldr will pull it from U-Boot and hand it to the
  kernel.

Modified:
  head/sys/boot/fdt/fdt_loader_cmd.c

Modified: head/sys/boot/fdt/fdt_loader_cmd.c
==============================================================================
--- head/sys/boot/fdt/fdt_loader_cmd.c	Wed Feb 20 15:44:40 2013	(r247044)
+++ head/sys/boot/fdt/fdt_loader_cmd.c	Wed Feb 20 16:32:38 2013	(r247045)
@@ -235,26 +235,47 @@ fdt_load_dtb(vm_offset_t va)
 }
 
 static int
-fdt_setup_fdtp()
+fdt_load_dtb_addr(struct fdt_header *header)
 {
 	struct preloaded_file *bfp;
-	vm_offset_t va;
 
-	bfp = file_findfile(NULL, "dtb");
+	bfp = mem_load_raw("dtb", "memory.dtb", header, fdt_totalsize(header));
 	if (bfp == NULL) {
-		if ((va = fdt_find_static_dtb()) == 0) {
-			command_errmsg = "no device tree blob found!";
-			return (1);
-		}
-	} else {
-		/* Dynamic blob has precedence over static. */
-		va = bfp->f_addr;
+		command_errmsg = "unable to copy DTB into module directory";
+		return (1);
 	}
+	return fdt_load_dtb(bfp->f_addr);
+}
 
-	if (fdt_load_dtb(va) != 0)
-		return (1);
-	
-	return (0);
+static int
+fdt_setup_fdtp()
+{
+  struct preloaded_file *bfp;
+  struct fdt_header *hdr;
+  const char *s, *p;
+  vm_offset_t va;
+
+  if ((bfp = file_findfile(NULL, "dtb")) != NULL) {
+	  printf("Using DTB from loaded file.\n");
+	  return fdt_load_dtb(bfp->f_addr);
+  } 
+
+  s = ub_env_get("fdtaddr");
+  if (s != NULL && *s != '\0') {
+	  hdr = (struct fdt_header *)strtoul(s, &p, 16);
+	  if (*p == '\0') {
+		  printf("Using DTB provided by U-Boot.\n");
+		  return fdt_load_dtb_addr(hdr);
+	  }
+  }
+
+  if ((va = fdt_find_static_dtb()) != 0) {
+	  printf("Using DTB compiled into kernel.\n");
+	  return (fdt_load_dtb(va));
+  }
+
+  command_errmsg = "no device tree blob found!";
+  return (1);
 }
 
 #define fdt_strtovect(str, cellbuf, lim, cellsize) _fdt_strtovect((str), \
@@ -789,8 +810,8 @@ command_fdt_internal(int argc, char *arg
 static int
 fdt_cmd_addr(int argc, char *argv[])
 {
-	vm_offset_t va;
-	char *addr, *cp;
+	struct fdt_header *hdr;
+	const char *addr, *cp;
 
 	if (argc > 2)
 		addr = argv[2];
@@ -799,13 +820,13 @@ fdt_cmd_addr(int argc, char *argv[])
 		return (CMD_ERROR);
 	}
 
-	va = strtol(addr, &cp, 0);
+	hdr = (struct fdt_header *)strtoul(addr, &cp, 0);
 	if (cp == addr) {
 		sprintf(command_errbuf, "Invalid address: %s", addr);
 		return (CMD_ERROR);
 	}
 
-	if (fdt_load_dtb(va) != 0)
+	if (fdt_load_dtb_addr(hdr) != 0)
 		return (CMD_ERROR);
 
 	return (CMD_OK);
@@ -1484,6 +1505,7 @@ fdt_cmd_mkprop(int argc, char *argv[])
 	if (fdt_modprop(o, propname, value, 1))
 		return (CMD_ERROR);
 
+	COPYIN(fdtp, fdtp_va, fdtp_size);
 	return (CMD_OK);
 }
 


More information about the svn-src-head mailing list