From owner-svn-src-head@FreeBSD.ORG Sat Mar 1 19:02:02 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 36BE4350; Sat, 1 Mar 2014 19:02:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 229EE1526; Sat, 1 Mar 2014 19:02:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s21J22tX019352; Sat, 1 Mar 2014 19:02:02 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s21J21Ki019345; Sat, 1 Mar 2014 19:02:01 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201403011902.s21J21Ki019345@svn.freebsd.org> From: Ian Lepore Date: Sat, 1 Mar 2014 19:02:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262664 - in head/sys/boot: fdt uboot/common uboot/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Mar 2014 19:02:02 -0000 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 + .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 #include #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); }