4 * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
14 * Callback function to register a image type within a tool
16 static imagetool_register_t register_func
;
19 * register_image_tool -
21 * The tool provides its own registration function in order to all image
22 * types initialize themselves.
24 void register_image_tool(imagetool_register_t image_register
)
27 * Save the image tool callback function. It will be used to register
28 * image types within that tool
30 register_func
= image_register
;
32 /* Init ATMEL ROM Boot Image generation/list support */
33 init_atmel_image_type();
34 /* Init Freescale PBL Boot image generation/list support */
35 init_pbl_image_type();
36 /* Init Kirkwood Boot image generation/list support */
37 init_kwb_image_type();
38 /* Init Freescale imx Boot image generation/list support */
39 init_imx_image_type();
40 /* Init Freescale mxs Boot image generation/list support */
41 init_mxs_image_type();
42 /* Init FIT image generation/list support */
43 init_fit_image_type();
44 /* Init TI OMAP Boot image generation/list support */
45 init_omap_image_type();
46 /* Init Default image generation/list support */
47 init_default_image_type();
48 /* Init Davinci UBL support */
49 init_ubl_image_type();
50 /* Init Davinci AIS support */
51 init_ais_image_type();
52 /* Init Altera SOCFPGA support */
53 init_socfpga_image_type();
54 /* Init TI Keystone boot image generation/list support */
59 * register_image_type -
61 * Register a image type within a tool
63 void register_image_type(struct image_type_params
*tparams
)
65 register_func(tparams
);
68 struct image_type_params
*imagetool_get_type(
70 struct image_type_params
*tparams
)
72 struct image_type_params
*curr
;
74 for (curr
= tparams
; curr
!= NULL
; curr
= curr
->next
) {
75 if (curr
->check_image_type
) {
76 if (!curr
->check_image_type(type
))
83 int imagetool_verify_print_header(
86 struct image_type_params
*tparams
,
87 struct image_tool_params
*params
)
90 struct image_type_params
*curr
;
92 for (curr
= tparams
; curr
!= NULL
; curr
= curr
->next
) {
93 if (curr
->verify_header
) {
94 retval
= curr
->verify_header((unsigned char *)ptr
,
95 sbuf
->st_size
, params
);
99 * Print the image information if verify is
102 if (curr
->print_header
) {
103 curr
->print_header(ptr
);
106 "%s: print_header undefined for %s\n",
107 params
->cmdname
, curr
->name
);
117 int imagetool_save_datafile(
118 const char *file_name
,
124 dfd
= open(file_name
, O_RDWR
| O_CREAT
| O_TRUNC
| O_BINARY
,
127 fprintf(stderr
, "Can't open \"%s\": %s\n",
128 file_name
, strerror(errno
));
132 if (write(dfd
, (void *)file_data
, file_len
) != (ssize_t
)file_len
) {
133 fprintf(stderr
, "Write error on \"%s\": %s\n",
134 file_name
, strerror(errno
));