您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

125 行
3.9 KiB

  1. /*
  2. * Copyright 2013-2016 Freescale Semiconductor, Inc.
  3. * Copyright 2016-2020 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. *
  8. */
  9. #ifndef FSL_FTFX_CACHE_H
  10. #define FSL_FTFX_CACHE_H
  11. #include "fsl_ftfx_controller.h"
  12. /*!
  13. * @addtogroup ftfx_cache_driver
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*!
  20. * @name FTFx cache version
  21. * @{
  22. */
  23. /*! @brief Flexnvm driver version for SDK*/
  24. #define FSL_FTFX_CACHE_DRIVER_VERSION (MAKE_VERSION(3, 0, 0)) /*!< Version 1.0.0. */
  25. /*@}*/
  26. /*!
  27. * @brief FTFx prefetch speculation status.
  28. */
  29. typedef struct _flash_prefetch_speculation_status
  30. {
  31. bool instructionOff; /*!< Instruction speculation.*/
  32. bool dataOff; /*!< Data speculation.*/
  33. } ftfx_prefetch_speculation_status_t;
  34. /*!
  35. * @brief Constants for execute-in-RAM flash function.
  36. */
  37. enum _ftfx_cache_ram_func_constants
  38. {
  39. kFTFx_CACHE_RamFuncMaxSizeInWords = 16U, /*!< The maximum size of execute-in-RAM function.*/
  40. };
  41. typedef union
  42. {
  43. uint32_t commadAddr;
  44. void (*callFlashCommand)(FTFx_REG32_ACCESS_TYPE base,
  45. uint32_t bitMask,
  46. uint32_t bitShift,
  47. uint32_t bitValue);
  48. }function_bit_operation_ptr_t;
  49. /*! @brief FTFx cache driver state information.
  50. *
  51. * An instance of this structure is allocated by the user of the flash driver and
  52. * passed into each of the driver APIs.
  53. */
  54. typedef struct _ftfx_cache_config
  55. {
  56. uint8_t flashMemoryIndex; /*!< 0 - primary flash; 1 - secondary flash*/
  57. uint8_t reserved[3];
  58. function_bit_operation_ptr_t bitOperFuncAddr; /*!< An buffer point to the flash execute-in-RAM function. */
  59. } ftfx_cache_config_t;
  60. /*******************************************************************************
  61. * API
  62. ******************************************************************************/
  63. #if defined(__cplusplus)
  64. extern "C" {
  65. #endif
  66. /*!
  67. * @brief Initializes the global FTFx cache structure members.
  68. *
  69. * This function checks and initializes the Flash module for the other FTFx cache APIs.
  70. *
  71. * @param config Pointer to the storage for the driver runtime state.
  72. *
  73. * @retval #kStatus_FTFx_Success API was executed successfully.
  74. * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided.
  75. * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  76. */
  77. status_t FTFx_CACHE_Init(ftfx_cache_config_t *config);
  78. /*!
  79. * @brief Process the cache/prefetch/speculation to the flash.
  80. *
  81. * @param config A pointer to the storage for the driver runtime state.
  82. * @param isPreProcess The possible option used to control flash cache/prefetch/speculation
  83. * @retval #kStatus_FTFx_Success API was executed successfully.
  84. * @retval #kStatus_FTFx_InvalidArgument Invalid argument is provided.
  85. * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
  86. */
  87. status_t FTFx_CACHE_ClearCachePrefetchSpeculation(ftfx_cache_config_t *config, bool isPreProcess);
  88. /*!
  89. * @brief Sets the PFlash prefetch speculation to the intended speculation status.
  90. *
  91. * @param speculationStatus The expected protect status to set to the PFlash protection register. Each bit is
  92. * @retval #kStatus_FTFx_Success API was executed successfully.
  93. * @retval #kStatus_FTFx_InvalidSpeculationOption An invalid speculation option argument is provided.
  94. */
  95. status_t FTFx_CACHE_PflashSetPrefetchSpeculation(ftfx_prefetch_speculation_status_t *speculationStatus);
  96. /*!
  97. * @brief Gets the PFlash prefetch speculation status.
  98. *
  99. * @param speculationStatus Speculation status returned by the PFlash IP.
  100. * @retval #kStatus_FTFx_Success API was executed successfully.
  101. */
  102. status_t FTFx_CACHE_PflashGetPrefetchSpeculation(ftfx_prefetch_speculation_status_t *speculationStatus);
  103. #if defined(__cplusplus)
  104. }
  105. #endif
  106. /*! @}*/
  107. #endif /* FSL_FTFX_CACHE_H */