Merge branch 'next'
[platform/kernel/u-boot.git] / include / image.h
index 9ababf2..aeb0d37 100644 (file)
@@ -134,6 +134,9 @@ extern ulong image_load_addr;               /* Default Load Address */
 extern ulong image_save_addr;          /* Default Save Address */
 extern ulong image_save_size;          /* Default Save Size */
 
+/* An invalid size, meaning that the image size is not known */
+#define IMAGE_SIZE_INVAL       (-1UL)
+
 enum ih_category {
        IH_ARCH,
        IH_COMP,
@@ -308,6 +311,7 @@ enum {
        IH_TYPE_IMX8MIMAGE,             /* Freescale IMX8MBoot Image    */
        IH_TYPE_IMX8IMAGE,              /* Freescale IMX8Boot Image     */
        IH_TYPE_COPRO,                  /* Coprocessor Image for remoteproc*/
+       IH_TYPE_SUNXI_EGON,             /* Allwinner eGON Boot Image */
 
        IH_TYPE_COUNT,                  /* Number of image types */
 };
@@ -412,7 +416,7 @@ typedef struct bootm_headers {
        ulong           initrd_end;
        ulong           cmdline_start;
        ulong           cmdline_end;
-       bd_t            *kbd;
+       struct bd_info          *kbd;
 #endif
 
        int             verify;         /* env_get("verify")[0] != 'n' */
@@ -563,11 +567,21 @@ int genimg_get_cat_count(enum ih_category category);
 /**
  * genimg_get_cat_desc() - Get the description of a category
  *
+ * @category:  Category to check
  * @return the description of a category, e.g. "architecture". This
  * effectively converts the enum to a string.
  */
 const char *genimg_get_cat_desc(enum ih_category category);
 
+/**
+ * genimg_cat_has_id() - Check whether a category has an item
+ *
+ * @category:  Category to check
+ * @id:                Item ID
+ * @return true or false as to whether a category has an item
+ */
+bool genimg_cat_has_id(enum ih_category category, uint id);
+
 int genimg_get_os_id(const char *name);
 int genimg_get_arch_id(const char *name);
 int genimg_get_type_id(const char *name);
@@ -755,7 +769,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                  ulong *initrd_start, ulong *initrd_end);
 int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end);
 #ifdef CONFIG_SYS_BOOT_GET_KBD
-int boot_get_kbd(struct lmb *lmb, bd_t **kbd);
+int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd);
 #endif /* CONFIG_SYS_BOOT_GET_KBD */
 #endif /* !USE_HOSTCC */
 
@@ -872,6 +886,11 @@ static inline int image_check_type(const image_header_t *hdr, uint8_t type)
 }
 static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
 {
+#ifndef USE_HOSTCC
+       /* Let's assume that sandbox can load any architecture */
+       if (IS_ENABLED(CONFIG_SANDBOX))
+               return true;
+#endif
        return (image_get_arch(hdr) == arch) ||
                (image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
 }
@@ -1131,7 +1150,23 @@ int fit_image_check_os(const void *fit, int noffset, uint8_t os);
 int fit_image_check_arch(const void *fit, int noffset, uint8_t arch);
 int fit_image_check_type(const void *fit, int noffset, uint8_t type);
 int fit_image_check_comp(const void *fit, int noffset, uint8_t comp);
-int fit_check_format(const void *fit);
+
+/**
+ * fit_check_format() - Check that the FIT is valid
+ *
+ * This performs various checks on the FIT to make sure it is suitable for
+ * use, looking for mandatory properties, nodes, etc.
+ *
+ * If FIT_FULL_CHECK is enabled, it also runs it through libfdt to make
+ * sure that there are no strange tags or broken nodes in the FIT.
+ *
+ * @fit: pointer to the FIT format image header
+ * @return 0 if OK, -ENOEXEC if not an FDT file, -EINVAL if the full FDT check
+ *     failed (e.g. due to bad structure), -ENOMSG if the description is
+ *     missing, -EBADMSG if the timestamp is missing, -ENOENT if the /images
+ *     path is missing
+ */
+int fit_check_format(const void *fit, ulong size);
 
 int fit_conf_find_compat(const void *fit, const void *fdt);
 
@@ -1463,7 +1498,7 @@ struct cipher_algo {
                       unsigned char **cipher, int *cipher_len);
 
        int (*add_cipher_data)(struct image_cipher_info *info,
-                              void *keydest);
+                              void *keydest, void *fit, int node_noffset);
 
        int (*decrypt)(struct image_cipher_info *info,
                       const void *cipher, size_t cipher_len,
@@ -1526,8 +1561,6 @@ bool android_image_print_dtb_contents(ulong hdr_addr);
  */
 int board_fit_config_name_match(const char *name);
 
-#if defined(CONFIG_SPL_FIT_IMAGE_POST_PROCESS) || \
-       defined(CONFIG_FIT_IMAGE_POST_PROCESS)
 /**
  * board_fit_image_post_process() - Do any post-process on FIT binary data
  *
@@ -1542,7 +1575,6 @@ int board_fit_config_name_match(const char *name);
  * @return no return value (failure should be handled internally)
  */
 void board_fit_image_post_process(void **p_image, size_t *p_size);
-#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
 #define FDT_ERROR      ((ulong)(-1))
 
@@ -1592,4 +1624,16 @@ struct fit_loadable_tbl {
                .handler = _handler, \
        }
 
+/**
+ * fit_update - update storage with FIT image
+ * @fit:        Pointer to FIT image
+ *
+ * Update firmware on storage using FIT image as input.
+ * The storage area to be update will be identified by the name
+ * in FIT and matching it to "dfu_alt_info" variable.
+ *
+ * Return:      0 on success, non-zero otherwise
+ */
+int fit_update(const void *fit);
+
 #endif /* __IMAGE_H__ */