]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - include/image.h
Kconfig: Move CONFIG_FIT and related options to Kconfig
[people/ms/u-boot.git] / include / image.h
index 340105658c02554597e84951e8d8f9bde571f54b..02ca43bb89e865d30a9bc88d6ec64ddf55057efd 100644 (file)
 struct lmb;
 
 #ifdef USE_HOSTCC
+#include <sys/types.h>
 
 /* new uImage format support enabled on host */
-#define CONFIG_FIT             1
-#define CONFIG_OF_LIBFDT       1
+#define IMAGE_ENABLE_FIT               1
 #define CONFIG_FIT_VERBOSE     1 /* enable fit_format_{error,warning}() */
 
 #define IMAGE_ENABLE_IGNORE    0
@@ -42,9 +42,11 @@ struct lmb;
 #define IMAGE_ENABLE_IGNORE    1
 #define IMAGE_INDENT_STRING    "   "
 
+#define IMAGE_ENABLE_FIT               CONFIG_IS_ENABLED(FIT)
+
 #endif /* USE_HOSTCC */
 
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
 #include <hash.h>
 #include <libfdt.h>
 #include <fdt_support.h>
@@ -93,7 +95,7 @@ struct lmb;
 #define IMAGE_ENABLE_SHA256    0
 #endif
 
-#endif /* CONFIG_FIT */
+#endif /* IMAGE_ENABLE_FIT */
 
 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
 # define IMAGE_ENABLE_RAMDISK_HIGH     1
@@ -119,6 +121,12 @@ struct lmb;
 # define IMAGE_OF_BOARD_SETUP          0
 #endif
 
+#ifdef CONFIG_OF_SYSTEM_SETUP
+# define IMAGE_OF_SYSTEM_SETUP 1
+#else
+# define IMAGE_OF_SYSTEM_SETUP 0
+#endif
+
 /*
  * Operating System Codes
  */
@@ -146,6 +154,7 @@ struct lmb;
 #define IH_OS_INTEGRITY                21      /* INTEGRITY    */
 #define IH_OS_OSE              22      /* OSE          */
 #define IH_OS_PLAN9            23      /* Plan 9       */
+#define IH_OS_OPENRTOS         24      /* OpenRTOS     */
 
 /*
  * CPU Architecture Codes (supported by Linux)
@@ -173,6 +182,7 @@ struct lmb;
 #define IH_ARCH_OPENRISC        21     /* OpenRISC 1000  */
 #define IH_ARCH_ARM64          22      /* ARM64        */
 #define IH_ARCH_ARC            23      /* Synopsys DesignWare ARC */
+#define IH_ARCH_X86_64         24      /* AMD x86_64, Intel and Via */
 
 /*
  * Image Types
@@ -232,6 +242,16 @@ struct lmb;
 #define IH_TYPE_MXSIMAGE       16      /* Freescale MXSBoot Image      */
 #define IH_TYPE_GPIMAGE                17      /* TI Keystone GPHeader Image   */
 #define IH_TYPE_ATMELIMAGE     18      /* ATMEL ROM bootable Image     */
+#define IH_TYPE_SOCFPGAIMAGE   19      /* Altera SOCFPGA Preloader     */
+#define IH_TYPE_X86_SETUP      20      /* x86 setup.bin Image          */
+#define IH_TYPE_LPC32XXIMAGE   21      /* x86 setup.bin Image          */
+#define IH_TYPE_LOADABLE       22      /* A list of typeless images    */
+#define IH_TYPE_RKIMAGE                23      /* Rockchip Boot Image          */
+#define IH_TYPE_RKSD           24      /* Rockchip SD card             */
+#define IH_TYPE_RKSPI          25      /* Rockchip SPI image           */
+#define IH_TYPE_ZYNQIMAGE      26      /* Xilinx Zynq Boot Image */
+
+#define IH_TYPE_COUNT          27      /* Number of image types */
 
 /*
  * Compression Types
@@ -241,6 +261,7 @@ struct lmb;
 #define IH_COMP_BZIP2          2       /* bzip2 Compression Used       */
 #define IH_COMP_LZMA           3       /* lzma  Compression Used       */
 #define IH_COMP_LZO            4       /* lzo   Compression Used       */
+#define IH_COMP_LZ4            5       /* lz4   Compression Used       */
 
 #define IH_MAGIC       0x27051956      /* Image Magic Number           */
 #define IH_NMLEN               32      /* Image Name Length            */
@@ -272,6 +293,7 @@ typedef struct image_info {
        ulong           image_start, image_len; /* start of image within blob, len of image */
        ulong           load;                   /* load addr for the image */
        uint8_t         comp, type, os;         /* compression, type of image, os type */
+       uint8_t         arch;                   /* CPU architecture */
 } image_info_t;
 
 /*
@@ -288,7 +310,7 @@ typedef struct bootm_headers {
        image_header_t  legacy_hdr_os_copy;     /* header copy */
        ulong           legacy_hdr_valid;
 
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
        const char      *fit_uname_cfg; /* configuration node unit name */
 
        void            *fit_hdr_os;    /* os FIT image header */
@@ -302,6 +324,10 @@ typedef struct bootm_headers {
        void            *fit_hdr_fdt;   /* FDT blob FIT image header */
        const char      *fit_uname_fdt; /* FDT blob subimage node unit name */
        int             fit_noffset_fdt;/* FDT blob subimage node offset */
+
+       void            *fit_hdr_setup; /* x86 setup FIT image header */
+       const char      *fit_uname_setup; /* x86 setup subimage node name */
+       int             fit_noffset_setup;/* x86 setup subimage node offset */
 #endif
 
 #ifndef USE_HOSTCC
@@ -393,6 +419,15 @@ char *get_table_entry_name(const table_entry_t *table, char *msg, int id);
 const char *genimg_get_os_name(uint8_t os);
 const char *genimg_get_arch_name(uint8_t arch);
 const char *genimg_get_type_name(uint8_t type);
+
+/**
+ * genimg_get_type_short_name() - get the short name for an image type
+ *
+ * @param type Image type (IH_TYPE_...)
+ * @return image short name, or "unknown" if unknown
+ */
+const char *genimg_get_type_short_name(uint8_t type);
+
 const char *genimg_get_comp_name(uint8_t comp);
 int genimg_get_os_id(const char *name);
 int genimg_get_arch_id(const char *name);
@@ -416,6 +451,9 @@ enum fit_load_op {
        FIT_LOAD_REQUIRED,      /* Must be provided */
 };
 
+int boot_get_setup(bootm_headers_t *images, uint8_t arch, ulong *setup_start,
+                  ulong *setup_len);
+
 #ifndef USE_HOSTCC
 /* Image format types, returned by _get_format() routine */
 #define IMAGE_FORMAT_INVALID   0x00
@@ -435,7 +473,34 @@ ulong genimg_get_image(ulong img_addr);
 
 int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                uint8_t arch, ulong *rd_start, ulong *rd_end);
-#endif
+
+/**
+ * boot_get_loadable - routine to load a list of binaries to memory
+ * @argc: Ignored Argument
+ * @argv: Ignored Argument
+ * @images: pointer to the bootm images structure
+ * @arch: expected architecture for the image
+ * @ld_start: Ignored Argument
+ * @ld_len: Ignored Argument
+ *
+ * boot_get_loadable() will take the given FIT configuration, and look
+ * for a field named "loadables".  Loadables, is a list of elements in
+ * the FIT given as strings.  exe:
+ *   loadables = "linux_kernel@1", "fdt@2";
+ * this function will attempt to parse each string, and load the
+ * corresponding element from the FIT into memory.  Once placed,
+ * no aditional actions are taken.
+ *
+ * @return:
+ *     0, if only valid images or no images are found
+ *     error code, if an error occurs during fit_image_load
+ */
+int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
+               uint8_t arch, const ulong *ld_start, ulong * const ld_len);
+#endif /* !USE_HOSTCC */
+
+int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
+                      ulong *setup_start, ulong *setup_len);
 
 /**
  * fit_image_load() - load an image from a FIT
@@ -692,7 +757,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 /*******************************************************************/
 /* New uImage format specific code (prefixed with fit_) */
 /*******************************************************************/
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
 
 #define FIT_IMAGES_PATH                "/images"
 #define FIT_CONFS_PATH         "/configurations"
@@ -719,7 +784,9 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 #define FIT_KERNEL_PROP                "kernel"
 #define FIT_RAMDISK_PROP       "ramdisk"
 #define FIT_FDT_PROP           "fdt"
+#define FIT_LOADABLE_PROP      "loadables"
 #define FIT_DEFAULT_PROP       "default"
+#define FIT_SETUP_PROP         "setup"
 
 #define FIT_MAX_HASH_LEN       HASH_MAX_DIGEST_SIZE
 
@@ -729,6 +796,7 @@ int fit_parse_conf(const char *spec, ulong addr_curr,
 int fit_parse_subimage(const char *spec, ulong addr_curr,
                ulong *addr, const char **image_name);
 
+int fit_get_subimage_count(const void *fit, int images_noffset);
 void fit_print_contents(const void *fit);
 void fit_image_print(const void *fit, int noffset, const char *p);
 
@@ -751,10 +819,7 @@ static inline ulong fit_get_size(const void *fit)
  * returns:
  *     end address of the FIT image (blob) in memory
  */
-static inline ulong fit_get_end(const void *fit)
-{
-       return (ulong)fit + fdt_totalsize(fit);
-}
+ulong fit_get_end(const void *fit);
 
 /**
  * fit_get_name - get FIT node name
@@ -888,6 +953,7 @@ struct image_sign_info {
        int required_keynode;           /* Node offset of key to use: -1=any */
        const char *require_keys;       /* Value for 'required' property */
 };
+#endif /* Allow struct image_region to always be defined for rsa.h */
 
 /* A part of an image, used for hashing */
 struct image_region {
@@ -895,6 +961,8 @@ struct image_region {
        int size;
 };
 
+#if IMAGE_ENABLE_FIT
+
 #if IMAGE_ENABLE_VERIFY
 # include <u-boot/rsa-checksum.h>
 #endif
@@ -905,8 +973,9 @@ struct checksum_algo {
 #if IMAGE_ENABLE_SIGN
        const EVP_MD *(*calculate_sign)(void);
 #endif
-       void (*calculate)(const struct image_region region[],
-                         int region_count, uint8_t *checksum);
+       int (*calculate)(const char *name,
+                        const struct image_region region[],
+                        int region_count, uint8_t *checksum);
        const uint8_t *rsa_padding;
 };