image.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __IMAGE_H__
  24. #define __IMAGE_H__
  25. /*
  26. * Operating System Codes
  27. */
  28. #define IH_OS_INVALID 0 /* Invalid OS */
  29. #define IH_OS_OPENBSD 1 /* OpenBSD */
  30. #define IH_OS_NETBSD 2 /* NetBSD */
  31. #define IH_OS_FREEBSD 3 /* FreeBSD */
  32. #define IH_OS_4_4BSD 4 /* 4.4BSD */
  33. #define IH_OS_LINUX 5 /* Linux */
  34. #define IH_OS_SVR4 6 /* SVR4 */
  35. #define IH_OS_ESIX 7 /* Esix */
  36. #define IH_OS_SOLARIS 8 /* Solaris */
  37. #define IH_OS_IRIX 9 /* Irix */
  38. #define IH_OS_SCO 10 /* SCO */
  39. #define IH_OS_DELL 11 /* Dell */
  40. #define IH_OS_NCR 12 /* NCR */
  41. #define IH_OS_LYNXOS 13 /* LynxOS */
  42. #define IH_OS_VXWORKS 14 /* VxWorks */
  43. #define IH_OS_PSOS 15 /* pSOS */
  44. #define IH_OS_QNX 16 /* QNX */
  45. #define IH_OS_U_BOOT 17 /* Firmware */
  46. #define IH_OS_RTEMS 18 /* RTEMS */
  47. #define IH_OS_ARTOS 19 /* ARTOS */
  48. /*
  49. * CPU Architecture Codes (supported by Linux)
  50. */
  51. #define IH_CPU_INVALID 0 /* Invalid CPU */
  52. #define IH_CPU_ALPHA 1 /* Alpha */
  53. #define IH_CPU_ARM 2 /* ARM */
  54. #define IH_CPU_I386 3 /* Intel x86 */
  55. #define IH_CPU_IA64 4 /* IA64 */
  56. #define IH_CPU_MIPS 5 /* MIPS */
  57. #define IH_CPU_MIPS64 6 /* MIPS 64 Bit */
  58. #define IH_CPU_PPC 7 /* PowerPC */
  59. #define IH_CPU_S390 8 /* IBM S390 */
  60. #define IH_CPU_SH 9 /* SuperH */
  61. #define IH_CPU_SPARC 10 /* Sparc */
  62. #define IH_CPU_SPARC64 11 /* Sparc 64 Bit */
  63. #define IH_CPU_M68K 12 /* M68K */
  64. /*
  65. * Image Types
  66. *
  67. * "Standalone Programs" are directly runnable in the environment
  68. * provided by U-Boot; it is expected that (if they behave
  69. * well) you can continue to work in U-Boot after return from
  70. * the Standalone Program.
  71. * "OS Kernel Images" are usually images of some Embedded OS which
  72. * will take over control completely. Usually these programs
  73. * will install their own set of exception handlers, device
  74. * drivers, set up the MMU, etc. - this means, that you cannot
  75. * expect to re-enter U-Boot except by resetting the CPU.
  76. * "RAMDisk Images" are more or less just data blocks, and their
  77. * parameters (address, size) are passed to an OS kernel that is
  78. * being started.
  79. * "Multi-File Images" contain several images, typically an OS
  80. * (Linux) kernel image and one or more data images like
  81. * RAMDisks. This construct is useful for instance when you want
  82. * to boot over the network using BOOTP etc., where the boot
  83. * server provides just a single image file, but you want to get
  84. * for instance an OS kernel and a RAMDisk image.
  85. *
  86. * "Multi-File Images" start with a list of image sizes, each
  87. * image size (in bytes) specified by an "uint32_t" in network
  88. * byte order. This list is terminated by an "(uint32_t)0".
  89. * Immediately after the terminating 0 follow the images, one by
  90. * one, all aligned on "uint32_t" boundaries (size rounded up to
  91. * a multiple of 4 bytes).
  92. *
  93. * "Firmware Images" are binary images containing firmware (like
  94. * U-Boot or FPGA images) which usually will be programmed to
  95. * flash memory.
  96. *
  97. * "Script files" are command sequences that will be executed by
  98. * U-Boot's command interpreter; this feature is especially
  99. * useful when you configure U-Boot to use a real shell (hush)
  100. * as command interpreter.
  101. */
  102. #define IH_TYPE_INVALID 0 /* Invalid Image */
  103. #define IH_TYPE_STANDALONE 1 /* Standalone Program */
  104. #define IH_TYPE_KERNEL 2 /* OS Kernel Image */
  105. #define IH_TYPE_RAMDISK 3 /* RAMDisk Image */
  106. #define IH_TYPE_MULTI 4 /* Multi-File Image */
  107. #define IH_TYPE_FIRMWARE 5 /* Firmware Image */
  108. #define IH_TYPE_SCRIPT 6 /* Script file */
  109. /*
  110. * Compression Types
  111. */
  112. #define IH_COMP_NONE 0 /* No Compression Used */
  113. #define IH_COMP_GZIP 1 /* gzip Compression Used */
  114. #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
  115. #define IH_MAGIC 0x27051956 /* Image Magic Number */
  116. #define IH_NMLEN 32 /* Image Name Length */
  117. #ifdef __CYGWIN__
  118. typedef unsigned long uint32_t;
  119. typedef unsigned char uint8_t;
  120. #endif /* __CYGWIN__ */
  121. /*
  122. * all data in network byte order (aka natural aka bigendian)
  123. */
  124. typedef struct image_header {
  125. uint32_t ih_magic; /* Image Header Magic Number */
  126. uint32_t ih_hcrc; /* Image Header CRC Checksum */
  127. uint32_t ih_time; /* Image Creation Timestamp */
  128. uint32_t ih_size; /* Image Data Size */
  129. uint32_t ih_load; /* Data Load Address */
  130. uint32_t ih_ep; /* Entry Point Address */
  131. uint32_t ih_dcrc; /* Image Data CRC Checksum */
  132. uint8_t ih_os; /* Operating System */
  133. uint8_t ih_arch; /* CPU architecture */
  134. uint8_t ih_type; /* Image Type */
  135. uint8_t ih_comp; /* Compression Type */
  136. uint8_t ih_name[IH_NMLEN]; /* Image Name */
  137. } image_header_t;
  138. #endif /* __IMAGE_H__ */