image.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * (C) Copyright 2008 Semihalf
  3. *
  4. * (C) Copyright 2000-2005
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. *
  25. ********************************************************************
  26. * NOTE: This header file defines an interface to U-Boot. Including
  27. * this (unmodified) header file in another file is considered normal
  28. * use of U-Boot, and does *not* fall under the heading of "derived
  29. * work".
  30. ********************************************************************
  31. */
  32. #ifndef __IMAGE_H__
  33. #define __IMAGE_H__
  34. #if USE_HOSTCC
  35. #include <endian.h>
  36. /* new uImage format support enabled on host */
  37. #define CONFIG_FIT 1
  38. #define CONFIG_OF_LIBFDT 1
  39. #define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
  40. #else
  41. #include <lmb.h>
  42. #include <linux/string.h>
  43. #include <asm/u-boot.h>
  44. #include <asm/byteorder.h>
  45. #endif /* USE_HOSTCC */
  46. #if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT)
  47. #error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!"
  48. #endif
  49. #include <command.h>
  50. #if defined(CONFIG_FIT)
  51. #include <fdt.h>
  52. #include <libfdt.h>
  53. #include <fdt_support.h>
  54. #define CONFIG_MD5 /* FIT images need MD5 support */
  55. #endif
  56. /*
  57. * Operating System Codes
  58. */
  59. #define IH_OS_INVALID 0 /* Invalid OS */
  60. #define IH_OS_OPENBSD 1 /* OpenBSD */
  61. #define IH_OS_NETBSD 2 /* NetBSD */
  62. #define IH_OS_FREEBSD 3 /* FreeBSD */
  63. #define IH_OS_4_4BSD 4 /* 4.4BSD */
  64. #define IH_OS_LINUX 5 /* Linux */
  65. #define IH_OS_SVR4 6 /* SVR4 */
  66. #define IH_OS_ESIX 7 /* Esix */
  67. #define IH_OS_SOLARIS 8 /* Solaris */
  68. #define IH_OS_IRIX 9 /* Irix */
  69. #define IH_OS_SCO 10 /* SCO */
  70. #define IH_OS_DELL 11 /* Dell */
  71. #define IH_OS_NCR 12 /* NCR */
  72. #define IH_OS_LYNXOS 13 /* LynxOS */
  73. #define IH_OS_VXWORKS 14 /* VxWorks */
  74. #define IH_OS_PSOS 15 /* pSOS */
  75. #define IH_OS_QNX 16 /* QNX */
  76. #define IH_OS_U_BOOT 17 /* Firmware */
  77. #define IH_OS_RTEMS 18 /* RTEMS */
  78. #define IH_OS_ARTOS 19 /* ARTOS */
  79. #define IH_OS_UNITY 20 /* Unity OS */
  80. #define IH_OS_INTEGRITY 21 /* INTEGRITY */
  81. /*
  82. * CPU Architecture Codes (supported by Linux)
  83. */
  84. #define IH_ARCH_INVALID 0 /* Invalid CPU */
  85. #define IH_ARCH_ALPHA 1 /* Alpha */
  86. #define IH_ARCH_ARM 2 /* ARM */
  87. #define IH_ARCH_I386 3 /* Intel x86 */
  88. #define IH_ARCH_IA64 4 /* IA64 */
  89. #define IH_ARCH_MIPS 5 /* MIPS */
  90. #define IH_ARCH_MIPS64 6 /* MIPS 64 Bit */
  91. #define IH_ARCH_PPC 7 /* PowerPC */
  92. #define IH_ARCH_S390 8 /* IBM S390 */
  93. #define IH_ARCH_SH 9 /* SuperH */
  94. #define IH_ARCH_SPARC 10 /* Sparc */
  95. #define IH_ARCH_SPARC64 11 /* Sparc 64 Bit */
  96. #define IH_ARCH_M68K 12 /* M68K */
  97. #define IH_ARCH_NIOS 13 /* Nios-32 */
  98. #define IH_ARCH_MICROBLAZE 14 /* MicroBlaze */
  99. #define IH_ARCH_NIOS2 15 /* Nios-II */
  100. #define IH_ARCH_BLACKFIN 16 /* Blackfin */
  101. #define IH_ARCH_AVR32 17 /* AVR32 */
  102. #define IH_ARCH_ST200 18 /* STMicroelectronics ST200 */
  103. /*
  104. * Image Types
  105. *
  106. * "Standalone Programs" are directly runnable in the environment
  107. * provided by U-Boot; it is expected that (if they behave
  108. * well) you can continue to work in U-Boot after return from
  109. * the Standalone Program.
  110. * "OS Kernel Images" are usually images of some Embedded OS which
  111. * will take over control completely. Usually these programs
  112. * will install their own set of exception handlers, device
  113. * drivers, set up the MMU, etc. - this means, that you cannot
  114. * expect to re-enter U-Boot except by resetting the CPU.
  115. * "RAMDisk Images" are more or less just data blocks, and their
  116. * parameters (address, size) are passed to an OS kernel that is
  117. * being started.
  118. * "Multi-File Images" contain several images, typically an OS
  119. * (Linux) kernel image and one or more data images like
  120. * RAMDisks. This construct is useful for instance when you want
  121. * to boot over the network using BOOTP etc., where the boot
  122. * server provides just a single image file, but you want to get
  123. * for instance an OS kernel and a RAMDisk image.
  124. *
  125. * "Multi-File Images" start with a list of image sizes, each
  126. * image size (in bytes) specified by an "uint32_t" in network
  127. * byte order. This list is terminated by an "(uint32_t)0".
  128. * Immediately after the terminating 0 follow the images, one by
  129. * one, all aligned on "uint32_t" boundaries (size rounded up to
  130. * a multiple of 4 bytes - except for the last file).
  131. *
  132. * "Firmware Images" are binary images containing firmware (like
  133. * U-Boot or FPGA images) which usually will be programmed to
  134. * flash memory.
  135. *
  136. * "Script files" are command sequences that will be executed by
  137. * U-Boot's command interpreter; this feature is especially
  138. * useful when you configure U-Boot to use a real shell (hush)
  139. * as command interpreter (=> Shell Scripts).
  140. */
  141. #define IH_TYPE_INVALID 0 /* Invalid Image */
  142. #define IH_TYPE_STANDALONE 1 /* Standalone Program */
  143. #define IH_TYPE_KERNEL 2 /* OS Kernel Image */
  144. #define IH_TYPE_RAMDISK 3 /* RAMDisk Image */
  145. #define IH_TYPE_MULTI 4 /* Multi-File Image */
  146. #define IH_TYPE_FIRMWARE 5 /* Firmware Image */
  147. #define IH_TYPE_SCRIPT 6 /* Script file */
  148. #define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */
  149. #define IH_TYPE_FLATDT 8 /* Binary Flat Device Tree Blob */
  150. /*
  151. * Compression Types
  152. */
  153. #define IH_COMP_NONE 0 /* No Compression Used */
  154. #define IH_COMP_GZIP 1 /* gzip Compression Used */
  155. #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
  156. #define IH_COMP_LZMA 3 /* lzma Compression Used */
  157. #define IH_MAGIC 0x27051956 /* Image Magic Number */
  158. #define IH_NMLEN 32 /* Image Name Length */
  159. /*
  160. * Legacy format image header,
  161. * all data in network byte order (aka natural aka bigendian).
  162. */
  163. typedef struct image_header {
  164. uint32_t ih_magic; /* Image Header Magic Number */
  165. uint32_t ih_hcrc; /* Image Header CRC Checksum */
  166. uint32_t ih_time; /* Image Creation Timestamp */
  167. uint32_t ih_size; /* Image Data Size */
  168. uint32_t ih_load; /* Data Load Address */
  169. uint32_t ih_ep; /* Entry Point Address */
  170. uint32_t ih_dcrc; /* Image Data CRC Checksum */
  171. uint8_t ih_os; /* Operating System */
  172. uint8_t ih_arch; /* CPU architecture */
  173. uint8_t ih_type; /* Image Type */
  174. uint8_t ih_comp; /* Compression Type */
  175. uint8_t ih_name[IH_NMLEN]; /* Image Name */
  176. } image_header_t;
  177. typedef struct image_info {
  178. ulong start, end; /* start/end of blob */
  179. ulong image_start, image_len; /* start of image within blob, len of image */
  180. ulong load; /* load addr for the image */
  181. uint8_t comp, type, os; /* compression, type of image, os type */
  182. } image_info_t;
  183. /*
  184. * Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()
  185. * routines.
  186. */
  187. typedef struct bootm_headers {
  188. /*
  189. * Legacy os image header, if it is a multi component image
  190. * then boot_get_ramdisk() and get_fdt() will attempt to get
  191. * data from second and third component accordingly.
  192. */
  193. image_header_t *legacy_hdr_os; /* image header pointer */
  194. image_header_t legacy_hdr_os_copy; /* header copy */
  195. ulong legacy_hdr_valid;
  196. #if defined(CONFIG_FIT)
  197. const char *fit_uname_cfg; /* configuration node unit name */
  198. void *fit_hdr_os; /* os FIT image header */
  199. const char *fit_uname_os; /* os subimage node unit name */
  200. int fit_noffset_os; /* os subimage node offset */
  201. void *fit_hdr_rd; /* init ramdisk FIT image header */
  202. const char *fit_uname_rd; /* init ramdisk subimage node unit name */
  203. int fit_noffset_rd; /* init ramdisk subimage node offset */
  204. #if defined(CONFIG_PPC)
  205. void *fit_hdr_fdt; /* FDT blob FIT image header */
  206. const char *fit_uname_fdt; /* FDT blob subimage node unit name */
  207. int fit_noffset_fdt;/* FDT blob subimage node offset */
  208. #endif
  209. #endif
  210. image_info_t os; /* os image info */
  211. ulong ep; /* entry point of OS */
  212. ulong rd_start, rd_end;/* ramdisk start/end */
  213. #ifdef CONFIG_OF_LIBFDT
  214. char *ft_addr; /* flat dev tree address */
  215. #endif
  216. ulong ft_len; /* length of flat device tree */
  217. int verify; /* getenv("verify")[0] != 'n' */
  218. int valid; /* set to 1 if we've set values in the header */
  219. #ifndef USE_HOSTCC
  220. struct lmb lmb; /* for memory mgmt */
  221. #endif
  222. } bootm_headers_t;
  223. /*
  224. * Some systems (for example LWMON) have very short watchdog periods;
  225. * we must make sure to split long operations like memmove() or
  226. * checksum calculations into reasonable chunks.
  227. */
  228. #ifndef CHUNKSZ
  229. #define CHUNKSZ (64 * 1024)
  230. #endif
  231. #ifndef CHUNKSZ_CRC32
  232. #define CHUNKSZ_CRC32 (64 * 1024)
  233. #endif
  234. #ifndef CHUNKSZ_MD5
  235. #define CHUNKSZ_MD5 (64 * 1024)
  236. #endif
  237. #ifndef CHUNKSZ_SHA1
  238. #define CHUNKSZ_SHA1 (64 * 1024)
  239. #endif
  240. #define uimage_to_cpu(x) ntohl(x)
  241. #define cpu_to_uimage(x) htonl(x)
  242. const char *genimg_get_os_name (uint8_t os);
  243. const char *genimg_get_arch_name (uint8_t arch);
  244. const char *genimg_get_type_name (uint8_t type);
  245. const char *genimg_get_comp_name (uint8_t comp);
  246. int genimg_get_os_id (const char *name);
  247. int genimg_get_arch_id (const char *name);
  248. int genimg_get_type_id (const char *name);
  249. int genimg_get_comp_id (const char *name);
  250. #ifndef USE_HOSTCC
  251. /* Image format types, returned by _get_format() routine */
  252. #define IMAGE_FORMAT_INVALID 0x00
  253. #define IMAGE_FORMAT_LEGACY 0x01 /* legacy image_header based format */
  254. #define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */
  255. int genimg_get_format (void *img_addr);
  256. int genimg_has_config (bootm_headers_t *images);
  257. ulong genimg_get_image (ulong img_addr);
  258. int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
  259. uint8_t arch, ulong *rd_start, ulong *rd_end);
  260. #ifdef CONFIG_OF_LIBFDT
  261. int boot_get_fdt (int flag, int argc, char *argv[], bootm_headers_t *images,
  262. char **of_flat_tree, ulong *of_size);
  263. int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,
  264. char **of_flat_tree, ulong *of_size);
  265. #endif
  266. #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
  267. int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
  268. ulong *initrd_start, ulong *initrd_end);
  269. int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
  270. ulong bootmap_base);
  271. int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base);
  272. #endif /* CONFIG_PPC || CONFIG_M68K */
  273. #endif /* !USE_HOSTCC */
  274. /*******************************************************************/
  275. /* Legacy format specific code (prefixed with image_) */
  276. /*******************************************************************/
  277. static inline uint32_t image_get_header_size (void)
  278. {
  279. return (sizeof (image_header_t));
  280. }
  281. #define image_get_hdr_l(f) \
  282. static inline uint32_t image_get_##f(image_header_t *hdr) \
  283. { \
  284. return uimage_to_cpu (hdr->ih_##f); \
  285. }
  286. image_get_hdr_l (magic);
  287. image_get_hdr_l (hcrc);
  288. image_get_hdr_l (time);
  289. image_get_hdr_l (size);
  290. image_get_hdr_l (load);
  291. image_get_hdr_l (ep);
  292. image_get_hdr_l (dcrc);
  293. #define image_get_hdr_b(f) \
  294. static inline uint8_t image_get_##f(image_header_t *hdr) \
  295. { \
  296. return hdr->ih_##f; \
  297. }
  298. image_get_hdr_b (os);
  299. image_get_hdr_b (arch);
  300. image_get_hdr_b (type);
  301. image_get_hdr_b (comp);
  302. static inline char *image_get_name (image_header_t *hdr)
  303. {
  304. return (char *)hdr->ih_name;
  305. }
  306. static inline uint32_t image_get_data_size (image_header_t *hdr)
  307. {
  308. return image_get_size (hdr);
  309. }
  310. /**
  311. * image_get_data - get image payload start address
  312. * @hdr: image header
  313. *
  314. * image_get_data() returns address of the image payload. For single
  315. * component images it is image data start. For multi component
  316. * images it points to the null terminated table of sub-images sizes.
  317. *
  318. * returns:
  319. * image payload data start address
  320. */
  321. static inline ulong image_get_data (image_header_t *hdr)
  322. {
  323. return ((ulong)hdr + image_get_header_size ());
  324. }
  325. static inline uint32_t image_get_image_size (image_header_t *hdr)
  326. {
  327. return (image_get_size (hdr) + image_get_header_size ());
  328. }
  329. static inline ulong image_get_image_end (image_header_t *hdr)
  330. {
  331. return ((ulong)hdr + image_get_image_size (hdr));
  332. }
  333. #define image_set_hdr_l(f) \
  334. static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
  335. { \
  336. hdr->ih_##f = cpu_to_uimage (val); \
  337. }
  338. image_set_hdr_l (magic);
  339. image_set_hdr_l (hcrc);
  340. image_set_hdr_l (time);
  341. image_set_hdr_l (size);
  342. image_set_hdr_l (load);
  343. image_set_hdr_l (ep);
  344. image_set_hdr_l (dcrc);
  345. #define image_set_hdr_b(f) \
  346. static inline void image_set_##f(image_header_t *hdr, uint8_t val) \
  347. { \
  348. hdr->ih_##f = val; \
  349. }
  350. image_set_hdr_b (os);
  351. image_set_hdr_b (arch);
  352. image_set_hdr_b (type);
  353. image_set_hdr_b (comp);
  354. static inline void image_set_name (image_header_t *hdr, const char *name)
  355. {
  356. strncpy (image_get_name (hdr), name, IH_NMLEN);
  357. }
  358. int image_check_hcrc (image_header_t *hdr);
  359. int image_check_dcrc (image_header_t *hdr);
  360. #ifndef USE_HOSTCC
  361. int getenv_yesno (char *var);
  362. ulong getenv_bootm_low(void);
  363. phys_size_t getenv_bootm_size(void);
  364. void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
  365. #endif
  366. static inline int image_check_magic (image_header_t *hdr)
  367. {
  368. return (image_get_magic (hdr) == IH_MAGIC);
  369. }
  370. static inline int image_check_type (image_header_t *hdr, uint8_t type)
  371. {
  372. return (image_get_type (hdr) == type);
  373. }
  374. static inline int image_check_arch (image_header_t *hdr, uint8_t arch)
  375. {
  376. return (image_get_arch (hdr) == arch);
  377. }
  378. static inline int image_check_os (image_header_t *hdr, uint8_t os)
  379. {
  380. return (image_get_os (hdr) == os);
  381. }
  382. ulong image_multi_count (image_header_t *hdr);
  383. void image_multi_getimg (image_header_t *hdr, ulong idx,
  384. ulong *data, ulong *len);
  385. void image_print_contents (image_header_t *hdr);
  386. #ifndef USE_HOSTCC
  387. static inline int image_check_target_arch (image_header_t *hdr)
  388. {
  389. #if defined(__ARM__)
  390. if (!image_check_arch (hdr, IH_ARCH_ARM))
  391. #elif defined(__avr32__)
  392. if (!image_check_arch (hdr, IH_ARCH_AVR32))
  393. #elif defined(__bfin__)
  394. if (!image_check_arch (hdr, IH_ARCH_BLACKFIN))
  395. #elif defined(__I386__)
  396. if (!image_check_arch (hdr, IH_ARCH_I386))
  397. #elif defined(__M68K__)
  398. if (!image_check_arch (hdr, IH_ARCH_M68K))
  399. #elif defined(__microblaze__)
  400. if (!image_check_arch (hdr, IH_ARCH_MICROBLAZE))
  401. #elif defined(__mips__)
  402. if (!image_check_arch (hdr, IH_ARCH_MIPS))
  403. #elif defined(__nios__)
  404. if (!image_check_arch (hdr, IH_ARCH_NIOS))
  405. #elif defined(__nios2__)
  406. if (!image_check_arch (hdr, IH_ARCH_NIOS2))
  407. #elif defined(__PPC__)
  408. if (!image_check_arch (hdr, IH_ARCH_PPC))
  409. #elif defined(__sh__)
  410. if (!image_check_arch (hdr, IH_ARCH_SH))
  411. #elif defined(__sparc__)
  412. if (!image_check_arch (hdr, IH_ARCH_SPARC))
  413. #else
  414. # error Unknown CPU type
  415. #endif
  416. return 0;
  417. return 1;
  418. }
  419. #endif /* USE_HOSTCC */
  420. /*******************************************************************/
  421. /* New uImage format specific code (prefixed with fit_) */
  422. /*******************************************************************/
  423. #if defined(CONFIG_FIT)
  424. #define FIT_IMAGES_PATH "/images"
  425. #define FIT_CONFS_PATH "/configurations"
  426. /* hash node */
  427. #define FIT_HASH_NODENAME "hash"
  428. #define FIT_ALGO_PROP "algo"
  429. #define FIT_VALUE_PROP "value"
  430. /* image node */
  431. #define FIT_DATA_PROP "data"
  432. #define FIT_TIMESTAMP_PROP "timestamp"
  433. #define FIT_DESC_PROP "description"
  434. #define FIT_ARCH_PROP "arch"
  435. #define FIT_TYPE_PROP "type"
  436. #define FIT_OS_PROP "os"
  437. #define FIT_COMP_PROP "compression"
  438. #define FIT_ENTRY_PROP "entry"
  439. #define FIT_LOAD_PROP "load"
  440. /* configuration node */
  441. #define FIT_KERNEL_PROP "kernel"
  442. #define FIT_RAMDISK_PROP "ramdisk"
  443. #define FIT_FDT_PROP "fdt"
  444. #define FIT_DEFAULT_PROP "default"
  445. #define FIT_MAX_HASH_LEN 20 /* max(crc32_len(4), sha1_len(20)) */
  446. /* cmdline argument format parsing */
  447. inline int fit_parse_conf (const char *spec, ulong addr_curr,
  448. ulong *addr, const char **conf_name);
  449. inline int fit_parse_subimage (const char *spec, ulong addr_curr,
  450. ulong *addr, const char **image_name);
  451. void fit_print_contents (const void *fit);
  452. void fit_image_print (const void *fit, int noffset, const char *p);
  453. void fit_image_print_hash (const void *fit, int noffset, const char *p);
  454. /**
  455. * fit_get_end - get FIT image size
  456. * @fit: pointer to the FIT format image header
  457. *
  458. * returns:
  459. * size of the FIT image (blob) in memory
  460. */
  461. static inline ulong fit_get_size (const void *fit)
  462. {
  463. return fdt_totalsize (fit);
  464. }
  465. /**
  466. * fit_get_end - get FIT image end
  467. * @fit: pointer to the FIT format image header
  468. *
  469. * returns:
  470. * end address of the FIT image (blob) in memory
  471. */
  472. static inline ulong fit_get_end (const void *fit)
  473. {
  474. return (ulong)fit + fdt_totalsize (fit);
  475. }
  476. /**
  477. * fit_get_name - get FIT node name
  478. * @fit: pointer to the FIT format image header
  479. *
  480. * returns:
  481. * NULL, on error
  482. * pointer to node name, on success
  483. */
  484. static inline const char *fit_get_name (const void *fit_hdr,
  485. int noffset, int *len)
  486. {
  487. return fdt_get_name (fit_hdr, noffset, len);
  488. }
  489. int fit_get_desc (const void *fit, int noffset, char **desc);
  490. int fit_get_timestamp (const void *fit, int noffset, time_t *timestamp);
  491. int fit_image_get_node (const void *fit, const char *image_uname);
  492. int fit_image_get_os (const void *fit, int noffset, uint8_t *os);
  493. int fit_image_get_arch (const void *fit, int noffset, uint8_t *arch);
  494. int fit_image_get_type (const void *fit, int noffset, uint8_t *type);
  495. int fit_image_get_comp (const void *fit, int noffset, uint8_t *comp);
  496. int fit_image_get_load (const void *fit, int noffset, ulong *load);
  497. int fit_image_get_entry (const void *fit, int noffset, ulong *entry);
  498. int fit_image_get_data (const void *fit, int noffset,
  499. const void **data, size_t *size);
  500. int fit_image_hash_get_algo (const void *fit, int noffset, char **algo);
  501. int fit_image_hash_get_value (const void *fit, int noffset, uint8_t **value,
  502. int *value_len);
  503. int fit_set_timestamp (void *fit, int noffset, time_t timestamp);
  504. int fit_set_hashes (void *fit);
  505. int fit_image_set_hashes (void *fit, int image_noffset);
  506. int fit_image_hash_set_value (void *fit, int noffset, uint8_t *value,
  507. int value_len);
  508. int fit_image_check_hashes (const void *fit, int noffset);
  509. int fit_all_image_check_hashes (const void *fit);
  510. int fit_image_check_os (const void *fit, int noffset, uint8_t os);
  511. int fit_image_check_arch (const void *fit, int noffset, uint8_t arch);
  512. int fit_image_check_type (const void *fit, int noffset, uint8_t type);
  513. int fit_image_check_comp (const void *fit, int noffset, uint8_t comp);
  514. int fit_check_format (const void *fit);
  515. int fit_conf_get_node (const void *fit, const char *conf_uname);
  516. int fit_conf_get_kernel_node (const void *fit, int noffset);
  517. int fit_conf_get_ramdisk_node (const void *fit, int noffset);
  518. int fit_conf_get_fdt_node (const void *fit, int noffset);
  519. void fit_conf_print (const void *fit, int noffset, const char *p);
  520. #ifndef USE_HOSTCC
  521. static inline int fit_image_check_target_arch (const void *fdt, int node)
  522. {
  523. #if defined(__ARM__)
  524. if (!fit_image_check_arch (fdt, node, IH_ARCH_ARM))
  525. #elif defined(__avr32__)
  526. if (!fit_image_check_arch (fdt, node, IH_ARCH_AVR32))
  527. #elif defined(__bfin__)
  528. if (!fit_image_check_arch (fdt, node, IH_ARCH_BLACKFIN))
  529. #elif defined(__I386__)
  530. if (!fit_image_check_arch (fdt, node, IH_ARCH_I386))
  531. #elif defined(__M68K__)
  532. if (!fit_image_check_arch (fdt, node, IH_ARCH_M68K))
  533. #elif defined(__microblaze__)
  534. if (!fit_image_check_arch (fdt, node, IH_ARCH_MICROBLAZE))
  535. #elif defined(__mips__)
  536. if (!fit_image_check_arch (fdt, node, IH_ARCH_MIPS))
  537. #elif defined(__nios__)
  538. if (!fit_image_check_arch (fdt, node, IH_ARCH_NIOS))
  539. #elif defined(__nios2__)
  540. if (!fit_image_check_arch (fdt, node, IH_ARCH_NIOS2))
  541. #elif defined(__PPC__)
  542. if (!fit_image_check_arch (fdt, node, IH_ARCH_PPC))
  543. #elif defined(__sh__)
  544. if (!fit_image_check_arch (fdt, node, IH_ARCH_SH))
  545. #elif defined(__sparc__)
  546. if (!fit_image_check_arch (fdt, node, IH_ARCH_SPARC))
  547. #else
  548. # error Unknown CPU type
  549. #endif
  550. return 0;
  551. return 1;
  552. }
  553. #endif /* USE_HOSTCC */
  554. #ifdef CONFIG_FIT_VERBOSE
  555. #define fit_unsupported(msg) printf ("! %s:%d " \
  556. "FIT images not supported for '%s'\n", \
  557. __FILE__, __LINE__, (msg))
  558. #define fit_unsupported_reset(msg) printf ("! %s:%d " \
  559. "FIT images not supported for '%s' " \
  560. "- must reset board to recover!\n", \
  561. __FILE__, __LINE__, (msg))
  562. #else
  563. #define fit_unsupported(msg)
  564. #define fit_unsupported_reset(msg)
  565. #endif /* CONFIG_FIT_VERBOSE */
  566. #endif /* CONFIG_FIT */
  567. #endif /* __IMAGE_H__ */