42 #define CONFIG_OF_LIBFDT 1
43 #define CONFIG_FIT_VERBOSE 1
53 #if defined(CONFIG_FIT)
56 #include <fdt_support.h>
64 #define IH_OS_INVALID 0
65 #define IH_OS_OPENBSD 1
66 #define IH_OS_NETBSD 2
67 #define IH_OS_FREEBSD 3
68 #define IH_OS_4_4BSD 4
72 #define IH_OS_SOLARIS 8
77 #define IH_OS_LYNXOS 13
78 #define IH_OS_VXWORKS 14
81 #define IH_OS_U_BOOT 17
82 #define IH_OS_RTEMS 18
83 #define IH_OS_ARTOS 19
84 #define IH_OS_UNITY 20
85 #define IH_OS_INTEGRITY 21
91 #define IH_ARCH_INVALID 0
92 #define IH_ARCH_ALPHA 1
94 #define IH_ARCH_I386 3
95 #define IH_ARCH_IA64 4
96 #define IH_ARCH_MIPS 5
97 #define IH_ARCH_MIPS64 6
99 #define IH_ARCH_S390 8
101 #define IH_ARCH_SPARC 10
102 #define IH_ARCH_SPARC64 11
103 #define IH_ARCH_M68K 12
104 #define IH_ARCH_MICROBLAZE 14
105 #define IH_ARCH_NIOS2 15
106 #define IH_ARCH_BLACKFIN 16
107 #define IH_ARCH_AVR32 17
108 #define IH_ARCH_ST200 18
109 #define IH_ARCH_SANDBOX 19
110 #define IH_ARCH_NDS32 20
111 #define IH_ARCH_OPENRISC 21
152 #define IH_TYPE_INVALID 0
153 #define IH_TYPE_STANDALONE 1
154 #define IH_TYPE_KERNEL 2
155 #define IH_TYPE_RAMDISK 3
156 #define IH_TYPE_MULTI 4
157 #define IH_TYPE_FIRMWARE 5
158 #define IH_TYPE_SCRIPT 6
159 #define IH_TYPE_FILESYSTEM 7
160 #define IH_TYPE_FLATDT 8
161 #define IH_TYPE_KWBIMAGE 9
162 #define IH_TYPE_IMXIMAGE 10
163 #define IH_TYPE_UBLIMAGE 11
164 #define IH_TYPE_OMAPIMAGE 12
165 #define IH_TYPE_AISIMAGE 13
166 #define IH_TYPE_KERNEL_NOLOAD 14
167 #define IH_TYPE_PBLIMAGE 15
172 #define IH_COMP_NONE 0
173 #define IH_COMP_GZIP 1
174 #define IH_COMP_BZIP2 2
175 #define IH_COMP_LZMA 3
176 #define IH_COMP_LZO 4
178 #define IH_MAGIC 0x27051956
221 #if defined(CONFIG_FIT)
222 const char *fit_uname_cfg;
225 const char *fit_uname_os;
229 const char *fit_uname_rd;
233 const char *fit_uname_fdt;
243 #ifdef CONFIG_OF_LIBFDT
257 #define BOOTM_STATE_START (0x00000001)
258 #define BOOTM_STATE_LOADOS (0x00000002)
259 #define BOOTM_STATE_RAMDISK (0x00000004)
260 #define BOOTM_STATE_FDT (0x00000008)
261 #define BOOTM_STATE_OS_CMDLINE (0x00000010)
262 #define BOOTM_STATE_OS_BD_T (0x00000020)
263 #define BOOTM_STATE_OS_PREP (0x00000040)
264 #define BOOTM_STATE_OS_GO (0x00000080)
280 #define CHUNKSZ (64 * 1024)
283 #ifndef CHUNKSZ_CRC32
284 #define CHUNKSZ_CRC32 (64 * 1024)
288 #define CHUNKSZ_MD5 (64 * 1024)
292 #define CHUNKSZ_SHA1 (64 * 1024)
295 #define uimage_to_cpu(x) be32_to_cpu(x)
296 #define cpu_to_uimage(x) cpu_to_be32(x)
314 const char *table_name,
const char *name);
334 #define IMAGE_FORMAT_INVALID 0x00
335 #define IMAGE_FORMAT_LEGACY 0x01
336 #define IMAGE_FORMAT_FIT 0x02
346 #ifdef CONFIG_OF_LIBFDT
347 int boot_get_fdt(
int flag,
int argc,
char *
const argv[],
349 void boot_fdt_add_mem_rsv_regions(
struct lmb *lmb,
void *fdt_blob);
350 int boot_relocate_fdt(
struct lmb *lmb,
char **of_flat_tree,
ulong *of_size);
353 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
354 int boot_ramdisk_high(
struct lmb *lmb,
ulong rd_data,
ulong rd_len,
357 #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
358 int boot_get_cmdline(
struct lmb *lmb,
ulong *cmd_start,
ulong *cmd_end);
360 #ifdef CONFIG_SYS_BOOT_GET_KBD
361 int boot_get_kbd(
struct lmb *lmb,
bd_t **kbd);
373 #define image_get_hdr_l(f) \
374 static inline uint32_t image_get_##f(const image_header_t *hdr) \
376 return uimage_to_cpu(hdr->ih_##f); \
386 #define image_get_hdr_b(f) \
387 static inline uint8_t image_get_##f(const image_header_t *hdr) \
389 return hdr->ih_##f; \
392 image_get_hdr_b(arch)
393 image_get_hdr_b(type)
394 image_get_hdr_b(comp)
398 return (
char *)hdr->ih_name;
403 return image_get_size(hdr);
431 #define image_set_hdr_l(f) \
432 static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
434 hdr->ih_##f = cpu_to_uimage(val); \
444 #define image_set_hdr_b(f) \
445 static inline void image_set_##f(image_header_t *hdr, uint8_t val) \
450 image_set_hdr_b(arch)
451 image_set_hdr_b(type)
452 image_set_hdr_b(comp)
454 static inline
void image_set_name(
image_header_t *hdr, const
char *name)
456 strncpy(image_get_name(hdr), name,
IH_NMLEN);
471 return (image_get_magic(hdr) ==
IH_MAGIC);
475 return (image_get_type(hdr) == type);
479 return (image_get_arch(hdr) == arch);
483 return (image_get_os(hdr) == os);
495 #ifndef IH_ARCH_DEFAULT
496 # error "please define IH_ARCH_DEFAULT in your arch asm/u-boot.h"
505 #if defined(CONFIG_FIT)
507 #define FIT_IMAGES_PATH "/images"
508 #define FIT_CONFS_PATH "/configurations"
511 #define FIT_HASH_NODENAME "hash"
512 #define FIT_ALGO_PROP "algo"
513 #define FIT_VALUE_PROP "value"
516 #define FIT_DATA_PROP "data"
517 #define FIT_TIMESTAMP_PROP "timestamp"
518 #define FIT_DESC_PROP "description"
519 #define FIT_ARCH_PROP "arch"
520 #define FIT_TYPE_PROP "type"
521 #define FIT_OS_PROP "os"
522 #define FIT_COMP_PROP "compression"
523 #define FIT_ENTRY_PROP "entry"
524 #define FIT_LOAD_PROP "load"
527 #define FIT_KERNEL_PROP "kernel"
528 #define FIT_RAMDISK_PROP "ramdisk"
529 #define FIT_FDT_PROP "fdt"
530 #define FIT_DEFAULT_PROP "default"
532 #define FIT_MAX_HASH_LEN 20
535 int fit_parse_conf(
const char *spec,
ulong addr_curr,
536 ulong *addr,
const char **conf_name);
537 int fit_parse_subimage(
const char *spec,
ulong addr_curr,
538 ulong *addr,
const char **image_name);
540 void fit_print_contents(
const void *fit);
541 void fit_image_print(
const void *fit,
int noffset,
const char *p);
542 void fit_image_print_hash(
const void *fit,
int noffset,
const char *p);
551 static inline ulong fit_get_size(
const void *fit)
553 return fdt_totalsize(fit);
563 static inline ulong fit_get_end(
const void *fit)
565 return (
ulong)fit + fdt_totalsize(fit);
576 static inline const char *fit_get_name(
const void *fit_hdr,
577 int noffset,
int *len)
579 return fdt_get_name(fit_hdr, noffset, len);
582 int fit_get_desc(
const void *fit,
int noffset,
char **desc);
583 int fit_get_timestamp(
const void *fit,
int noffset, time_t *timestamp);
585 int fit_image_get_node(
const void *fit,
const char *image_uname);
586 int fit_image_get_os(
const void *fit,
int noffset,
uint8_t *os);
587 int fit_image_get_arch(
const void *fit,
int noffset,
uint8_t *arch);
588 int fit_image_get_type(
const void *fit,
int noffset,
uint8_t *type);
589 int fit_image_get_comp(
const void *fit,
int noffset,
uint8_t *comp);
590 int fit_image_get_load(
const void *fit,
int noffset,
ulong *load);
591 int fit_image_get_entry(
const void *fit,
int noffset,
ulong *entry);
592 int fit_image_get_data(
const void *fit,
int noffset,
593 const void **data,
size_t *size);
595 int fit_image_hash_get_algo(
const void *fit,
int noffset,
char **algo);
596 int fit_image_hash_get_value(
const void *fit,
int noffset,
uint8_t **
value,
599 int fit_set_timestamp(
void *fit,
int noffset, time_t timestamp);
600 int fit_set_hashes(
void *fit);
601 int fit_image_set_hashes(
void *fit,
int image_noffset);
602 int fit_image_hash_set_value(
void *fit,
int noffset,
uint8_t *
value,
605 int fit_image_check_hashes(
const void *fit,
int noffset);
606 int fit_all_image_check_hashes(
const void *fit);
607 int fit_image_check_os(
const void *fit,
int noffset,
uint8_t os);
608 int fit_image_check_arch(
const void *fit,
int noffset,
uint8_t arch);
609 int fit_image_check_type(
const void *fit,
int noffset,
uint8_t type);
610 int fit_image_check_comp(
const void *fit,
int noffset,
uint8_t comp);
611 int fit_check_format(
const void *fit);
613 int fit_conf_get_node(
const void *fit,
const char *conf_uname);
614 int fit_conf_get_kernel_node(
const void *fit,
int noffset);
615 int fit_conf_get_ramdisk_node(
const void *fit,
int noffset);
616 int fit_conf_get_fdt_node(
const void *fit,
int noffset);
618 void fit_conf_print(
const void *fit,
int noffset,
const char *p);
621 static inline int fit_image_check_target_arch(
const void *fdt,
int node)
627 #ifdef CONFIG_FIT_VERBOSE
628 #define fit_unsupported(msg) printf("! %s:%d " \
629 "FIT images not supported for '%s'\n", \
630 __FILE__, __LINE__, (msg))
632 #define fit_unsupported_reset(msg) printf("! %s:%d " \
633 "FIT images not supported for '%s' " \
634 "- must reset board to recover!\n", \
635 __FILE__, __LINE__, (msg))
637 #define fit_unsupported(msg)
638 #define fit_unsupported_reset(msg)