2 * (C) Copyright 2000-2004
3 * DENX Software Engineering
4 * Wolfgang Denk, wd@denx.de
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include "os_support.h"
40 #define debug(fmt,args...) printf (fmt ,##args)
42 #define debug(fmt,args...)
43 #endif /* MKIMAGE_DEBUG */
45 #define MKIMAGE_TMPFILE_SUFFIX ".tmp"
46 #define MKIMAGE_MAX_TMPFILE_LEN 256
47 #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"
48 #define MKIMAGE_MAX_DTC_CMDLINE_LEN 512
49 #define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */
52 * This structure defines all such variables those are initialized by
53 * mkimage main core and need to be referred by image type specific
56 struct mkimage_params {
78 * image type specific variables and callback functions
80 struct image_type_params {
81 /* name is an identification tag string for added support */
84 * header size is local to the specific image type to be supported,
85 * mkimage core treats this as number of bytes
88 /* Image type header pointer */
91 * There are several arguments that are passed on the command line
92 * and are registered as flags in mkimage_params structure.
93 * This callback function can be used to check the passed arguments
94 * are in-lined with the image type to be supported
96 * Returns 1 if parameter check is successful
98 int (*check_params) (struct mkimage_params *);
100 * This function is used by list command (i.e. mkimage -l <filename>)
101 * image type verification code must be put here
103 * Returns 0 if image header verification is successful
104 * otherwise, returns respective negative error codes
106 int (*verify_header) (unsigned char *, int, struct mkimage_params *);
107 /* Prints image information abstracting from image header */
108 void (*print_header) (const void *);
110 * The header or image contents need to be set as per image type to
111 * be generated using this callback function.
112 * further output file post processing (for ex. checksum calculation,
113 * padding bytes etc..) can also be done in this callback function.
115 void (*set_header) (void *, struct stat *, int,
116 struct mkimage_params *);
118 * Some image generation support for ex (default image type) supports
119 * more than one type_ids, this callback function is used to check
120 * whether input (-T <image_type>) is supported by registered image
121 * generation/list low level code
123 int (*check_image_type) (uint8_t);
124 /* This callback function will be executed if fflag is defined */
125 int (*fflag_handle) (struct mkimage_params *);
127 * This callback function will be executed for variable size record
128 * It is expected to build this header in memory and return its length
129 * and a pointer to it
131 int (*vrec_header) (struct mkimage_params *,
132 struct image_type_params *);
133 /* pointer to the next registered entry in linked list */
134 struct image_type_params *next;
140 void mkimage_register (struct image_type_params *tparams);
143 * There is a c file associated with supported image type low level code
144 * for ex. default_image.c, fit_image.c
145 * init is the only function referred by mkimage core.
146 * to avoid a single lined header file, you can define them here
148 * Supported image types init functions
150 void init_ais_image_type(void);
151 void init_kwb_image_type (void);
152 void init_imx_image_type (void);
153 void init_default_image_type (void);
154 void init_fit_image_type (void);
155 void init_ubl_image_type(void);
156 void init_omap_image_type(void);
158 #endif /* _MKIIMAGE_H_ */