Index: stand/efi/fdt/efi_fdt.c =================================================================== --- stand/efi/fdt/efi_fdt.c +++ stand/efi/fdt/efi_fdt.c @@ -53,12 +53,7 @@ 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); } Index: stand/fdt/fdt_loader_cmd.c =================================================================== --- stand/fdt/fdt_loader_cmd.c +++ stand/fdt/fdt_loader_cmd.c @@ -73,6 +73,7 @@ static vm_offset_t fdtp_va = 0; static int fdt_load_dtb(vm_offset_t va); +static int fdt_load_dtb_overlays_string(const char * filenames); static int fdt_cmd_nyi(int argc, char *argv[]); @@ -310,14 +311,14 @@ return (0); } -int -fdt_load_dtb_overlays(const char * filenames) +static int +fdt_load_dtb_overlays_string(const char * filenames) { char *names; char *name; char *comaptr; - debugf("fdt_load_dtb_overlay(%s)\n", filenames); + debugf("fdt_load_dtb_overlays_string(%s)\n", filenames); names = strdup(filenames); if (names == NULL) @@ -794,6 +795,28 @@ } } +void +fdt_load_dtb_overlays(FDT_ADDITIONAL_OVERLAY_FUNC fdt_additional_overlays) +{ + const char *s; + + /* Any extra overlays supplied by pre-loader environment */ + if (fdt_additional_overlays != NULL) { + s = fdt_additional_overlays(); + if (s != NULL && *s != '\0') { + printf("Loading DTB overlays: '%s'\n", s); + fdt_load_dtb_overlays_string(s); + } + } + + /* 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. */ Index: stand/fdt/fdt_platform.h =================================================================== --- stand/fdt/fdt_platform.h +++ stand/fdt/fdt_platform.h @@ -38,6 +38,8 @@ #define TMP_MAX_ETH 8 +typedef const char *(*FDT_ADDITIONAL_OVERLAY_FUNC)(void); + int fdt_copy(vm_offset_t); void fdt_fixup_cpubusfreqs(unsigned long, unsigned long); void fdt_fixup_ethernet(const char *, char *, int); @@ -46,7 +48,7 @@ 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(FDT_ADDITIONAL_OVERLAY_FUNC); int fdt_setup_fdtp(void); /* The platform library needs to implement these functions */ Index: stand/uboot/fdt/uboot_fdt.c =================================================================== --- stand/uboot/fdt/uboot_fdt.c +++ stand/uboot/fdt/uboot_fdt.c @@ -39,6 +39,8 @@ #define STR(number) #number #define STRINGIFY(number) STR(number) +static const char *fdt_additional_overlays(void); + int fdt_platform_load_dtb(void) { @@ -89,15 +91,8 @@ } 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(fdt_additional_overlays); return (rv); } @@ -197,3 +192,10 @@ /* Fixup memory regions */ fdt_fixup_memory(regions, n); } + +static const char * +fdt_additional_overlays(void) +{ + + return (ub_env_get("fdt_overlays")); +}