4 * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
12 #include "os_support.h"
24 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
26 #define IH_ARCH_DEFAULT IH_ARCH_INVALID
29 * This structure defines all such variables those are initialized by
30 * mkimage and dumpimage main core and need to be referred by image
31 * type specific functions
33 struct image_tool_params {
53 const char *keydir; /* Directory holding private keys */
54 const char *keydest; /* Destination .dtb for public key */
55 const char *comment; /* Comment to add to signature node */
56 int require_keys; /* 1 to mark signing keys as 'required' */
60 * image type specific variables and callback functions
62 struct image_type_params {
63 /* name is an identification tag string for added support */
66 * header size is local to the specific image type to be supported,
67 * mkimage core treats this as number of bytes
70 /* Image type header pointer */
73 * There are several arguments that are passed on the command line
74 * and are registered as flags in image_tool_params structure.
75 * This callback function can be used to check the passed arguments
76 * are in-lined with the image type to be supported
78 * Returns 1 if parameter check is successful
80 int (*check_params) (struct image_tool_params *);
82 * This function is used by list command (i.e. mkimage -l <filename>)
83 * image type verification code must be put here
85 * Returns 0 if image header verification is successful
86 * otherwise, returns respective negative error codes
88 int (*verify_header) (unsigned char *, int, struct image_tool_params *);
89 /* Prints image information abstracting from image header */
90 void (*print_header) (const void *);
92 * The header or image contents need to be set as per image type to
93 * be generated using this callback function.
94 * further output file post processing (for ex. checksum calculation,
95 * padding bytes etc..) can also be done in this callback function.
97 void (*set_header) (void *, struct stat *, int,
98 struct image_tool_params *);
100 * Some image generation support for ex (default image type) supports
101 * more than one type_ids, this callback function is used to check
102 * whether input (-T <image_type>) is supported by registered image
103 * generation/list low level code
105 int (*check_image_type) (uint8_t);
106 /* This callback function will be executed if fflag is defined */
107 int (*fflag_handle) (struct image_tool_params *);
109 * This callback function will be executed for variable size record
110 * It is expected to build this header in memory and return its length
111 * and a pointer to it by using image_type_params.header_size and
112 * image_type_params.hdr. The return value shall indicate if an
113 * additional padding should be used when copying the data image
114 * by returning the padding length.
116 int (*vrec_header) (struct image_tool_params *,
117 struct image_type_params *);
118 /* pointer to the next registered entry in linked list */
119 struct image_type_params *next;
123 * Tool registration function.
125 typedef void (*imagetool_register_t)(struct image_type_params *);
128 * Initializes all image types with the given registration callback
130 * An image tool uses this function to initialize all image types.
132 void register_image_tool(imagetool_register_t image_register);
135 * Register a image type within a tool.
136 * An image type uses this function to register itself within
139 void register_image_type(struct image_type_params *tparams);
142 * There is a c file associated with supported image type low level code
143 * for ex. default_image.c, fit_image.c
144 * init_xxx_type() is the only function referred by image tool core to avoid
145 * a single lined header file, you can define them here
147 * Supported image types init functions
149 void init_default_image_type(void);
150 void init_pbl_image_type(void);
151 void init_ais_image_type(void);
152 void init_kwb_image_type(void);
153 void init_imx_image_type(void);
154 void init_mxs_image_type(void);
155 void init_fit_image_type(void);
156 void init_ubl_image_type(void);
157 void init_omap_image_type(void);
159 void pbl_load_uboot(int fd, struct image_tool_params *mparams);
161 #endif /* _IMAGETOOL_H_ */