imximage.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * (C) Copyright 2009
  3. * Stefano Babic, DENX Software Engineering, sbabic@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 _IMXIMAGE_H_
  24. #define _IMXIMAGE_H_
  25. #define MAX_HW_CFG_SIZE_V2 121 /* Max number of registers imx can set for v2 */
  26. #define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */
  27. #define APP_CODE_BARKER 0xB1
  28. #define DCD_BARKER 0xB17219E9
  29. #define HEADER_OFFSET 0x400
  30. #define CMD_DATA_STR "DATA"
  31. #define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF
  32. #define FLASH_OFFSET_STANDARD 0x400
  33. #define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
  34. #define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD
  35. #define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD
  36. #define FLASH_OFFSET_ONENAND 0x100
  37. #define FLASH_OFFSET_NOR 0x1000
  38. #define FLASH_OFFSET_SATA FLASH_OFFSET_STANDARD
  39. #define IVT_HEADER_TAG 0xD1
  40. #define IVT_VERSION 0x40
  41. #define DCD_HEADER_TAG 0xD2
  42. #define DCD_COMMAND_TAG 0xCC
  43. #define DCD_VERSION 0x40
  44. #define DCD_COMMAND_PARAM 0x4
  45. enum imximage_cmd {
  46. CMD_INVALID,
  47. CMD_IMAGE_VERSION,
  48. CMD_BOOT_FROM,
  49. CMD_DATA
  50. };
  51. enum imximage_fld_types {
  52. CFG_INVALID = -1,
  53. CFG_COMMAND,
  54. CFG_REG_SIZE,
  55. CFG_REG_ADDRESS,
  56. CFG_REG_VALUE
  57. };
  58. enum imximage_version {
  59. IMXIMAGE_VER_INVALID = -1,
  60. IMXIMAGE_V1 = 1,
  61. IMXIMAGE_V2
  62. };
  63. typedef struct {
  64. uint32_t type; /* Type of pointer (byte, halfword, word, wait/read) */
  65. uint32_t addr; /* Address to write to */
  66. uint32_t value; /* Data to write */
  67. } dcd_type_addr_data_t;
  68. typedef struct {
  69. uint32_t barker; /* Barker for sanity check */
  70. uint32_t length; /* Device configuration length (without preamble) */
  71. } dcd_preamble_t;
  72. typedef struct {
  73. dcd_preamble_t preamble;
  74. dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1];
  75. } dcd_v1_t;
  76. typedef struct {
  77. uint32_t app_code_jump_vector;
  78. uint32_t app_code_barker;
  79. uint32_t app_code_csf;
  80. uint32_t dcd_ptr_ptr;
  81. uint32_t super_root_key;
  82. uint32_t dcd_ptr;
  83. uint32_t app_dest_ptr;
  84. } flash_header_v1_t;
  85. typedef struct {
  86. uint32_t length; /* Length of data to be read from flash */
  87. } flash_cfg_parms_t;
  88. typedef struct {
  89. flash_header_v1_t fhdr;
  90. dcd_v1_t dcd_table;
  91. flash_cfg_parms_t ext_header;
  92. } imx_header_v1_t;
  93. typedef struct {
  94. uint32_t addr;
  95. uint32_t value;
  96. } dcd_addr_data_t;
  97. typedef struct {
  98. uint8_t tag;
  99. uint16_t length;
  100. uint8_t version;
  101. } __attribute__((packed)) ivt_header_t;
  102. typedef struct {
  103. uint8_t tag;
  104. uint16_t length;
  105. uint8_t param;
  106. } __attribute__((packed)) write_dcd_command_t;
  107. typedef struct {
  108. ivt_header_t header;
  109. write_dcd_command_t write_dcd_command;
  110. dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2];
  111. } dcd_v2_t;
  112. typedef struct {
  113. uint32_t start;
  114. uint32_t size;
  115. uint32_t plugin;
  116. } boot_data_t;
  117. typedef struct {
  118. ivt_header_t header;
  119. uint32_t entry;
  120. uint32_t reserved1;
  121. uint32_t dcd_ptr;
  122. uint32_t boot_data_ptr;
  123. uint32_t self;
  124. uint32_t csf;
  125. uint32_t reserved2;
  126. } flash_header_v2_t;
  127. typedef struct {
  128. flash_header_v2_t fhdr;
  129. boot_data_t boot_data;
  130. dcd_v2_t dcd_table;
  131. } imx_header_v2_t;
  132. struct imx_header {
  133. union {
  134. imx_header_v1_t hdr_v1;
  135. imx_header_v2_t hdr_v2;
  136. } header;
  137. uint32_t flash_offset;
  138. };
  139. typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
  140. char *name, int lineno,
  141. int fld, uint32_t value,
  142. uint32_t off);
  143. typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
  144. uint32_t dcd_len,
  145. char *name, int lineno);
  146. typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr,
  147. uint32_t dcd_len,
  148. struct stat *sbuf,
  149. struct mkimage_params *params);
  150. #endif /* _IMXIMAGE_H_ */