summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkevans <kevans@FreeBSD.org>2018-02-02 21:25:32 +0000
committerkevans <kevans@FreeBSD.org>2018-02-02 21:25:32 +0000
commite1157f670d8d555bd9838f6f343deda54fe51583 (patch)
tree9bd286057d5c84e73dd9264604a0a0752cc2ce7b
parentf205d4efbec3c0d8f5cd5edbc11db6c713a58ca6 (diff)
downloadFreeBSD-src-e1157f670d8d555bd9838f6f343deda54fe51583.zip
FreeBSD-src-e1157f670d8d555bd9838f6f343deda54fe51583.tar.gz
MFC r328504: stand/fdt: Consolidate overlay handling a little further
[This is effectively a direct commit to stable/11 due to path restructuring in HEAD. The diff against HEAD has simply been applied to the old path] 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.
-rw-r--r--sys/boot/efi/fdt/efi_fdt.c7
-rw-r--r--sys/boot/fdt/fdt_loader_cmd.c26
-rw-r--r--sys/boot/fdt/fdt_platform.h2
-rw-r--r--sys/boot/uboot/fdt/uboot_fdt.c12
4 files changed, 27 insertions, 20 deletions
diff --git a/sys/boot/efi/fdt/efi_fdt.c b/sys/boot/efi/fdt/efi_fdt.c
index 5fcb6ad..42d70a2 100644
--- a/sys/boot/efi/fdt/efi_fdt.c
+++ b/sys/boot/efi/fdt/efi_fdt.c
@@ -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);
}
diff --git a/sys/boot/fdt/fdt_loader_cmd.c b/sys/boot/fdt/fdt_loader_cmd.c
index 9366b74..710b6cb 100644
--- a/sys/boot/fdt/fdt_loader_cmd.c
+++ b/sys/boot/fdt/fdt_loader_cmd.c
@@ -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[]);
@@ -330,15 +331,15 @@ fdt_print_overlay_load_error(int err, const char *filename)
}
}
-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)
@@ -827,6 +828,25 @@ fdt_fixup_stdout(const char *str)
}
}
+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);
+ }
+}
+
/*
* Locate the blob, fix it up and return its location.
*/
diff --git a/sys/boot/fdt/fdt_platform.h b/sys/boot/fdt/fdt_platform.h
index eae940a..8930340 100644
--- a/sys/boot/fdt/fdt_platform.h
+++ b/sys/boot/fdt/fdt_platform.h
@@ -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 */
diff --git a/sys/boot/uboot/fdt/uboot_fdt.c b/sys/boot/uboot/fdt/uboot_fdt.c
index 5d7581d..aed7885 100644
--- a/sys/boot/uboot/fdt/uboot_fdt.c
+++ b/sys/boot/uboot/fdt/uboot_fdt.c
@@ -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);
}
OpenPOWER on IntegriCloud