uboot_image.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2008 Semihalf
  4. *
  5. * (C) Copyright 2000-2005
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. ********************************************************************
  8. * NOTE: This header file defines an interface to U-Boot. Including
  9. * this (unmodified) header file in another file is considered normal
  10. * use of U-Boot, and does *not* fall under the heading of "derived
  11. * work".
  12. ********************************************************************
  13. */
  14. #ifndef UBOOT_IMAGE_H
  15. #define UBOOT_IMAGE_H
  16. /*
  17. * Operating System Codes
  18. *
  19. * The following are exposed to uImage header.
  20. * New IDs *MUST* be appended at the end of the list and *NEVER*
  21. * inserted for backward compatibility.
  22. */
  23. enum {
  24. IH_OS_INVALID = 0, /* Invalid OS */
  25. IH_OS_OPENBSD, /* OpenBSD */
  26. IH_OS_NETBSD, /* NetBSD */
  27. IH_OS_FREEBSD, /* FreeBSD */
  28. IH_OS_4_4BSD, /* 4.4BSD */
  29. IH_OS_LINUX, /* Linux */
  30. IH_OS_SVR4, /* SVR4 */
  31. IH_OS_ESIX, /* Esix */
  32. IH_OS_SOLARIS, /* Solaris */
  33. IH_OS_IRIX, /* Irix */
  34. IH_OS_SCO, /* SCO */
  35. IH_OS_DELL, /* Dell */
  36. IH_OS_NCR, /* NCR */
  37. IH_OS_LYNXOS, /* LynxOS */
  38. IH_OS_VXWORKS, /* VxWorks */
  39. IH_OS_PSOS, /* pSOS */
  40. IH_OS_QNX, /* QNX */
  41. IH_OS_U_BOOT, /* Firmware */
  42. IH_OS_RTEMS, /* RTEMS */
  43. IH_OS_ARTOS, /* ARTOS */
  44. IH_OS_UNITY, /* Unity OS */
  45. IH_OS_INTEGRITY, /* INTEGRITY */
  46. IH_OS_OSE, /* OSE */
  47. IH_OS_PLAN9, /* Plan 9 */
  48. IH_OS_OPENRTOS, /* OpenRTOS */
  49. IH_OS_ARM_TRUSTED_FIRMWARE, /* ARM Trusted Firmware */
  50. IH_OS_TEE, /* Trusted Execution Environment */
  51. IH_OS_OPENSBI, /* RISC-V OpenSBI */
  52. IH_OS_EFI, /* EFI Firmware (e.g. GRUB2) */
  53. IH_OS_COUNT,
  54. };
  55. /*
  56. * CPU Architecture Codes (supported by Linux)
  57. *
  58. * The following are exposed to uImage header.
  59. * New IDs *MUST* be appended at the end of the list and *NEVER*
  60. * inserted for backward compatibility.
  61. */
  62. enum {
  63. IH_ARCH_INVALID = 0, /* Invalid CPU */
  64. IH_ARCH_ALPHA, /* Alpha */
  65. IH_ARCH_ARM, /* ARM */
  66. IH_ARCH_I386, /* Intel x86 */
  67. IH_ARCH_IA64, /* IA64 */
  68. IH_ARCH_MIPS, /* MIPS */
  69. IH_ARCH_MIPS64, /* MIPS 64 Bit */
  70. IH_ARCH_PPC, /* PowerPC */
  71. IH_ARCH_S390, /* IBM S390 */
  72. IH_ARCH_SH, /* SuperH */
  73. IH_ARCH_SPARC, /* Sparc */
  74. IH_ARCH_SPARC64, /* Sparc 64 Bit */
  75. IH_ARCH_M68K, /* M68K */
  76. IH_ARCH_NIOS, /* Nios-32 */
  77. IH_ARCH_MICROBLAZE, /* MicroBlaze */
  78. IH_ARCH_NIOS2, /* Nios-II */
  79. IH_ARCH_BLACKFIN, /* Blackfin */
  80. IH_ARCH_AVR32, /* AVR32 */
  81. IH_ARCH_ST200, /* STMicroelectronics ST200 */
  82. IH_ARCH_SANDBOX, /* Sandbox architecture (test only) */
  83. IH_ARCH_NDS32, /* ANDES Technology - NDS32 */
  84. IH_ARCH_OPENRISC, /* OpenRISC 1000 */
  85. IH_ARCH_ARM64, /* ARM64 */
  86. IH_ARCH_ARC, /* Synopsys DesignWare ARC */
  87. IH_ARCH_X86_64, /* AMD x86_64, Intel and Via */
  88. IH_ARCH_XTENSA, /* Xtensa */
  89. IH_ARCH_RISCV, /* RISC-V */
  90. IH_ARCH_COUNT,
  91. };
  92. /*
  93. * Image Types
  94. *
  95. * "Standalone Programs" are directly runnable in the environment
  96. * provided by U-Boot; it is expected that (if they behave
  97. * well) you can continue to work in U-Boot after return from
  98. * the Standalone Program.
  99. * "OS Kernel Images" are usually images of some Embedded OS which
  100. * will take over control completely. Usually these programs
  101. * will install their own set of exception handlers, device
  102. * drivers, set up the MMU, etc. - this means, that you cannot
  103. * expect to re-enter U-Boot except by resetting the CPU.
  104. * "RAMDisk Images" are more or less just data blocks, and their
  105. * parameters (address, size) are passed to an OS kernel that is
  106. * being started.
  107. * "Multi-File Images" contain several images, typically an OS
  108. * (Linux) kernel image and one or more data images like
  109. * RAMDisks. This construct is useful for instance when you want
  110. * to boot over the network using BOOTP etc., where the boot
  111. * server provides just a single image file, but you want to get
  112. * for instance an OS kernel and a RAMDisk image.
  113. *
  114. * "Multi-File Images" start with a list of image sizes, each
  115. * image size (in bytes) specified by an "uint32_t" in network
  116. * byte order. This list is terminated by an "(uint32_t)0".
  117. * Immediately after the terminating 0 follow the images, one by
  118. * one, all aligned on "uint32_t" boundaries (size rounded up to
  119. * a multiple of 4 bytes - except for the last file).
  120. *
  121. * "Firmware Images" are binary images containing firmware (like
  122. * U-Boot or FPGA images) which usually will be programmed to
  123. * flash memory.
  124. *
  125. * "Script files" are command sequences that will be executed by
  126. * U-Boot's command interpreter; this feature is especially
  127. * useful when you configure U-Boot to use a real shell (hush)
  128. * as command interpreter (=> Shell Scripts).
  129. *
  130. * The following are exposed to uImage header.
  131. * New IDs *MUST* be appended at the end of the list and *NEVER*
  132. * inserted for backward compatibility.
  133. */
  134. enum {
  135. IH_TYPE_INVALID = 0, /* Invalid Image */
  136. IH_TYPE_STANDALONE, /* Standalone Program */
  137. IH_TYPE_KERNEL, /* OS Kernel Image */
  138. IH_TYPE_RAMDISK, /* RAMDisk Image */
  139. IH_TYPE_MULTI, /* Multi-File Image */
  140. IH_TYPE_FIRMWARE, /* Firmware Image */
  141. IH_TYPE_SCRIPT, /* Script file */
  142. IH_TYPE_FILESYSTEM, /* Filesystem Image (any type) */
  143. IH_TYPE_FLATDT, /* Binary Flat Device Tree Blob */
  144. IH_TYPE_KWBIMAGE, /* Kirkwood Boot Image */
  145. IH_TYPE_IMXIMAGE, /* Freescale IMXBoot Image */
  146. IH_TYPE_UBLIMAGE, /* Davinci UBL Image */
  147. IH_TYPE_OMAPIMAGE, /* TI OMAP Config Header Image */
  148. IH_TYPE_AISIMAGE, /* TI Davinci AIS Image */
  149. /* OS Kernel Image, can run from any load address */
  150. IH_TYPE_KERNEL_NOLOAD,
  151. IH_TYPE_PBLIMAGE, /* Freescale PBL Boot Image */
  152. IH_TYPE_MXSIMAGE, /* Freescale MXSBoot Image */
  153. IH_TYPE_GPIMAGE, /* TI Keystone GPHeader Image */
  154. IH_TYPE_ATMELIMAGE, /* ATMEL ROM bootable Image */
  155. IH_TYPE_SOCFPGAIMAGE, /* Altera SOCFPGA CV/AV Preloader */
  156. IH_TYPE_X86_SETUP, /* x86 setup.bin Image */
  157. IH_TYPE_LPC32XXIMAGE, /* x86 setup.bin Image */
  158. IH_TYPE_LOADABLE, /* A list of typeless images */
  159. IH_TYPE_RKIMAGE, /* Rockchip Boot Image */
  160. IH_TYPE_RKSD, /* Rockchip SD card */
  161. IH_TYPE_RKSPI, /* Rockchip SPI image */
  162. IH_TYPE_ZYNQIMAGE, /* Xilinx Zynq Boot Image */
  163. IH_TYPE_ZYNQMPIMAGE, /* Xilinx ZynqMP Boot Image */
  164. IH_TYPE_ZYNQMPBIF, /* Xilinx ZynqMP Boot Image (bif) */
  165. IH_TYPE_FPGA, /* FPGA Image */
  166. IH_TYPE_VYBRIDIMAGE, /* VYBRID .vyb Image */
  167. IH_TYPE_TEE, /* Trusted Execution Environment OS Image */
  168. IH_TYPE_FIRMWARE_IVT, /* Firmware Image with HABv4 IVT */
  169. IH_TYPE_PMMC, /* TI Power Management Micro-Controller Firmware */
  170. IH_TYPE_STM32IMAGE, /* STMicroelectronics STM32 Image */
  171. IH_TYPE_SOCFPGAIMAGE_V1, /* Altera SOCFPGA A10 Preloader */
  172. IH_TYPE_MTKIMAGE, /* MediaTek BootROM loadable Image */
  173. IH_TYPE_IMX8MIMAGE, /* Freescale IMX8MBoot Image */
  174. IH_TYPE_IMX8IMAGE, /* Freescale IMX8Boot Image */
  175. IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/
  176. IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */
  177. IH_TYPE_COUNT, /* Number of image types */
  178. };
  179. /*
  180. * Compression Types
  181. *
  182. * The following are exposed to uImage header.
  183. * New IDs *MUST* be appended at the end of the list and *NEVER*
  184. * inserted for backward compatibility.
  185. */
  186. enum {
  187. IH_COMP_NONE = 0, /* No Compression Used */
  188. IH_COMP_GZIP, /* gzip Compression Used */
  189. IH_COMP_BZIP2, /* bzip2 Compression Used */
  190. IH_COMP_LZMA, /* lzma Compression Used */
  191. IH_COMP_LZO, /* lzo Compression Used */
  192. IH_COMP_LZ4, /* lz4 Compression Used */
  193. IH_COMP_ZSTD, /* zstd Compression Used */
  194. IH_COMP_COUNT,
  195. };
  196. #define IH_MAGIC 0x27051956 /* Image Magic Number */
  197. #define IH_NMLEN 32 /* Image Name Length */
  198. /*
  199. * Legacy format image header,
  200. * all data in network byte order (aka natural aka bigendian).
  201. */
  202. typedef struct uboot_image_header {
  203. uint32_t ih_magic; /* Image Header Magic Number */
  204. uint32_t ih_hcrc; /* Image Header CRC Checksum */
  205. uint32_t ih_time; /* Image Creation Timestamp */
  206. uint32_t ih_size; /* Image Data Size */
  207. uint32_t ih_load; /* Data Load Address */
  208. uint32_t ih_ep; /* Entry Point Address */
  209. uint32_t ih_dcrc; /* Image Data CRC Checksum */
  210. uint8_t ih_os; /* Operating System */
  211. uint8_t ih_arch; /* CPU architecture */
  212. uint8_t ih_type; /* Image Type */
  213. uint8_t ih_comp; /* Compression Type */
  214. uint8_t ih_name[IH_NMLEN]; /* Image Name */
  215. } uboot_image_header_t;
  216. #endif /* UBOOT_IMAGE_H */