123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- #ifndef _IMAGETOOL_H_
- #define _IMAGETOOL_H_
- #include "os_support.h"
- #include <errno.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <time.h>
- #include <unistd.h>
- #include <u-boot/sha1.h>
- #include "fdt_host.h"
- #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
- #define IH_ARCH_DEFAULT IH_ARCH_INVALID
- struct content_info {
- struct content_info *next;
- int type;
- const char *fname;
- };
- struct image_tool_params {
- int dflag;
- int eflag;
- int fflag;
- int iflag;
- int lflag;
- int pflag;
- int vflag;
- int xflag;
- int skipcpy;
- int os;
- int arch;
- int type;
- int comp;
- char *dtc;
- unsigned int addr;
- unsigned int ep;
- char *imagename;
- char *imagename2;
- char *datafile;
- char *imagefile;
- char *cmdname;
- const char *outfile;
- const char *keydir;
- const char *keydest;
- const char *comment;
- int require_keys;
- int file_size;
- int orig_file_size;
- bool auto_its;
- int fit_image_type;
- char *fit_ramdisk;
- struct content_info *content_head;
- struct content_info *content_tail;
- bool external_data;
- bool quiet;
- unsigned int external_offset;
- };
- struct image_type_params {
-
- char *name;
-
- uint32_t header_size;
-
- void *hdr;
-
- int (*check_params) (struct image_tool_params *);
-
- int (*verify_header) (unsigned char *, int, struct image_tool_params *);
-
- void (*print_header) (const void *);
-
- void (*set_header) (void *, struct stat *, int,
- struct image_tool_params *);
-
- int (*extract_subimage)(void *, struct image_tool_params *);
-
- int (*check_image_type) (uint8_t);
-
- int (*fflag_handle) (struct image_tool_params *);
-
- int (*vrec_header) (struct image_tool_params *,
- struct image_type_params *);
- };
- struct image_type_params *imagetool_get_type(int type);
- int imagetool_verify_print_header(
- void *ptr,
- struct stat *sbuf,
- struct image_type_params *tparams,
- struct image_tool_params *params);
- int imagetool_save_subimage(
- const char *file_name,
- ulong file_data,
- ulong file_len);
- int imagetool_get_filesize(struct image_tool_params *params, const char *fname);
- time_t imagetool_get_source_date(
- struct image_tool_params *params,
- time_t fallback);
- void pbl_load_uboot(int fd, struct image_tool_params *mparams);
- #define ___cat(a, b) a ## b
- #define __cat(a, b) ___cat(a, b)
- #if defined(__MACH__)
- #include <mach-o/getsect.h>
- #define INIT_SECTION(name) do { \
- unsigned long name ## _len; \
- char *__cat(pstart_, name) = getsectdata("__TEXT", \
- #name, &__cat(name, _len)); \
- char *__cat(pstop_, name) = __cat(pstart_, name) + \
- __cat(name, _len); \
- __cat(__start_, name) = (void *)__cat(pstart_, name); \
- __cat(__stop_, name) = (void *)__cat(pstop_, name); \
- } while (0)
- #define SECTION(name) __attribute__((section("__TEXT, " #name)))
- struct image_type_params **__start_image_type, **__stop_image_type;
- #else
- #define INIT_SECTION(name)
- #define SECTION(name) __attribute__((section(#name)))
- extern struct image_type_params *__start_image_type[], *__stop_image_type[];
- #endif
- #if !defined(__used)
- # if __GNUC__ == 3 && __GNUC_MINOR__ < 3
- # define __used __attribute__((__unused__))
- # else
- # define __used __attribute__((__used__))
- # endif
- #endif
- #define U_BOOT_IMAGE_TYPE( \
- _id, \
- _name, \
- _header_size, \
- _header, \
- _check_params, \
- _verify_header, \
- _print_header, \
- _set_header, \
- _extract_subimage, \
- _check_image_type, \
- _fflag_handle, \
- _vrec_header \
- ) \
- static struct image_type_params __cat(image_type_, _id) = \
- { \
- .name = _name, \
- .header_size = _header_size, \
- .hdr = _header, \
- .check_params = _check_params, \
- .verify_header = _verify_header, \
- .print_header = _print_header, \
- .set_header = _set_header, \
- .extract_subimage = _extract_subimage, \
- .check_image_type = _check_image_type, \
- .fflag_handle = _fflag_handle, \
- .vrec_header = _vrec_header \
- }; \
- static struct image_type_params *SECTION(image_type) __used \
- __cat(image_type_ptr_, _id) = &__cat(image_type_, _id)
- #endif
|