fsl_flexspi_nor_boot.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2017-2020 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. #include "fsl_common.h"
  12. /*! @name Driver version */
  13. /*@{*/
  14. /*! @brief XIP_DEVICE driver version 2.0.2. */
  15. #define FSL_XIP_DEVICE_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
  16. /*@}*/
  17. /*************************************
  18. * IVT Data
  19. *************************************/
  20. typedef struct _ivt_
  21. {
  22. /** @ref hdr with tag #HAB_TAG_IVT, length and HAB version fields
  23. * (see @ref data)
  24. */
  25. uint32_t hdr;
  26. /** Absolute address of the first instruction to execute from the
  27. * image
  28. */
  29. uint32_t entry;
  30. /** Reserved in this version of HAB: should be NULL. */
  31. uint32_t reserved1;
  32. /** Absolute address of the image DCD: may be NULL. */
  33. uint32_t dcd;
  34. /** Absolute address of the Boot Data: may be NULL, but not interpreted
  35. * any further by HAB
  36. */
  37. uint32_t boot_data;
  38. /** Absolute address of the IVT.*/
  39. uint32_t self;
  40. /** Absolute address of the image CSF.*/
  41. uint32_t csf;
  42. /** Reserved in this version of HAB: should be zero. */
  43. uint32_t reserved2;
  44. } ivt;
  45. #define IVT_MAJOR_VERSION 0x4
  46. #define IVT_MAJOR_VERSION_SHIFT 0x4
  47. #define IVT_MAJOR_VERSION_MASK 0xF
  48. #define IVT_MINOR_VERSION 0x1
  49. #define IVT_MINOR_VERSION_SHIFT 0x0
  50. #define IVT_MINOR_VERSION_MASK 0xF
  51. #define IVT_VERSION(major, minor) \
  52. ((((major)&IVT_MAJOR_VERSION_MASK) << IVT_MAJOR_VERSION_SHIFT) | \
  53. (((minor)&IVT_MINOR_VERSION_MASK) << IVT_MINOR_VERSION_SHIFT))
  54. /* IVT header */
  55. #define IVT_TAG_HEADER 0xD1 /**< Image Vector Table */
  56. #define IVT_SIZE 0x2000
  57. #define IVT_PAR IVT_VERSION(IVT_MAJOR_VERSION, IVT_MINOR_VERSION)
  58. #define IVT_HEADER (IVT_TAG_HEADER | (IVT_SIZE << 8) | (IVT_PAR << 24))
  59. /* Set resume entry */
  60. #if defined(__CC_ARM) || defined(__ARMCC_VERSION)
  61. extern uint32_t __Vectors[];
  62. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
  63. #elif defined(__MCUXPRESSO)
  64. extern uint32_t __Vectors[];
  65. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
  66. #elif defined(__ICCARM__)
  67. extern uint32_t __VECTOR_TABLE[];
  68. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE)
  69. #elif defined(__GNUC__)
  70. extern uint32_t __isr_vector[];
  71. #define IMAGE_ENTRY_ADDRESS ((uint32_t)__isr_vector)
  72. #endif
  73. #if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE)
  74. #define DCD_ADDRESS dcd_data
  75. #else
  76. #define DCD_ADDRESS 0
  77. #endif
  78. #define BOOT_DATA_ADDRESS &g_boot_data
  79. #define CSF_ADDRESS 0
  80. #define IVT_RSVD (uint32_t)(0x00000000)
  81. /*************************************
  82. * Boot Data
  83. *************************************/
  84. typedef struct _boot_data_
  85. {
  86. uint32_t start; /* boot start location */
  87. uint32_t size; /* size */
  88. uint32_t plugin; /* plugin flag - 1 if downloaded application is plugin */
  89. uint32_t placeholder; /* placehoder to make even 0x10 size */
  90. } BOOT_DATA_T;
  91. #define FLASH_BASE FlexSPI_AMBA_BASE
  92. #if defined(BOARD_FLASH_SIZE)
  93. #define FLASH_SIZE BOARD_FLASH_SIZE
  94. #else
  95. #error "Please define macro BOARD_FLASH_SIZE"
  96. #endif
  97. #define PLUGIN_FLAG (uint32_t)0
  98. /* External Variables */
  99. extern const BOOT_DATA_T g_boot_data;
  100. #if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE)
  101. extern const uint8_t dcd_data[];
  102. #endif
  103. #endif /* __FLEXSPI_NOR_BOOT_H__ */