command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / common / image-fdt.c
index e70da3dcb33aaeb2bf72c3950b23949647751e18..1d2263de5d75ce64a405a06dabc84c3abc9fc09e 100644 (file)
 #include <common.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
+#include <env.h>
 #include <errno.h>
 #include <image.h>
+#include <lmb.h>
+#include <malloc.h>
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <tee/optee.h>
 
 #ifndef CONFIG_SYS_FDT_PAD
 #define CONFIG_SYS_FDT_PAD 0x3000
@@ -120,7 +124,7 @@ void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
                        /* check if this subnode has a reg property */
                        ret = fdt_get_resource(fdt_blob, subnode, "reg", 0,
                                               &res);
-                       if (!ret) {
+                       if (!ret && fdtdec_get_is_enabled(fdt_blob, subnode)) {
                                addr = res.start;
                                size = res.end - res.start + 1;
                                boot_fdt_reserve_region(lmb, addr, size);
@@ -260,8 +264,8 @@ error:
  *     1, if fdt image is found but corrupted
  *     of_flat_tree and of_size are set to 0 if no fdt exists
  */
-int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
-               bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
+int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
+                bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
        const image_header_t *fdt_hdr;
@@ -283,7 +287,8 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
        *of_flat_tree = NULL;
        *of_size = 0;
 
-       img_addr = (argc == 0) ? load_addr : simple_strtoul(argv[0], NULL, 16);
+       img_addr = (argc == 0) ? image_load_addr :
+                       simple_strtoul(argv[0], NULL, 16);
        buf = map_sysmem(img_addr, 0);
 
        if (argc > 2)
@@ -302,7 +307,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                        else if (images->fit_uname_os)
                                default_addr = (ulong)images->fit_hdr_os;
                        else
-                               default_addr = load_addr;
+                               default_addr = image_load_addr;
 
                        if (fit_parse_conf(select, default_addr,
                                           &fdt_addr, &fit_uname_config)) {
@@ -560,6 +565,13 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
                }
        }
 
+       fdt_ret = optee_copy_fdt_nodes(gd->fdt_blob, blob);
+       if (fdt_ret) {
+               printf("ERROR: transfer of optee nodes to new fdt failed: %s\n",
+                      fdt_strerror(fdt_ret));
+               goto err;
+       }
+
        /* Delete the old LMB reservation */
        if (lmb)
                lmb_free(lmb, (phys_addr_t)(u32)(uintptr_t)blob,