image.h 20 KB

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