Cache_Ip.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : DMA,CACHE,TRGMUX,FLEXIO
  5. * Dependencies : none
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. /* Prevention from multiple including the same header */
  25. #ifndef CACHE_IP_DRIVER_H_
  26. #define CACHE_IP_DRIVER_H_
  27. /**
  28. * @file Cache_Ip.h
  29. *
  30. * @version 1.0.0
  31. *
  32. * @brief AUTOSAR Mcl - Cache Ip driver header file.
  33. * @details
  34. *
  35. * @addtogroup CACHE_IP_DRIVER CACHE IP Driver
  36. * @{
  37. */
  38. /*==================================================================================================
  39. * INCLUDE FILES
  40. * 1) system and project includes
  41. * 2) needed interfaces from external units
  42. * 3) internal and external interfaces from this unit
  43. ==================================================================================================*/
  44. #include "Cache_Ip_Cfg_Defines.h"
  45. #if (CACHE_IP_IS_AVAILABLE == STD_ON)
  46. /*==================================================================================================
  47. * SOURCE FILE VERSION INFORMATION
  48. ==================================================================================================*/
  49. #define CACHE_IP_VENDOR_ID_H 43
  50. #define CACHE_IP_AR_RELEASE_MAJOR_VERSION_H 4
  51. #define CACHE_IP_AR_RELEASE_MINOR_VERSION_H 4
  52. #define CACHE_IP_AR_RELEASE_REVISION_VERSION_H 0
  53. #define CACHE_IP_SW_MAJOR_VERSION_H 1
  54. #define CACHE_IP_SW_MINOR_VERSION_H 0
  55. #define CACHE_IP_SW_PATCH_VERSION_H 0
  56. /*==================================================================================================
  57. FILE VERSION CHECKS
  58. ==================================================================================================*/
  59. /* Check if header file and Cache_Ip_Cfg_Defines.h file are of the same vendor */
  60. #if (CACHE_IP_VENDOR_ID_H != CACHE_IP_CFG_DEFINES_VENDOR_ID_H)
  61. #error "Cache_Ip.h and Cache_Ip_Cfg_Defines.h have different vendor ids"
  62. #endif
  63. /* Check if header file and Cache_Ip_Cfg_Defines.h file are of the same Autosar version */
  64. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_H != CACHE_IP_CFG_DEFINES_AR_RELEASE_MAJOR_VERSION_H) || \
  65. (CACHE_IP_AR_RELEASE_MINOR_VERSION_H != CACHE_IP_CFG_DEFINES_AR_RELEASE_MINOR_VERSION_H) || \
  66. (CACHE_IP_AR_RELEASE_REVISION_VERSION_H != CACHE_IP_CFG_DEFINES_AR_RELEASE_REVISION_VERSION_H) \
  67. )
  68. #error "AutoSar Version Numbers of Cache_Ip.h and Cache_Ip_Cfg_Defines.h are different"
  69. #endif
  70. /* Check if header file and Cache_Ip_Cfg_Defines.h file are of the same Software version */
  71. #if ((CACHE_IP_SW_MAJOR_VERSION_H != CACHE_IP_CFG_DEFINES_SW_MAJOR_VERSION_H) || \
  72. (CACHE_IP_SW_MINOR_VERSION_H != CACHE_IP_CFG_DEFINES_SW_MINOR_VERSION_H) || \
  73. (CACHE_IP_SW_PATCH_VERSION_H != CACHE_IP_CFG_DEFINES_SW_PATCH_VERSION_H) \
  74. )
  75. #error "Software Version Numbers of Cache_Ip.h and Cache_Ip_Cfg_Defines.h are different"
  76. #endif
  77. /*==================================================================================================
  78. ENUM
  79. ==================================================================================================*/
  80. /**
  81. * @brief This type contains the Cache Ip types.
  82. * @details The cache types specifies what type of cache shall be used when calling the interface.
  83. * The CACHE_IP_ALL specifies both Instruction and Data caches.
  84. * The CACHE_IP_INSTRUCTION specifies the Instruction cache.
  85. * The CACHE_IP_DATA specifies the Data cache.
  86. *
  87. * */
  88. typedef enum{
  89. CACHE_IP_ALL = 0U,
  90. CACHE_IP_INSTRUCTION = 1U,
  91. CACHE_IP_DATA = 2U,
  92. }Cache_Ip_Type;
  93. /*==================================================================================================
  94. * GLOBAL FUNCTION PROTOTYPES
  95. ==================================================================================================*/
  96. #define MCL_START_SEC_CODE
  97. /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
  98. #include "Mcl_MemMap.h"
  99. /**
  100. * @brief This function enables the Cache Ip Driver.
  101. * @details This service is a reentrant function that shall enable the Cache Ip driver.
  102. *
  103. * @param[in] CacheType Specifies the cache type.
  104. *
  105. * @return E_OK is returned if the enable action finished correctly.
  106. * E_NOT_OK is returned if the enable action finished incorrectly.
  107. *
  108. * @implements Cache_Ip_Enable_Activity
  109. * */
  110. Std_ReturnType Cache_Ip_Enable(const Cache_Ip_Type CacheType);
  111. /**
  112. * @brief This function disables the Cache Ip Driver.
  113. * @details This service is a reentrant function that shall disables the Cache Ip driver.
  114. *
  115. * @param[in] CacheType Specifies the cache type.
  116. *
  117. * @return E_OK is returned if the disable action finished correctly.
  118. * E_NOT_OK is returned if the disable action finished incorrectly.
  119. *
  120. * @implements Cache_Ip_Disable_Activity
  121. * */
  122. Std_ReturnType Cache_Ip_Disable(const Cache_Ip_Type CacheType);
  123. /**
  124. * @brief This function Invalidates the Cache Ip Driver.
  125. * @details This service is a reentrant function that shall Invalidates the Cache Ip driver.
  126. * The Invalidate operation applies for the entire selected Cache Type.
  127. *
  128. * A cache invalidate operation ensures that updates made visible by observers that access memory at
  129. * the point to which the invalidate is defined are made visible to an observer that controls the cache.
  130. * This might result in the loss of updates to the locations affected by the invalidate operation that have
  131. * been written by observers that access the cache. If the address of an entry on which the invalidate
  132. * operates does not have a Normal Cacheable attribute, or if the cache is disabled, then an invalidate
  133. * operation also ensures that this address is not present in the cache.
  134. *
  135. * @param[in] CacheType Specifies the cache type.
  136. *
  137. * @return E_OK is returned if the invalidation finished correctly.
  138. * E_NOT_OK is returned if the invalidation finished incorrectly.
  139. *
  140. * @implements Cache_Ip_Invalidate_Activity
  141. * */
  142. Std_ReturnType Cache_Ip_Invalidate(const Cache_Ip_Type CacheType);
  143. /**
  144. * @brief This function Clean the Cache Ip Driver.
  145. * @details This service is a reentrant function that shall Clean the Cache Ip driver.
  146. * The Clean operation applies for the entire selected Cache Type.
  147. *
  148. * A cache clean operation ensures that updates made by an observer that controls the cache are made
  149. * visible to other observers that can access memory at the point to which the operation is performed.
  150. * Once the Clean has completed, the new memory values are guaranteed to be visible to the point to
  151. * which the operation is performed, for example to the point of unification. The cleaning of a cache
  152. * entry from a cache can overwrite memory that has been written by another observer only if the entry
  153. * contains a location that has been written to by an observer in the shareability domain of that memory
  154. * location.
  155. *
  156. * A cache clean and invalidate operation behaves as the execution of a clean operation followed
  157. * immediately by an invalidate operation. Both operations are performed to the same location.
  158. *
  159. * @param[in] CacheType Specifies the cache type.
  160. * @param[in] enInvalidate Specifies to execute operation Clean&Invalidate.
  161. *
  162. * @return E_OK is returned if the cleaning finished correctly.
  163. * E_NOT_OK is returned if the cleaning finished incorrectly.
  164. *
  165. * @implements Cache_Ip_Clean_Activity
  166. * */
  167. Std_ReturnType Cache_Ip_Clean(const Cache_Ip_Type CacheType, const boolean EnInvalidate);
  168. /**
  169. * @brief This function Invalidates By Address the Cache Ip Driver.
  170. * @details This service is a reentrant function that shall Invalidates By Address the Cache Ip driver.
  171. * The Invalidate By Address operation applies for the memory segment specified by the
  172. * start Address and Length. The operation Invalidates only multiple of Cache Line Size, thus the
  173. * specified memory segment shall be aligned and multiple of the Cache Line Size.
  174. *
  175. * A cache invalidate operation ensures that updates made visible by observers that access memory at
  176. * the point to which the invalidate is defined are made visible to an observer that controls the cache.
  177. * This might result in the loss of updates to the locations affected by the invalidate operation that have
  178. * been written by observers that access the cache. If the address of an entry on which the invalidate
  179. * operates does not have a Normal Cacheable attribute, or if the cache is disabled, then an invalidate
  180. * operation also ensures that this address is not present in the cache.
  181. *
  182. * @param[in] CacheType Specifies the cache type.
  183. * @param[in] Addr Specifies the memory segment start address.
  184. * @param[in] Length Specifies the memory segment length.
  185. *
  186. * @return E_OK is returned if the invalidation finished correctly.
  187. * E_NOT_OK is returned if the invalidation finished incorrectly.
  188. *
  189. * @implements Cache_Ip_InvalidateByAddr_Activity
  190. * */
  191. Std_ReturnType Cache_Ip_InvalidateByAddr(const Cache_Ip_Type CacheType, const uint32 Addr, const uint32 Length);
  192. /**
  193. * @brief This function Clean By Address the Cache Ip Driver.
  194. * @details This service is a reentrant function that shall Clean By Address the Cache Ip driver.
  195. * The Clean By Address operation applies for the memory segment specified by the
  196. * start Address and Length. The operation Cleans only multiple of Cache Line Size, thus the
  197. * specified memory segment shall be aligned and multiple of the Cache Line Size.
  198. *
  199. * A cache clean operation ensures that updates made by an observer that controls the cache are made
  200. * visible to other observers that can access memory at the point to which the operation is performed.
  201. * Once the Clean has completed, the new memory values are guaranteed to be visible to the point to
  202. * which the operation is performed, for example to the point of unification. The cleaning of a cache
  203. * entry from a cache can overwrite memory that has been written by another observer only if the entry
  204. * contains a location that has been written to by an observer in the shareability domain of that memory
  205. * location.
  206. *
  207. * A cache clean and invalidate operation behaves as the execution of a clean operation followed
  208. * immediately by an invalidate operation. Both operations are performed to the same location.
  209. *
  210. * @param[in] CacheType Specifies the cache type.
  211. * @param[in] enInvalidate Specifies to execute operation Clean&Invalidate.
  212. * @param[in] Addr Specifies the memory segment start address.
  213. * @param[in] Length Specifies the memory segment length.
  214. *
  215. * @return E_OK is returned if the cleaning finished correctly.
  216. * E_NOT_OK is returned if the cleaning finished incorrectly.
  217. *
  218. * @implements Cache_Ip_CleanByAddr_Activity
  219. * */
  220. Std_ReturnType Cache_Ip_CleanByAddr(const Cache_Ip_Type CacheType, const boolean EnInvalidate, const uint32 Addr, const uint32 Length);
  221. #define MCL_STOP_SEC_CODE
  222. /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
  223. #include "Mcl_MemMap.h"
  224. #endif /* #if (CACHE_IP_IS_AVAILABLE == STD_ON) */
  225. /** @} */
  226. #endif /* #ifndef CACHE_IP_DRIVER_H_ */
  227. /*==================================================================================================
  228. * END OF FILE
  229. ==================================================================================================*/