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 ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
47 static inline void *map_sysmem(ulong paddr, unsigned long len)
49 return (void *)(uintptr_t)paddr;
52 static inline ulong map_to_sysmem(void *ptr)
54 return (ulong)(uintptr_t)ptr;
57 #define MKIMAGE_TMPFILE_SUFFIX ".tmp"
58 #define MKIMAGE_MAX_TMPFILE_LEN 256
59 #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"
60 #define MKIMAGE_MAX_DTC_CMDLINE_LEN 512
61 #define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */
63 #define IH_ARCH_DEFAULT IH_ARCH_INVALID
66 * This structure defines all such variables those are initialized by
67 * mkimage main core and need to be referred by image type specific
70 struct mkimage_params {
93 * image type specific variables and callback functions
95 struct image_type_params {
96 /* name is an identification tag string for added support */
99 * header size is local to the specific image type to be supported,
100 * mkimage core treats this as number of bytes
102 uint32_t header_size;
103 /* Image type header pointer */
106 * There are several arguments that are passed on the command line
107 * and are registered as flags in mkimage_params structure.
108 * This callback function can be used to check the passed arguments
109 * are in-lined with the image type to be supported
111 * Returns 1 if parameter check is successful
113 int (*check_params) (struct mkimage_params *);
115 * This function is used by list command (i.e. mkimage -l <filename>)
116 * image type verification code must be put here
118 * Returns 0 if image header verification is successful
119 * otherwise, returns respective negative error codes
121 int (*verify_header) (unsigned char *, int, struct mkimage_params *);
122 /* Prints image information abstracting from image header */
123 void (*print_header) (const void *);
125 * The header or image contents need to be set as per image type to
126 * be generated using this callback function.
127 * further output file post processing (for ex. checksum calculation,
128 * padding bytes etc..) can also be done in this callback function.
130 void (*set_header) (void *, struct stat *, int,
131 struct mkimage_params *);
133 * Some image generation support for ex (default image type) supports
134 * more than one type_ids, this callback function is used to check
135 * whether input (-T <image_type>) is supported by registered image
136 * generation/list low level code
138 int (*check_image_type) (uint8_t);
139 /* This callback function will be executed if fflag is defined */
140 int (*fflag_handle) (struct mkimage_params *);
142 * This callback function will be executed for variable size record
143 * It is expected to build this header in memory and return its length
144 * and a pointer to it
146 int (*vrec_header) (struct mkimage_params *,
147 struct image_type_params *);
148 /* pointer to the next registered entry in linked list */
149 struct image_type_params *next;
155 void mkimage_register (struct image_type_params *tparams);
158 * There is a c file associated with supported image type low level code
159 * for ex. default_image.c, fit_image.c
160 * init is the only function referred by mkimage core.
161 * to avoid a single lined header file, you can define them here
163 * Supported image types init functions
165 void pbl_load_uboot(int fd, struct mkimage_params *mparams);
166 void init_pbl_image_type(void);
167 void init_ais_image_type(void);
168 void init_kwb_image_type (void);
169 void init_imx_image_type (void);
170 void init_default_image_type (void);
171 void init_fit_image_type (void);
172 void init_ubl_image_type(void);
173 void init_omap_image_type(void);
175 #endif /* _MKIIMAGE_H_ */