fsl_ftfx_cache.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * The Clear BSD License
  3. * Copyright 2013-2016 Freescale Semiconductor, Inc.
  4. * Copyright 2016-2018 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted (subject to the limitations in the
  9. * disclaimer below) provided that the following conditions are met:
  10. *
  11. * * Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * * Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * * Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from
  20. * this software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  23. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  24. * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  25. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  26. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  31. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  32. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  33. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  34. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. */
  37. #ifndef _FSL_FTFX_CACHE_H_
  38. #define _FSL_FTFX_CACHE_H_
  39. #include "fsl_ftfx_controller.h"
  40. /*!
  41. * @addtogroup ftfx_cache_driver
  42. * @{
  43. */
  44. /*******************************************************************************
  45. * Definitions
  46. ******************************************************************************/
  47. /*!
  48. * @name FTFx cache version
  49. * @{
  50. */
  51. /*! @brief Flexnvm driver version for SDK*/
  52. #define FSL_FTFX_CACHE_DRIVER_VERSION (MAKE_VERSION(3, 0, 0)) /*!< Version 1.0.0. */
  53. /*@}*/
  54. /*!
  55. * @brief FTFx prefetch speculation status.
  56. */
  57. typedef struct _flash_prefetch_speculation_status
  58. {
  59. bool instructionOff; /*!< Instruction speculation.*/
  60. bool dataOff; /*!< Data speculation.*/
  61. } ftfx_prefetch_speculation_status_t;
  62. /*!
  63. * @brief Constants for execute-in-RAM flash function.
  64. */
  65. enum _ftfx_cache_ram_func_constants
  66. {
  67. kFTFx_CACHE_RamFuncMaxSizeInWords = 16U, /*!< The maximum size of execute-in-RAM function.*/
  68. };
  69. /*! @brief FTFx cache driver state information.
  70. *
  71. * An instance of this structure is allocated by the user of the flash driver and
  72. * passed into each of the driver APIs.
  73. */
  74. typedef struct _ftfx_cache_config
  75. {
  76. uint8_t flashMemoryIndex; /*!< 0 - primary flash; 1 - secondary flash*/
  77. uint8_t reserved[3];
  78. uint32_t *comBitOperFuncAddr; /*!< An buffer point to the flash execute-in-RAM function. */
  79. } ftfx_cache_config_t;
  80. /*******************************************************************************
  81. * API
  82. ******************************************************************************/
  83. #if defined(__cplusplus)
  84. extern "C" {
  85. #endif
  86. /*!
  87. * @brief Initializes the global FTFx cache structure members.
  88. *
  89. * This function checks and initializes the Flash module for the other FTFx cache APIs.
  90. *
  91. * @param config Pointer to the storage for the driver runtime state.
  92. *
  93. * @retval #kStatus_FTFx_Success API was executed successfully.
  94. * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided.
  95. * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  96. */
  97. status_t FTFx_CACHE_Init(ftfx_cache_config_t *config);
  98. /*!
  99. * @brief Process the cache/prefetch/speculation to the flash.
  100. *
  101. * @param config A pointer to the storage for the driver runtime state.
  102. * @param process The possible option used to control flash cache/prefetch/speculation
  103. * @retval #kStatus_FTFx_Success API was executed successfully.
  104. * @retval #kStatus_FTFx_InvalidArgument Invalid argument is provided.
  105. * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  106. */
  107. status_t FTFx_CACHE_ClearCachePrefetchSpeculation(ftfx_cache_config_t *config, bool isPreProcess);
  108. /*!
  109. * @brief Sets the PFlash prefetch speculation to the intended speculation status.
  110. *
  111. * @param speculationStatus The expected protect status to set to the PFlash protection register. Each bit is
  112. * @retval #kStatus_FTFx_Success API was executed successfully.
  113. * @retval #kStatus_FTFx_InvalidSpeculationOption An invalid speculation option argument is provided.
  114. */
  115. status_t FTFx_CACHE_PflashSetPrefetchSpeculation(ftfx_prefetch_speculation_status_t *speculationStatus);
  116. /*!
  117. * @brief Gets the PFlash prefetch speculation status.
  118. *
  119. * @param speculationStatus Speculation status returned by the PFlash IP.
  120. * @retval #kStatus_FTFx_Success API was executed successfully.
  121. */
  122. status_t FTFx_CACHE_PflashGetPrefetchSpeculation(ftfx_prefetch_speculation_status_t *speculationStatus);
  123. #if defined(__cplusplus)
  124. }
  125. #endif
  126. /*! @}*/
  127. #endif /* _FSL_FTFX_CACHE_H_ */