xref: /openbmc/u-boot/tools/imagetool.h (revision e8e3f2d2d48f97b2c79b698eccedce8f4f880993)
183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2f86ed6a8SGuilherme Maciel Ferreira /*
3f86ed6a8SGuilherme Maciel Ferreira  * (C) Copyright 2013
4f86ed6a8SGuilherme Maciel Ferreira  *
5f86ed6a8SGuilherme Maciel Ferreira  * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
6f86ed6a8SGuilherme Maciel Ferreira  */
7f86ed6a8SGuilherme Maciel Ferreira 
8f86ed6a8SGuilherme Maciel Ferreira #ifndef _IMAGETOOL_H_
9f86ed6a8SGuilherme Maciel Ferreira #define _IMAGETOOL_H_
10f86ed6a8SGuilherme Maciel Ferreira 
11f86ed6a8SGuilherme Maciel Ferreira #include "os_support.h"
12f86ed6a8SGuilherme Maciel Ferreira #include <errno.h>
13f86ed6a8SGuilherme Maciel Ferreira #include <fcntl.h>
14d2bf1152SMasahiro Yamada #include <stdbool.h>
15f86ed6a8SGuilherme Maciel Ferreira #include <stdio.h>
16f86ed6a8SGuilherme Maciel Ferreira #include <stdlib.h>
17f86ed6a8SGuilherme Maciel Ferreira #include <string.h>
18f86ed6a8SGuilherme Maciel Ferreira #include <sys/stat.h>
1926e355d1SJörg Krause #include <sys/types.h>
20f86ed6a8SGuilherme Maciel Ferreira #include <time.h>
21f86ed6a8SGuilherme Maciel Ferreira #include <unistd.h>
222b9912e6SJeroen Hofstee #include <u-boot/sha1.h>
23a93648d1SGuilherme Maciel Ferreira 
24f86ed6a8SGuilherme Maciel Ferreira #include "fdt_host.h"
25f86ed6a8SGuilherme Maciel Ferreira 
26f86ed6a8SGuilherme Maciel Ferreira #define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
27f86ed6a8SGuilherme Maciel Ferreira 
28f86ed6a8SGuilherme Maciel Ferreira #define IH_ARCH_DEFAULT		IH_ARCH_INVALID
29f86ed6a8SGuilherme Maciel Ferreira 
30fb4cce0fSSimon Glass /* Information about a file that needs to be placed into the FIT */
31fb4cce0fSSimon Glass struct content_info {
32fb4cce0fSSimon Glass 	struct content_info *next;
33fb4cce0fSSimon Glass 	int type;		/* File type (IH_TYPE_...) */
34fb4cce0fSSimon Glass 	const char *fname;
35fb4cce0fSSimon Glass };
36fb4cce0fSSimon Glass 
37f86ed6a8SGuilherme Maciel Ferreira /*
38f86ed6a8SGuilherme Maciel Ferreira  * This structure defines all such variables those are initialized by
39f86ed6a8SGuilherme Maciel Ferreira  * mkimage and dumpimage main core and need to be referred by image
40f86ed6a8SGuilherme Maciel Ferreira  * type specific functions
41f86ed6a8SGuilherme Maciel Ferreira  */
42f86ed6a8SGuilherme Maciel Ferreira struct image_tool_params {
43f86ed6a8SGuilherme Maciel Ferreira 	int dflag;
44f86ed6a8SGuilherme Maciel Ferreira 	int eflag;
45f86ed6a8SGuilherme Maciel Ferreira 	int fflag;
46a804b5ceSGuilherme Maciel Ferreira 	int iflag;
47f86ed6a8SGuilherme Maciel Ferreira 	int lflag;
48a804b5ceSGuilherme Maciel Ferreira 	int pflag;
49f86ed6a8SGuilherme Maciel Ferreira 	int vflag;
50f86ed6a8SGuilherme Maciel Ferreira 	int xflag;
51f86ed6a8SGuilherme Maciel Ferreira 	int skipcpy;
52f86ed6a8SGuilherme Maciel Ferreira 	int os;
53f86ed6a8SGuilherme Maciel Ferreira 	int arch;
54f86ed6a8SGuilherme Maciel Ferreira 	int type;
55f86ed6a8SGuilherme Maciel Ferreira 	int comp;
56f86ed6a8SGuilherme Maciel Ferreira 	char *dtc;
57f86ed6a8SGuilherme Maciel Ferreira 	unsigned int addr;
58f86ed6a8SGuilherme Maciel Ferreira 	unsigned int ep;
59f86ed6a8SGuilherme Maciel Ferreira 	char *imagename;
60f86ed6a8SGuilherme Maciel Ferreira 	char *imagename2;
61f86ed6a8SGuilherme Maciel Ferreira 	char *datafile;
62f86ed6a8SGuilherme Maciel Ferreira 	char *imagefile;
63f86ed6a8SGuilherme Maciel Ferreira 	char *cmdname;
64a804b5ceSGuilherme Maciel Ferreira 	const char *outfile;	/* Output filename */
65f86ed6a8SGuilherme Maciel Ferreira 	const char *keydir;	/* Directory holding private keys */
66f86ed6a8SGuilherme Maciel Ferreira 	const char *keydest;	/* Destination .dtb for public key */
67f86ed6a8SGuilherme Maciel Ferreira 	const char *comment;	/* Comment to add to signature node */
68f86ed6a8SGuilherme Maciel Ferreira 	int require_keys;	/* 1 to mark signing keys as 'required' */
6992a655c3SSimon Glass 	int file_size;		/* Total size of output file */
701b99e5bbSSimon Glass 	int orig_file_size;	/* Original size for file before padding */
718e35bb07SSimon Glass 	bool auto_its;		/* Automatically create the .its file */
72d505a09cSSimon Glass 	int fit_image_type;	/* Image type to put into the FIT */
730f7c6cdcSTomeu Vizoso 	char *fit_ramdisk;	/* Ramdisk file to include */
74fb4cce0fSSimon Glass 	struct content_info *content_head;	/* List of files to include */
75fb4cce0fSSimon Glass 	struct content_info *content_tail;
76722ebc8fSSimon Glass 	bool external_data;	/* Store data outside the FIT */
77bd6e1420SSimon Glass 	bool quiet;		/* Don't output text in normal operation */
78f8f9107dSTeddy Reed 	unsigned int external_offset;	/* Add padding to external data */
79f1ca1fdeSGeorge McCollister 	const char *engine_id;	/* Engine to use for signing */
80f86ed6a8SGuilherme Maciel Ferreira };
81f86ed6a8SGuilherme Maciel Ferreira 
82f86ed6a8SGuilherme Maciel Ferreira /*
83f86ed6a8SGuilherme Maciel Ferreira  * image type specific variables and callback functions
84f86ed6a8SGuilherme Maciel Ferreira  */
85f86ed6a8SGuilherme Maciel Ferreira struct image_type_params {
86f86ed6a8SGuilherme Maciel Ferreira 	/* name is an identification tag string for added support */
87f86ed6a8SGuilherme Maciel Ferreira 	char *name;
88f86ed6a8SGuilherme Maciel Ferreira 	/*
89f86ed6a8SGuilherme Maciel Ferreira 	 * header size is local to the specific image type to be supported,
90f86ed6a8SGuilherme Maciel Ferreira 	 * mkimage core treats this as number of bytes
91f86ed6a8SGuilherme Maciel Ferreira 	 */
92f86ed6a8SGuilherme Maciel Ferreira 	uint32_t header_size;
93f86ed6a8SGuilherme Maciel Ferreira 	/* Image type header pointer */
94f86ed6a8SGuilherme Maciel Ferreira 	void *hdr;
95f86ed6a8SGuilherme Maciel Ferreira 	/*
96f86ed6a8SGuilherme Maciel Ferreira 	 * There are several arguments that are passed on the command line
97f86ed6a8SGuilherme Maciel Ferreira 	 * and are registered as flags in image_tool_params structure.
98f86ed6a8SGuilherme Maciel Ferreira 	 * This callback function can be used to check the passed arguments
99f86ed6a8SGuilherme Maciel Ferreira 	 * are in-lined with the image type to be supported
100f86ed6a8SGuilherme Maciel Ferreira 	 *
101f86ed6a8SGuilherme Maciel Ferreira 	 * Returns 1 if parameter check is successful
102f86ed6a8SGuilherme Maciel Ferreira 	 */
103f86ed6a8SGuilherme Maciel Ferreira 	int (*check_params) (struct image_tool_params *);
104f86ed6a8SGuilherme Maciel Ferreira 	/*
105f86ed6a8SGuilherme Maciel Ferreira 	 * This function is used by list command (i.e. mkimage -l <filename>)
106f86ed6a8SGuilherme Maciel Ferreira 	 * image type verification code must be put here
107f86ed6a8SGuilherme Maciel Ferreira 	 *
108f86ed6a8SGuilherme Maciel Ferreira 	 * Returns 0 if image header verification is successful
109f86ed6a8SGuilherme Maciel Ferreira 	 * otherwise, returns respective negative error codes
110f86ed6a8SGuilherme Maciel Ferreira 	 */
111f86ed6a8SGuilherme Maciel Ferreira 	int (*verify_header) (unsigned char *, int, struct image_tool_params *);
112f86ed6a8SGuilherme Maciel Ferreira 	/* Prints image information abstracting from image header */
113f86ed6a8SGuilherme Maciel Ferreira 	void (*print_header) (const void *);
114f86ed6a8SGuilherme Maciel Ferreira 	/*
115f86ed6a8SGuilherme Maciel Ferreira 	 * The header or image contents need to be set as per image type to
116f86ed6a8SGuilherme Maciel Ferreira 	 * be generated using this callback function.
117f86ed6a8SGuilherme Maciel Ferreira 	 * further output file post processing (for ex. checksum calculation,
118f86ed6a8SGuilherme Maciel Ferreira 	 * padding bytes etc..) can also be done in this callback function.
119f86ed6a8SGuilherme Maciel Ferreira 	 */
120f86ed6a8SGuilherme Maciel Ferreira 	void (*set_header) (void *, struct stat *, int,
121f86ed6a8SGuilherme Maciel Ferreira 					struct image_tool_params *);
122f86ed6a8SGuilherme Maciel Ferreira 	/*
12367f946cdSGuilherme Maciel Ferreira 	 * This function is used by the command to retrieve a component
12467f946cdSGuilherme Maciel Ferreira 	 * (sub-image) from the image (i.e. dumpimage -i <image> -p <position>
12567f946cdSGuilherme Maciel Ferreira 	 * <sub-image-name>).
126a804b5ceSGuilherme Maciel Ferreira 	 * Thus the code to extract a file from an image must be put here.
127a804b5ceSGuilherme Maciel Ferreira 	 *
128a804b5ceSGuilherme Maciel Ferreira 	 * Returns 0 if the file was successfully retrieved from the image,
129a804b5ceSGuilherme Maciel Ferreira 	 * or a negative value on error.
130a804b5ceSGuilherme Maciel Ferreira 	 */
13167f946cdSGuilherme Maciel Ferreira 	int (*extract_subimage)(void *, struct image_tool_params *);
132a804b5ceSGuilherme Maciel Ferreira 	/*
133f86ed6a8SGuilherme Maciel Ferreira 	 * Some image generation support for ex (default image type) supports
134f86ed6a8SGuilherme Maciel Ferreira 	 * more than one type_ids, this callback function is used to check
135f86ed6a8SGuilherme Maciel Ferreira 	 * whether input (-T <image_type>) is supported by registered image
136f86ed6a8SGuilherme Maciel Ferreira 	 * generation/list low level code
137f86ed6a8SGuilherme Maciel Ferreira 	 */
138f86ed6a8SGuilherme Maciel Ferreira 	int (*check_image_type) (uint8_t);
139f86ed6a8SGuilherme Maciel Ferreira 	/* This callback function will be executed if fflag is defined */
140f86ed6a8SGuilherme Maciel Ferreira 	int (*fflag_handle) (struct image_tool_params *);
141f86ed6a8SGuilherme Maciel Ferreira 	/*
142f86ed6a8SGuilherme Maciel Ferreira 	 * This callback function will be executed for variable size record
143f86ed6a8SGuilherme Maciel Ferreira 	 * It is expected to build this header in memory and return its length
144f86ed6a8SGuilherme Maciel Ferreira 	 * and a pointer to it by using image_type_params.header_size and
145f86ed6a8SGuilherme Maciel Ferreira 	 * image_type_params.hdr. The return value shall indicate if an
146f86ed6a8SGuilherme Maciel Ferreira 	 * additional padding should be used when copying the data image
147f86ed6a8SGuilherme Maciel Ferreira 	 * by returning the padding length.
148f86ed6a8SGuilherme Maciel Ferreira 	 */
149f86ed6a8SGuilherme Maciel Ferreira 	int (*vrec_header) (struct image_tool_params *,
150f86ed6a8SGuilherme Maciel Ferreira 		struct image_type_params *);
151f86ed6a8SGuilherme Maciel Ferreira };
152f86ed6a8SGuilherme Maciel Ferreira 
1530ca6691cSGuilherme Maciel Ferreira /**
1540ca6691cSGuilherme Maciel Ferreira  * imagetool_get_type() - find the image type params for a given image type
1550ca6691cSGuilherme Maciel Ferreira  *
1560ca6691cSGuilherme Maciel Ferreira  * It scans all registers image type supports
1570ca6691cSGuilherme Maciel Ferreira  * checks the input type for each supported image type
1580ca6691cSGuilherme Maciel Ferreira  *
1590ca6691cSGuilherme Maciel Ferreira  * if successful,
1600ca6691cSGuilherme Maciel Ferreira  *     returns respective image_type_params pointer if success
1610ca6691cSGuilherme Maciel Ferreira  * if input type_id is not supported by any of image_type_support
1620ca6691cSGuilherme Maciel Ferreira  *     returns NULL
1630ca6691cSGuilherme Maciel Ferreira  */
164a93648d1SGuilherme Maciel Ferreira struct image_type_params *imagetool_get_type(int type);
1650ca6691cSGuilherme Maciel Ferreira 
1660ca6691cSGuilherme Maciel Ferreira /*
1670ca6691cSGuilherme Maciel Ferreira  * imagetool_verify_print_header() - verifies the image header
1680ca6691cSGuilherme Maciel Ferreira  *
1690ca6691cSGuilherme Maciel Ferreira  * Scan registered image types and verify the image_header for each
1700ca6691cSGuilherme Maciel Ferreira  * supported image type. If verification is successful, this prints
1710ca6691cSGuilherme Maciel Ferreira  * the respective header.
1720ca6691cSGuilherme Maciel Ferreira  *
1730ca6691cSGuilherme Maciel Ferreira  * @return 0 on success, negative if input image format does not match with
1740ca6691cSGuilherme Maciel Ferreira  * any of supported image types
1750ca6691cSGuilherme Maciel Ferreira  */
1760ca6691cSGuilherme Maciel Ferreira int imagetool_verify_print_header(
1770ca6691cSGuilherme Maciel Ferreira 	void *ptr,
1780ca6691cSGuilherme Maciel Ferreira 	struct stat *sbuf,
1790ca6691cSGuilherme Maciel Ferreira 	struct image_type_params *tparams,
1800ca6691cSGuilherme Maciel Ferreira 	struct image_tool_params *params);
1810ca6691cSGuilherme Maciel Ferreira 
182*d32aa3caSJordan Hand /*
183*d32aa3caSJordan Hand  * imagetool_verify_print_header_by_type() - verifies the image header
184*d32aa3caSJordan Hand  *
185*d32aa3caSJordan Hand  * Verify the image_header for the image type given by tparams.
186*d32aa3caSJordan Hand  * If verification is successful, this prints the respective header.
187*d32aa3caSJordan Hand  * @ptr: pointer the the image header
188*d32aa3caSJordan Hand  * @sbuf: stat information about the file pointed to by ptr
189*d32aa3caSJordan Hand  * @tparams: image type parameters
190*d32aa3caSJordan Hand  * @params: mkimage parameters
191*d32aa3caSJordan Hand  *
192*d32aa3caSJordan Hand  * @return 0 on success, negative if input image format does not match with
193*d32aa3caSJordan Hand  * the given image type
194*d32aa3caSJordan Hand  */
195*d32aa3caSJordan Hand int imagetool_verify_print_header_by_type(
196*d32aa3caSJordan Hand 	void *ptr,
197*d32aa3caSJordan Hand 	struct stat *sbuf,
198*d32aa3caSJordan Hand 	struct image_type_params *tparams,
199*d32aa3caSJordan Hand 	struct image_tool_params *params);
200*d32aa3caSJordan Hand 
201067d1560SGuilherme Maciel Ferreira /**
20267f946cdSGuilherme Maciel Ferreira  * imagetool_save_subimage - store data into a file
203067d1560SGuilherme Maciel Ferreira  * @file_name: name of the destination file
204067d1560SGuilherme Maciel Ferreira  * @file_data: data to be written
205067d1560SGuilherme Maciel Ferreira  * @file_len: the amount of data to store
206067d1560SGuilherme Maciel Ferreira  *
20767f946cdSGuilherme Maciel Ferreira  * imagetool_save_subimage() store file_len bytes of data pointed by file_data
208067d1560SGuilherme Maciel Ferreira  * into the file name by file_name.
209067d1560SGuilherme Maciel Ferreira  *
210067d1560SGuilherme Maciel Ferreira  * returns:
211067d1560SGuilherme Maciel Ferreira  *     zero in case of success or a negative value if fail.
212067d1560SGuilherme Maciel Ferreira  */
21367f946cdSGuilherme Maciel Ferreira int imagetool_save_subimage(
214067d1560SGuilherme Maciel Ferreira 	const char *file_name,
215067d1560SGuilherme Maciel Ferreira 	ulong file_data,
216067d1560SGuilherme Maciel Ferreira 	ulong file_len);
217067d1560SGuilherme Maciel Ferreira 
2183837ce65SSimon Glass /**
2193837ce65SSimon Glass  * imagetool_get_filesize() - Utility function to obtain the size of a file
2203837ce65SSimon Glass  *
2213837ce65SSimon Glass  * This function prints a message if an error occurs, showing the error that
2223837ce65SSimon Glass  * was obtained.
2233837ce65SSimon Glass  *
2243837ce65SSimon Glass  * @params:	mkimage parameters
2253837ce65SSimon Glass  * @fname:	filename to check
2263837ce65SSimon Glass  * @return size of file, or -ve value on error
2273837ce65SSimon Glass  */
2283837ce65SSimon Glass int imagetool_get_filesize(struct image_tool_params *params, const char *fname);
2293837ce65SSimon Glass 
2305847084fSVagrant Cascadian /**
2315847084fSVagrant Cascadian  * imagetool_get_source_date() - Get timestamp for build output.
2325847084fSVagrant Cascadian  *
2335847084fSVagrant Cascadian  * Gets a timestamp for embedding it in a build output. If set
2345847084fSVagrant Cascadian  * SOURCE_DATE_EPOCH is used. Else the given fallback value is returned. Prints
2355847084fSVagrant Cascadian  * an error message if SOURCE_DATE_EPOCH contains an invalid value and returns
2365847084fSVagrant Cascadian  * 0.
2375847084fSVagrant Cascadian  *
23887925df2SAlex Kiernan  * @cmdname:	command name
2395847084fSVagrant Cascadian  * @fallback:	timestamp to use if SOURCE_DATE_EPOCH isn't set
2405847084fSVagrant Cascadian  * @return timestamp based on SOURCE_DATE_EPOCH
2415847084fSVagrant Cascadian  */
2425847084fSVagrant Cascadian time_t imagetool_get_source_date(
24387925df2SAlex Kiernan 	const char *cmdname,
2445847084fSVagrant Cascadian 	time_t fallback);
2455847084fSVagrant Cascadian 
246f86ed6a8SGuilherme Maciel Ferreira /*
247f86ed6a8SGuilherme Maciel Ferreira  * There is a c file associated with supported image type low level code
248f86ed6a8SGuilherme Maciel Ferreira  * for ex. default_image.c, fit_image.c
249f86ed6a8SGuilherme Maciel Ferreira  */
250a93648d1SGuilherme Maciel Ferreira 
251f86ed6a8SGuilherme Maciel Ferreira 
252f86ed6a8SGuilherme Maciel Ferreira void pbl_load_uboot(int fd, struct image_tool_params *mparams);
2536915dcf3SAlexander Graf int zynqmpbif_copy_image(int fd, struct image_tool_params *mparams);
254a2b96eceSPeng Fan int imx8image_copy_image(int fd, struct image_tool_params *mparams);
2556609c266SPeng Fan int imx8mimage_copy_image(int fd, struct image_tool_params *mparams);
256f86ed6a8SGuilherme Maciel Ferreira 
2571fddd7b6SAndreas Bießmann #define ___cat(a, b) a ## b
2581fddd7b6SAndreas Bießmann #define __cat(a, b) ___cat(a, b)
2591fddd7b6SAndreas Bießmann 
2601fddd7b6SAndreas Bießmann /* we need some special handling for this host tool running eventually on
2611fddd7b6SAndreas Bießmann  * Darwin. The Mach-O section handling is a bit different than ELF section
2621fddd7b6SAndreas Bießmann  * handling. The differnces in detail are:
2631fddd7b6SAndreas Bießmann  *  a) we have segments which have sections
2641fddd7b6SAndreas Bießmann  *  b) we need a API call to get the respective section symbols */
2651fddd7b6SAndreas Bießmann #if defined(__MACH__)
2661fddd7b6SAndreas Bießmann #include <mach-o/getsect.h>
2671fddd7b6SAndreas Bießmann 
2681fddd7b6SAndreas Bießmann #define INIT_SECTION(name)  do {					\
2691fddd7b6SAndreas Bießmann 		unsigned long name ## _len;				\
2701fddd7b6SAndreas Bießmann 		char *__cat(pstart_, name) = getsectdata("__TEXT",	\
2711fddd7b6SAndreas Bießmann 			#name, &__cat(name, _len));			\
2721fddd7b6SAndreas Bießmann 		char *__cat(pstop_, name) = __cat(pstart_, name) +	\
2731fddd7b6SAndreas Bießmann 			__cat(name, _len);				\
2741fddd7b6SAndreas Bießmann 		__cat(__start_, name) = (void *)__cat(pstart_, name);	\
2751fddd7b6SAndreas Bießmann 		__cat(__stop_, name) = (void *)__cat(pstop_, name);	\
2761fddd7b6SAndreas Bießmann 	} while (0)
2771fddd7b6SAndreas Bießmann #define SECTION(name)   __attribute__((section("__TEXT, " #name)))
2781fddd7b6SAndreas Bießmann 
2791fddd7b6SAndreas Bießmann struct image_type_params **__start_image_type, **__stop_image_type;
2801fddd7b6SAndreas Bießmann #else
2811fddd7b6SAndreas Bießmann #define INIT_SECTION(name) /* no-op for ELF */
2821fddd7b6SAndreas Bießmann #define SECTION(name)   __attribute__((section(#name)))
2831fddd7b6SAndreas Bießmann 
2841fddd7b6SAndreas Bießmann /* We construct a table of pointers in an ELF section (pointers generally
2851fddd7b6SAndreas Bießmann  * go unpadded by gcc).  ld creates boundary syms for us. */
2861fddd7b6SAndreas Bießmann extern struct image_type_params *__start_image_type[], *__stop_image_type[];
2871fddd7b6SAndreas Bießmann #endif /* __MACH__ */
2881fddd7b6SAndreas Bießmann 
2891fddd7b6SAndreas Bießmann #if !defined(__used)
2901fddd7b6SAndreas Bießmann # if __GNUC__ == 3 && __GNUC_MINOR__ < 3
2911fddd7b6SAndreas Bießmann #  define __used			__attribute__((__unused__))
2921fddd7b6SAndreas Bießmann # else
2931fddd7b6SAndreas Bießmann #  define __used			__attribute__((__used__))
2941fddd7b6SAndreas Bießmann # endif
2951fddd7b6SAndreas Bießmann #endif
2961fddd7b6SAndreas Bießmann 
297a93648d1SGuilherme Maciel Ferreira #define U_BOOT_IMAGE_TYPE( \
298a93648d1SGuilherme Maciel Ferreira 		_id, \
299a93648d1SGuilherme Maciel Ferreira 		_name, \
300a93648d1SGuilherme Maciel Ferreira 		_header_size, \
301a93648d1SGuilherme Maciel Ferreira 		_header, \
302a93648d1SGuilherme Maciel Ferreira 		_check_params, \
303a93648d1SGuilherme Maciel Ferreira 		_verify_header, \
304a93648d1SGuilherme Maciel Ferreira 		_print_header, \
305a93648d1SGuilherme Maciel Ferreira 		_set_header, \
30667f946cdSGuilherme Maciel Ferreira 		_extract_subimage, \
307a93648d1SGuilherme Maciel Ferreira 		_check_image_type, \
308a93648d1SGuilherme Maciel Ferreira 		_fflag_handle, \
309a93648d1SGuilherme Maciel Ferreira 		_vrec_header \
310a93648d1SGuilherme Maciel Ferreira 	) \
3111fddd7b6SAndreas Bießmann 	static struct image_type_params __cat(image_type_, _id) = \
3121fddd7b6SAndreas Bießmann 	{ \
313a93648d1SGuilherme Maciel Ferreira 		.name = _name, \
314a93648d1SGuilherme Maciel Ferreira 		.header_size = _header_size, \
315a93648d1SGuilherme Maciel Ferreira 		.hdr = _header, \
316a93648d1SGuilherme Maciel Ferreira 		.check_params = _check_params, \
317a93648d1SGuilherme Maciel Ferreira 		.verify_header = _verify_header, \
318a93648d1SGuilherme Maciel Ferreira 		.print_header = _print_header, \
319a93648d1SGuilherme Maciel Ferreira 		.set_header = _set_header, \
32067f946cdSGuilherme Maciel Ferreira 		.extract_subimage = _extract_subimage, \
321a93648d1SGuilherme Maciel Ferreira 		.check_image_type = _check_image_type, \
322a93648d1SGuilherme Maciel Ferreira 		.fflag_handle = _fflag_handle, \
323a93648d1SGuilherme Maciel Ferreira 		.vrec_header = _vrec_header \
3241fddd7b6SAndreas Bießmann 	}; \
3251fddd7b6SAndreas Bießmann 	static struct image_type_params *SECTION(image_type) __used \
3261fddd7b6SAndreas Bießmann 		__cat(image_type_ptr_, _id) = &__cat(image_type_, _id)
327a93648d1SGuilherme Maciel Ferreira 
328f86ed6a8SGuilherme Maciel Ferreira #endif /* _IMAGETOOL_H_ */
329