]> git.sur5r.net Git - u-boot/blobdiff - tools/default_image.c
image: Add IH_OS_TEE for TEE chain-load boot
[u-boot] / tools / default_image.c
index 4e5568e06a496fc6b43e865aee7d4093ce111c77..c67f66b2552eadf6dd6692a029884aeb7682f823 100644 (file)
@@ -18,6 +18,7 @@
 #include "mkimage.h"
 
 #include <image.h>
+#include <tee/optee.h>
 #include <u-boot/crc.h>
 
 static image_header_t header;
@@ -90,6 +91,8 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
        uint32_t checksum;
        time_t time;
        uint32_t imagesize;
+       uint32_t ep;
+       uint32_t addr;
 
        image_header_t * hdr = (image_header_t *)ptr;
 
@@ -99,18 +102,26 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
                        sbuf->st_size - sizeof(image_header_t));
 
        time = imagetool_get_source_date(params, sbuf->st_mtime);
+       ep = params->ep;
+       addr = params->addr;
+
        if (params->type == IH_TYPE_FIRMWARE_IVT)
                /* Add size of CSF minus IVT */
                imagesize = sbuf->st_size - sizeof(image_header_t) + 0x1FE0;
        else
                imagesize = sbuf->st_size - sizeof(image_header_t);
 
+       if (params->os == IH_OS_TEE) {
+               addr = optee_image_get_load_addr(hdr);
+               ep = optee_image_get_entry_point(hdr);
+       }
+
        /* Build new header */
        image_set_magic(hdr, IH_MAGIC);
        image_set_time(hdr, time);
        image_set_size(hdr, imagesize);
-       image_set_load(hdr, params->addr);
-       image_set_ep(hdr, params->ep);
+       image_set_load(hdr, addr);
+       image_set_ep(hdr, ep);
        image_set_dcrc(hdr, checksum);
        image_set_os(hdr, params->os);
        image_set_arch(hdr, params->arch);