svn commit: r262664 - in head/sys/boot: fdt uboot/common uboot/lib

Ian Lepore ian at FreeBSD.org
Sat Mar 1 19:02:02 UTC 2014


Author: ian
Date: Sat Mar  1 19:02:00 2014
New Revision: 262664
URL: http://svnweb.freebsd.org/changeset/base/262664

Log:
  Prevent fdt data loaded from a file from overwriting the kernel environment,
  by having uboot_autoload() do the fdt setup (which may load a file) rather
  than waiting until we're actually in the process of launching the kernel.
  
  As part of making this happen...
   - Define LOADER_FDT_SUPPORT on the uboot/lib compile command line when
     MK_FDT is set.
   - Make fdt_setup_fdtb() public.
   - Declare public fdt_whatever() functions in a header instead of using
     scattered extern decls in .c files.

Modified:
  head/sys/boot/fdt/fdt_loader_cmd.c
  head/sys/boot/uboot/common/metadata.c
  head/sys/boot/uboot/lib/Makefile
  head/sys/boot/uboot/lib/libuboot.h
  head/sys/boot/uboot/lib/module.c

Modified: head/sys/boot/fdt/fdt_loader_cmd.c
==============================================================================
--- head/sys/boot/fdt/fdt_loader_cmd.c	Sat Mar  1 18:56:50 2014	(r262663)
+++ head/sys/boot/fdt/fdt_loader_cmd.c	Sat Mar  1 19:02:00 2014	(r262664)
@@ -279,7 +279,7 @@ fdt_load_dtb_file(const char * filename)
 	return (0);
 }
 
-static int
+int
 fdt_setup_fdtp()
 {
 	struct preloaded_file *bfp;

Modified: head/sys/boot/uboot/common/metadata.c
==============================================================================
--- head/sys/boot/uboot/common/metadata.c	Sat Mar  1 18:56:50 2014	(r262663)
+++ head/sys/boot/uboot/common/metadata.c	Sat Mar  1 19:02:00 2014	(r262664)
@@ -41,10 +41,6 @@ __FBSDID("$FreeBSD$");
 #include "bootstrap.h"
 #include "glue.h"
 
-#if defined(LOADER_FDT_SUPPORT)
-extern int fdt_copy(vm_offset_t);
-#endif
-
 /*
  * Return a 'boothowto' value corresponding to the kernel arguments in
  * (kargs) and any relevant environment variables.

Modified: head/sys/boot/uboot/lib/Makefile
==============================================================================
--- head/sys/boot/uboot/lib/Makefile	Sat Mar  1 18:56:50 2014	(r262663)
+++ head/sys/boot/uboot/lib/Makefile	Sat Mar  1 19:02:00 2014	(r262664)
@@ -1,5 +1,7 @@
 # $FreeBSD$
 
+.include <bsd.own.mk>
+
 .PATH: ${.CURDIR}/../../common
 
 LIB=		uboot
@@ -18,6 +20,16 @@ SRCS+=	disk.c
 CFLAGS+= -DLOADER_DISK_SUPPORT
 .endif
 
+.if ${MK_FDT} != "no"
+LOADER_FDT_SUPPORT=	yes
+.else
+LOADER_FDT_SUPPORT=	no
+.endif
+
+.if ${LOADER_FDT_SUPPORT} == "yes"
+CFLAGS+= -DLOADER_FDT_SUPPORT
+.endif
+
 # Pick up FDT includes
 CFLAGS+=	-I${.CURDIR}/../../../../sys/contrib/libfdt/
 

Modified: head/sys/boot/uboot/lib/libuboot.h
==============================================================================
--- head/sys/boot/uboot/lib/libuboot.h	Sat Mar  1 18:56:50 2014	(r262663)
+++ head/sys/boot/uboot/lib/libuboot.h	Sat Mar  1 19:02:00 2014	(r262664)
@@ -69,3 +69,9 @@ struct file_format;
 extern struct file_format uboot_elf;
 
 void reboot(void);
+
+#if defined(LOADER_FDT_SUPPORT)
+extern int fdt_setup_fdtp();
+extern int fdt_copy(vm_offset_t);
+#endif
+

Modified: head/sys/boot/uboot/lib/module.c
==============================================================================
--- head/sys/boot/uboot/lib/module.c	Sat Mar  1 18:56:50 2014	(r262663)
+++ head/sys/boot/uboot/lib/module.c	Sat Mar  1 19:02:00 2014	(r262664)
@@ -29,19 +29,23 @@ __FBSDID("$FreeBSD$");
 
 /*
  * U-Boot-specific module functionality.
- *
- * XXX not much for now...
- *
  */
 
 #include <stand.h>
 #include <string.h>
 
 #include "bootstrap.h"
+#include "libuboot.h"
 
 int
 uboot_autoload(void)
 {
+#if defined(LOADER_FDT_SUPPORT)
+	int err;
+
+	if ((err = fdt_setup_fdtp()) != 0)
+		return (err);
+#endif
 
 	return(0);
 }


More information about the svn-src-all mailing list