From owner-svn-src-all@freebsd.org Sun Jan 28 01:22:16 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91A09ED0852; Sun, 28 Jan 2018 01:22:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4786584309; Sun, 28 Jan 2018 01:22:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 42925129B9; Sun, 28 Jan 2018 01:22:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0S1MGoV051045; Sun, 28 Jan 2018 01:22:16 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0S1MFHb051040; Sun, 28 Jan 2018 01:22:15 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801280122.w0S1MFHb051040@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 28 Jan 2018 01:22:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328504 - in head/stand: efi/fdt fdt uboot/fdt X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head/stand: efi/fdt fdt uboot/fdt X-SVN-Commit-Revision: 328504 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jan 2018 01:22:16 -0000 Author: kevans Date: Sun Jan 28 01:22:15 2018 New Revision: 328504 URL: https://svnweb.freebsd.org/changeset/base/328504 Log: stand/fdt: Consolidate overlay handling a little further This should have been done as part of r327350, but due to lack of foresight it came later. In the different places we apply overlays, we duplicate the bits that check for fdt_overlays in the environment and supplement that with any other places we need to check for overlays to load. These "other places" will be loader specific and are not candidates for consolidation. Provide an fdt_load_dtb_overlays to capture the common logic, allow passing in an additional list of overlays to be loaded. This additional list of overlays is used in practice for ubldr to pull in any fdt_overlays passed to it from U-Boot environment, but it can be used for any other source of overlays. These additional overlays supplement loader.conf(5) fdt_overlays, rather than replace, so that we're not restricted to specifying overlays in only one place. This is a change from previous behavior where loader.conf(5) supplied fdt_overlays would cause us to ignore U-Boot environment, and this seems nonsensical- user should have sufficient control over both of these aspects, or lack of control for good reasons. A knob could be considered in the future to ignore U-Boot supplied overlays, but the supplemental treatment seems like a good start. Reviewed by: imp (earlier version), gonzo (earlier version) Differential Revision: https://reviews.freebsd.org/D13993 Modified: head/stand/efi/fdt/efi_fdt.c head/stand/fdt/fdt_loader_cmd.c head/stand/fdt/fdt_platform.h head/stand/uboot/fdt/uboot_fdt.c Modified: head/stand/efi/fdt/efi_fdt.c ============================================================================== --- head/stand/efi/fdt/efi_fdt.c Sun Jan 28 00:27:51 2018 (r328503) +++ head/stand/efi/fdt/efi_fdt.c Sun Jan 28 01:22:15 2018 (r328504) @@ -53,12 +53,7 @@ fdt_platform_load_dtb(void) return (1); printf("Using DTB provided by EFI at %p.\n", hdr); - s = getenv("fdt_overlays"); - if (s != NULL && *s != '\0') { - printf("Loading DTB overlays: '%s'\n", s); - fdt_load_dtb_overlays(s); - } - + fdt_load_dtb_overlays(NULL); return (0); } Modified: head/stand/fdt/fdt_loader_cmd.c ============================================================================== --- head/stand/fdt/fdt_loader_cmd.c Sun Jan 28 00:27:51 2018 (r328503) +++ head/stand/fdt/fdt_loader_cmd.c Sun Jan 28 01:22:15 2018 (r328504) @@ -76,6 +76,7 @@ static int fdt_load_dtb(vm_offset_t va); static void fdt_print_overlay_load_error(int err, const char *filename); static int fdt_cmd_nyi(int argc, char *argv[]); +static int fdt_load_dtb_overlays_string(const char * filenames); static int fdt_cmd_addr(int argc, char *argv[]); static int fdt_cmd_mkprop(int argc, char *argv[]); @@ -331,15 +332,15 @@ fdt_print_overlay_load_error(int err, const char *file } } -int -fdt_load_dtb_overlays(const char * filenames) +static int +fdt_load_dtb_overlays_string(const char * filenames) { char *names; char *name, *name_ext; char *comaptr; int err, namesz; - debugf("fdt_load_dtb_overlay(%s)\n", filenames); + debugf("fdt_load_dtb_overlays_string(%s)\n", filenames); names = strdup(filenames); if (names == NULL) @@ -829,6 +830,25 @@ fdt_fixup_stdout(const char *str) strlen((char *)&tmp) + 1); fdt_setprop(fdtp, no, "stdin", &tmp, strlen((char *)&tmp) + 1); + } +} + +void +fdt_load_dtb_overlays(const char *extras) +{ + const char *s; + + /* Any extra overlays supplied by pre-loader environment */ + if (extras != NULL && *extras != '\0') { + printf("Loading DTB overlays: '%s'\n", extras); + fdt_load_dtb_overlays_string(extras); + } + + /* Any overlays supplied by loader environment */ + s = getenv("fdt_overlays"); + if (s != NULL && *s != '\0') { + printf("Loading DTB overlays: '%s'\n", s); + fdt_load_dtb_overlays_string(s); } } Modified: head/stand/fdt/fdt_platform.h ============================================================================== --- head/stand/fdt/fdt_platform.h Sun Jan 28 00:27:51 2018 (r328503) +++ head/stand/fdt/fdt_platform.h Sun Jan 28 01:22:15 2018 (r328504) @@ -46,7 +46,7 @@ void fdt_fixup_stdout(const char *); void fdt_apply_overlays(void); int fdt_load_dtb_addr(struct fdt_header *); int fdt_load_dtb_file(const char *); -int fdt_load_dtb_overlays(const char *); +void fdt_load_dtb_overlays(const char *); int fdt_setup_fdtp(void); /* The platform library needs to implement these functions */ Modified: head/stand/uboot/fdt/uboot_fdt.c ============================================================================== --- head/stand/uboot/fdt/uboot_fdt.c Sun Jan 28 00:27:51 2018 (r328503) +++ head/stand/uboot/fdt/uboot_fdt.c Sun Jan 28 01:22:15 2018 (r328504) @@ -89,16 +89,8 @@ fdt_platform_load_dtb(void) } exit: - if (rv == 0) { - s = getenv("fdt_overlays"); - if (s == NULL) - s = ub_env_get("fdt_overlays"); - if (s != NULL && *s != '\0') { - printf("Loading DTB overlays: '%s'\n", s); - fdt_load_dtb_overlays(s); - } - } - + if (rv == 0) + fdt_load_dtb_overlays(ub_env_get("fdt_overlays")); return (rv); }