]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/image.c
image: Add Trusted Execution Environment image type
[people/ms/u-boot.git] / common / image.c
index 0e86c13a88aa827415d98740894abe12440ed91f..bd07e86701a4171c2a2c7a428d3a5dbe632782d5 100644 (file)
@@ -165,6 +165,7 @@ static const table_entry_t uimage_type[] = {
        {       IH_TYPE_ZYNQIMAGE,  "zynqimage",  "Xilinx Zynq Boot Image" },
        {       IH_TYPE_ZYNQMPIMAGE, "zynqmpimage", "Xilinx ZynqMP Boot Image" },
        {       IH_TYPE_FPGA,       "fpga",       "FPGA Image" },
+       {       IH_TYPE_TEE,        "tee",        "Trusted Execution Environment Image",},
        {       -1,                 "",           "",                   },
 };
 
@@ -587,10 +588,12 @@ const table_entry_t *get_table_entry(const table_entry_t *table, int id)
 
 static const char *unknown_msg(enum ih_category category)
 {
+       static const char unknown_str[] = "Unknown ";
        static char msg[30];
 
-       strcpy(msg, "Unknown ");
-       strcat(msg, table_info[category].desc);
+       strcpy(msg, unknown_str);
+       strncat(msg, table_info[category].desc,
+               sizeof(msg) - sizeof(unknown_str));
 
        return msg;
 }
@@ -1387,6 +1390,23 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
 }
 #endif
 
+static void fit_loadable_process(uint8_t img_type,
+                                ulong img_data,
+                                ulong img_len)
+{
+       int i;
+       const unsigned int count =
+                       ll_entry_count(struct fit_loadable_tbl, fit_loadable);
+       struct fit_loadable_tbl *fit_loadable_handler =
+                       ll_entry_start(struct fit_loadable_tbl, fit_loadable);
+       /* For each loadable handler */
+       for (i = 0; i < count; i++, fit_loadable_handler++)
+               /* matching this type */
+               if (fit_loadable_handler->type == img_type)
+                       /* call that handler with this image data */
+                       fit_loadable_handler->handler(img_data, img_len);
+}
+
 int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
                uint8_t arch, const ulong *ld_start, ulong * const ld_len)
 {
@@ -1405,6 +1425,7 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
        int conf_noffset;
        int fit_img_result;
        const char *uname;
+       uint8_t img_type;
 
        /* Check to see if the images struct has a FIT configuration */
        if (!genimg_has_config(images)) {
@@ -1445,6 +1466,21 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
                                /* Something went wrong! */
                                return fit_img_result;
                        }
+
+                       fit_img_result = fit_image_get_node(buf, uname);
+                       if (fit_img_result < 0) {
+                               /* Something went wrong! */
+                               return fit_img_result;
+                       }
+                       fit_img_result = fit_image_get_type(buf,
+                                                           fit_img_result,
+                                                           &img_type);
+                       if (fit_img_result < 0) {
+                               /* Something went wrong! */
+                               return fit_img_result;
+                       }
+
+                       fit_loadable_process(img_type, img_data, img_len);
                }
                break;
        default: