image.h 19 KB

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