fsl_flexspi_nor_boot.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2017 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef __FLEXSPI_NOR_BOOT_H__
  8. #define __FLEXSPI_NOR_BOOT_H__
  9. #include <stdint.h>
  10. #include "board.h"
  11. /*************************************
  12. * IVT Data
  13. *************************************/
  14. typedef struct _ivt_ {
  15. /** @ref hdr with tag #HAB_TAG_IVT, length and HAB version fields
  16. * (see @ref data)
  17. */
  18. uint32_t hdr;
  19. /** Absolute address of the first instruction to execute from the
  20. * image
  21. */
  22. uint32_t entry;
  23. /** Reserved in this version of HAB: should be NULL. */
  24. uint32_t reserved1;
  25. /** Absolute address of the image DCD: may be NULL. */
  26. uint32_t dcd;
  27. /** Absolute address of the Boot Data: may be NULL, but not interpreted
  28. * any further by HAB
  29. */
  30. uint32_t boot_data;
  31. /** Absolute address of the IVT.*/
  32. uint32_t self;
  33. /** Absolute address of the image CSF.*/
  34. uint32_t csf;
  35. /** Reserved in this version of HAB: should be zero. */
  36. uint32_t reserved2;
  37. } ivt;
  38. #define IVT_MAJOR_VERSION 0x4
  39. #define IVT_MAJOR_VERSION_SHIFT 0x4
  40. #define IVT_MAJOR_VERSION_MASK 0xF
  41. #define IVT_MINOR_VERSION 0x1
  42. #define IVT_MINOR_VERSION_SHIFT 0x0
  43. #define IVT_MINOR_VERSION_MASK 0xF
  44. #define IVT_VERSION(major, minor) \
  45. ((((major) & IVT_MAJOR_VERSION_MASK) << IVT_MAJOR_VERSION_SHIFT) | \
  46. (((minor) & IVT_MINOR_VERSION_MASK) << IVT_MINOR_VERSION_SHIFT))
  47. /* IVT header */
  48. #define IVT_TAG_HEADER 0xD1 /**< Image Vector Table */
  49. #define IVT_SIZE 0x2000
  50. #define IVT_PAR IVT_VERSION(IVT_MAJOR_VERSION, IVT_MINOR_VERSION)
  51. #define IVT_HEADER (IVT_TAG_HEADER | (IVT_SIZE << 8) | (IVT_PAR << 24))
  52. /* Set resume entry */
  53. #if defined(__CC_ARM)
  54. extern uint32_t __Vectors[];
  55. extern uint32_t Image$$RW_m_config_text$$Base[];
  56. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
  57. #define FLASH_BASE ((uint32_t)Image$$RW_m_config_text$$Base)
  58. #elif defined(__MCUXPRESSO)
  59. extern uint32_t __Vectors[];
  60. extern uint32_t __boot_hdr_start__[];
  61. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
  62. #define FLASH_BASE ((uint32_t)__boot_hdr_start__)
  63. #elif defined(__ICCARM__)
  64. extern uint32_t __VECTOR_TABLE[];
  65. extern uint32_t m_boot_hdr_conf_start[];
  66. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE)
  67. #define FLASH_BASE ((uint32_t)m_boot_hdr_conf_start)
  68. #elif defined(__GNUC__)
  69. extern uint32_t __VECTOR_TABLE[];
  70. extern uint32_t __FLASH_BASE[];
  71. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE)
  72. #define FLASH_BASE ((uint32_t)__FLASH_BASE)
  73. #endif
  74. #define DCD_ADDRESS dcd_data
  75. #define BOOT_DATA_ADDRESS &boot_data
  76. #define CSF_ADDRESS 0
  77. #define IVT_RSVD (uint32_t)(0x00000000)
  78. /*************************************
  79. * Boot Data
  80. *************************************/
  81. typedef struct _boot_data_ {
  82. uint32_t start; /* boot start location */
  83. uint32_t size; /* size */
  84. uint32_t plugin; /* plugin flag - 1 if downloaded application is plugin */
  85. uint32_t placeholder; /* placehoder to make even 0x10 size */
  86. }BOOT_DATA_T;
  87. #define FLASH_SIZE BOARD_FLASH_SIZE
  88. #define PLUGIN_FLAG (uint32_t)0
  89. /* External Variables */
  90. const BOOT_DATA_T boot_data;
  91. extern const uint8_t dcd_data[];
  92. #endif /* __FLEXSPI_NOR_BOOT_H__ */