diff options
author | ian <ian@FreeBSD.org> | 2014-04-29 00:36:51 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-04-29 00:36:51 +0000 |
commit | 0eaada9b3bb473513e2f89f24b948075c2385269 (patch) | |
tree | be0ec586551caa57c1fb3ef0e1447f4be837f2f8 /sys/boot | |
parent | 56bd016e78c171de47b7f9450975ea51cf694d43 (diff) | |
download | FreeBSD-src-0eaada9b3bb473513e2f89f24b948075c2385269.zip FreeBSD-src-0eaada9b3bb473513e2f89f24b948075c2385269.tar.gz |
MFC r262664, r262694:
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.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/fdt/fdt_loader_cmd.c | 2 | ||||
-rw-r--r-- | sys/boot/uboot/common/metadata.c | 2 | ||||
-rw-r--r-- | sys/boot/uboot/lib/Makefile | 12 | ||||
-rw-r--r-- | sys/boot/uboot/lib/libuboot.h | 6 | ||||
-rw-r--r-- | sys/boot/uboot/lib/module.c | 10 |
5 files changed, 27 insertions, 5 deletions
diff --git a/sys/boot/fdt/fdt_loader_cmd.c b/sys/boot/fdt/fdt_loader_cmd.c index 1d74d62..b54a6b4 100644 --- a/sys/boot/fdt/fdt_loader_cmd.c +++ b/sys/boot/fdt/fdt_loader_cmd.c @@ -279,7 +279,7 @@ fdt_load_dtb_file(const char * filename) return (0); } -static int +int fdt_setup_fdtp() { struct preloaded_file *bfp; diff --git a/sys/boot/uboot/common/metadata.c b/sys/boot/uboot/common/metadata.c index bbc1893..65ba003 100644 --- a/sys/boot/uboot/common/metadata.c +++ b/sys/boot/uboot/common/metadata.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include "glue.h" #if defined(LOADER_FDT_SUPPORT) -extern int fdt_copy(vm_offset_t); +#include "libuboot.h" #endif /* diff --git a/sys/boot/uboot/lib/Makefile b/sys/boot/uboot/lib/Makefile index 7908f24..e5ed3ce 100644 --- a/sys/boot/uboot/lib/Makefile +++ b/sys/boot/uboot/lib/Makefile @@ -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/ diff --git a/sys/boot/uboot/lib/libuboot.h b/sys/boot/uboot/lib/libuboot.h index 1f63bee..bf07ad3 100644 --- a/sys/boot/uboot/lib/libuboot.h +++ b/sys/boot/uboot/lib/libuboot.h @@ -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 + diff --git a/sys/boot/uboot/lib/module.c b/sys/boot/uboot/lib/module.c index f03d644..d9b3dc0 100644 --- a/sys/boot/uboot/lib/module.c +++ b/sys/boot/uboot/lib/module.c @@ -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); } |