imximage.h 4.1 KB

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