Cache_Ip.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. /**
  25. * @file Cache_Ip.c
  26. *
  27. * @version 1.0.0
  28. *
  29. * @brief AUTOSAR Mcl - Cache Ip driver source file.
  30. * @details
  31. *
  32. * @addtogroup CACHE_IP_DRIVER CACHE IP Driver
  33. * @{
  34. */
  35. /*==================================================================================================
  36. * INCLUDE FILES
  37. * 1) system and project includes
  38. * 2) needed interfaces from external units
  39. * 3) internal and external interfaces from this unit
  40. ==================================================================================================*/
  41. #include "Cache_Ip.h"
  42. #include "Cache_Ip_Devassert.h"
  43. #include "SchM_Mcl.h"
  44. #if (CACHE_IP_ARMCOREMX_IS_AVAILABLE == STD_ON)
  45. #include "Cache_Ip_HwAcc_ArmCoreMx.h"
  46. #endif /* #if (CACHE_IP_ARMCOREMX_IS_AVAILABLE == STD_ON) */
  47. #if (CACHE_IP_LMEM_IS_AVAILABLE == STD_ON)
  48. #include "Cache_Ip_HwAcc_Lmem.h"
  49. #endif /* #if (CACHE_IP_LMEM_IS_AVAILABLE == STD_ON) */
  50. /*==================================================================================================
  51. * SOURCE FILE VERSION INFORMATION
  52. ==================================================================================================*/
  53. #define CACHE_IP_VENDOR_ID_C 43
  54. #define CACHE_IP_AR_RELEASE_MAJOR_VERSION_C 4
  55. #define CACHE_IP_AR_RELEASE_MINOR_VERSION_C 4
  56. #define CACHE_IP_AR_RELEASE_REVISION_VERSION_C 0
  57. #define CACHE_IP_SW_MAJOR_VERSION_C 1
  58. #define CACHE_IP_SW_MINOR_VERSION_C 0
  59. #define CACHE_IP_SW_PATCH_VERSION_C 0
  60. #if (CACHE_IP_IS_AVAILABLE == STD_ON)
  61. /*==================================================================================================
  62. FILE VERSION CHECKS
  63. ==================================================================================================*/
  64. /* Check if Cache_Ip.c file and Cache_Ip.h file are of the same vendor */
  65. #if (CACHE_IP_VENDOR_ID_C != CACHE_IP_VENDOR_ID_H)
  66. #error "Cache_Ip.c and Cache_Ip.h have different vendor ids"
  67. #endif
  68. /* Check if Cache_Ip.c file and Cache_Ip.h file are of the same Autosar version */
  69. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_C != CACHE_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  70. (CACHE_IP_AR_RELEASE_MINOR_VERSION_C != CACHE_IP_AR_RELEASE_MINOR_VERSION_H) || \
  71. (CACHE_IP_AR_RELEASE_REVISION_VERSION_C != CACHE_IP_AR_RELEASE_REVISION_VERSION_H) \
  72. )
  73. #error "AutoSar Version Numbers of Cache_Ip.c and Cache_Ip.h are different"
  74. #endif
  75. /* Check if Cache_Ip.c file and Cache_Ip.h file are of the same Software version */
  76. #if ((CACHE_IP_SW_MAJOR_VERSION_C != CACHE_IP_SW_MAJOR_VERSION_H) || \
  77. (CACHE_IP_SW_MINOR_VERSION_C != CACHE_IP_SW_MINOR_VERSION_H) || \
  78. (CACHE_IP_SW_PATCH_VERSION_C != CACHE_IP_SW_PATCH_VERSION_H) \
  79. )
  80. #error "Software Version Numbers of Cache_Ip.c and Cache_Ip.h are different"
  81. #endif
  82. /* Check if Cache_Ip.c file and Cache_Ip_Devassert.h file are of the same vendor */
  83. #if (CACHE_IP_VENDOR_ID_C != CACHE_IP_DEVASSERT_VENDOR_ID_H)
  84. #error "Cache_Ip.c and Cache_Ip_Devassert.h have different vendor ids"
  85. #endif
  86. /* Check if Cache_Ip.c file and Cache_Ip_Devassert.h file are of the same Autosar version */
  87. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_C != CACHE_IP_DEVASSERT_AR_RELEASE_MAJOR_VERSION_H) || \
  88. (CACHE_IP_AR_RELEASE_MINOR_VERSION_C != CACHE_IP_DEVASSERT_AR_RELEASE_MINOR_VERSION_H) || \
  89. (CACHE_IP_AR_RELEASE_REVISION_VERSION_C != CACHE_IP_DEVASSERT_AR_RELEASE_REVISION_VERSION_H) \
  90. )
  91. #error "AutoSar Version Numbers of Cache_Ip.c and Cache_Ip_Devassert.h are different"
  92. #endif
  93. /* Check if Cache_Ip.c file and Cache_Ip_Devassert.h file are of the same Software version */
  94. #if ((CACHE_IP_SW_MAJOR_VERSION_C != CACHE_IP_DEVASSERT_SW_MAJOR_VERSION_H) || \
  95. (CACHE_IP_SW_MINOR_VERSION_C != CACHE_IP_DEVASSERT_SW_MINOR_VERSION_H) || \
  96. (CACHE_IP_SW_PATCH_VERSION_C != CACHE_IP_DEVASSERT_SW_PATCH_VERSION_H) \
  97. )
  98. #error "Software Version Numbers of Cache_Ip.c and Cache_Ip_Devassert.h are different"
  99. #endif
  100. #if (CACHE_IP_ARMCOREMX_IS_AVAILABLE == STD_ON)
  101. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_ArmCoreMx.h file are of the same vendor */
  102. #if (CACHE_IP_VENDOR_ID_C != CACHE_IP_HWACC_ARMCOREMX_VENDOR_ID_H)
  103. #error "Cache_Ip.c and Cache_Ip_HwAcc_ArmCoreMx.h have different vendor ids"
  104. #endif
  105. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_ArmCoreMx.h file are of the same Autosar version */
  106. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_AR_RELEASE_MAJOR_VERSION_H) || \
  107. (CACHE_IP_AR_RELEASE_MINOR_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_AR_RELEASE_MINOR_VERSION_H) || \
  108. (CACHE_IP_AR_RELEASE_REVISION_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_AR_RELEASE_REVISION_VERSION_H) \
  109. )
  110. #error "AutoSar Version Numbers of Cache_Ip.c and Cache_Ip_HwAcc_ArmCoreMx.h are different"
  111. #endif
  112. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_ArmCoreMx.h file are of the same Software version */
  113. #if ((CACHE_IP_SW_MAJOR_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_SW_MAJOR_VERSION_H) || \
  114. (CACHE_IP_SW_MINOR_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_SW_MINOR_VERSION_H) || \
  115. (CACHE_IP_SW_PATCH_VERSION_C != CACHE_IP_HWACC_ARMCOREMX_SW_PATCH_VERSION_H) \
  116. )
  117. #error "Software Version Numbers of Cache_Ip.c and Cache_Ip_HwAcc_ArmCoreMx.h are different"
  118. #endif
  119. #endif /* #if (CACHE_IP_ARMCOREMX_IS_AVAILABLE == STD_ON) */
  120. #if (CACHE_IP_LMEM_IS_AVAILABLE == STD_ON)
  121. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_Lmem.h file are of the same vendor */
  122. #if (CACHE_IP_VENDOR_ID_C != CACHE_IP_HWACC_LMEM_VENDOR_ID_H)
  123. #error "Cache_Ip.c and Cache_Ip_HwAcc_Lmem.h have different vendor ids"
  124. #endif
  125. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_Lmem.h file are of the same Autosar version */
  126. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_C != CACHE_IP_HWACC_LMEM_AR_RELEASE_MAJOR_VERSION_H) || \
  127. (CACHE_IP_AR_RELEASE_MINOR_VERSION_C != CACHE_IP_HWACC_LMEM_AR_RELEASE_MINOR_VERSION_H) || \
  128. (CACHE_IP_AR_RELEASE_REVISION_VERSION_C != CACHE_IP_HWACC_LMEM_AR_RELEASE_REVISION_VERSION_H) \
  129. )
  130. #error "AutoSar Version Numbers of Cache_Ip.c and Cache_Ip_HwAcc_Lmem.h are different"
  131. #endif
  132. /* Check if Cache_Ip.c file and Cache_Ip_HwAcc_Lmem.h file are of the same Software version */
  133. #if ((CACHE_IP_SW_MAJOR_VERSION_C != CACHE_IP_HWACC_LMEM_SW_MAJOR_VERSION_H) || \
  134. (CACHE_IP_SW_MINOR_VERSION_C != CACHE_IP_HWACC_LMEM_SW_MINOR_VERSION_H) || \
  135. (CACHE_IP_SW_PATCH_VERSION_C != CACHE_IP_HWACC_LMEM_SW_PATCH_VERSION_H) \
  136. )
  137. #error "Software Version Numbers of Cache_Ip.c and Cache_Ip_HwAcc_Lmem.h are different"
  138. #endif
  139. #endif /* #if (CACHE_IP_LMEM_IS_AVAILABLE == STD_ON) */
  140. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  141. /* Check if Cache_Ip.c file and SchM_Mcl header file are of the same Autosar version */
  142. #if ((CACHE_IP_AR_RELEASE_MAJOR_VERSION_C != SCHM_MCL_AR_RELEASE_MAJOR_VERSION) || \
  143. (CACHE_IP_AR_RELEASE_MINOR_VERSION_C != SCHM_MCL_AR_RELEASE_MINOR_VERSION))
  144. #error "AutoSar Version Numbers of Cache_Ip.c and SchM_Mcl.h are different"
  145. #endif
  146. #endif
  147. /**
  148. * @page misra_violations MISRA-C:2012 violations
  149. */
  150. /*==================================================================================================
  151. * GLOBAL FUNCTIONS
  152. ==================================================================================================*/
  153. #define MCL_START_SEC_CODE
  154. /* @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. */
  155. #include "Mcl_MemMap.h"
  156. /***************************************************************************************************
  157. * @brief The function enables the specified cache.
  158. *
  159. * @param[in] CacheType - cache type
  160. ***************************************************************************************************/
  161. Std_ReturnType Cache_Ip_Enable(const Cache_Ip_Type CacheType)
  162. {
  163. Std_ReturnType Status = E_OK;
  164. /* Enter exclusive area to protect S32_SCB_CCR */
  165. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_13();
  166. switch(CacheType)
  167. {
  168. case CACHE_IP_ALL:{
  169. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  170. Cache_Ip_Enable_InstructionCache();
  171. #endif
  172. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  173. Cache_Ip_Enable_DataCache();
  174. #endif
  175. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  176. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  177. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  178. Status = ((Cache_Ip_Enable_AllCache() == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  179. #else
  180. Status = Cache_Ip_Enable_AllCache();
  181. #endif
  182. #else
  183. Status = Cache_Ip_Enable_AllCache();
  184. #endif
  185. #endif
  186. break;}
  187. case CACHE_IP_INSTRUCTION:{
  188. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  189. Cache_Ip_Enable_InstructionCache();
  190. #else
  191. CACHE_IP_DEV_ASSERT(FALSE);
  192. #endif
  193. break;}
  194. case CACHE_IP_DATA:{
  195. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  196. Cache_Ip_Enable_DataCache();
  197. #else
  198. CACHE_IP_DEV_ASSERT(FALSE);
  199. #endif
  200. break;}
  201. default:{
  202. CACHE_IP_DEV_ASSERT(FALSE);
  203. break;}
  204. }
  205. /* Exit exclusive area to protect S32_SCB_CCR */
  206. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_13();
  207. return Status;
  208. }
  209. /***************************************************************************************************
  210. * @brief The function disables the specified cache.
  211. *
  212. * @param[in] CacheType - cache type
  213. ***************************************************************************************************/
  214. Std_ReturnType Cache_Ip_Disable(const Cache_Ip_Type CacheType)
  215. {
  216. Std_ReturnType Status = E_OK;
  217. /* Enter exclusive area to protect S32_SCB_CCR */
  218. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_14();
  219. switch(CacheType)
  220. {
  221. case CACHE_IP_ALL:{
  222. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  223. Cache_Ip_Disable_InstructionCache();
  224. #endif
  225. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  226. Cache_Ip_Disable_DataCache();
  227. #endif
  228. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  229. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  230. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  231. Status = ((Cache_Ip_Disable_AllCache() == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  232. #else
  233. Status = Cache_Ip_Disable_AllCache();
  234. #endif
  235. #else
  236. Status = Cache_Ip_Disable_AllCache();
  237. #endif
  238. #endif
  239. break;}
  240. case CACHE_IP_INSTRUCTION:{
  241. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  242. Cache_Ip_Disable_InstructionCache();
  243. #else
  244. CACHE_IP_DEV_ASSERT(FALSE);
  245. #endif
  246. break;}
  247. case CACHE_IP_DATA:{
  248. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  249. Cache_Ip_Disable_DataCache();
  250. #else
  251. CACHE_IP_DEV_ASSERT(FALSE);
  252. #endif
  253. break;}
  254. default:{
  255. CACHE_IP_DEV_ASSERT(FALSE);
  256. break;}
  257. }
  258. /* Exit exclusive area to protect S32_SCB_CCR */
  259. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_14();
  260. return Status;
  261. }
  262. /***************************************************************************************************
  263. * @brief The function invalidates the specified cache.
  264. * @details The cache is invalidated by using set and way.
  265. *
  266. * @param[in] CacheType - cache type
  267. ***************************************************************************************************/
  268. Std_ReturnType Cache_Ip_Invalidate(const Cache_Ip_Type CacheType)
  269. {
  270. Std_ReturnType Status = E_OK;
  271. /* Enter exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIALLU */
  272. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_15();
  273. switch(CacheType)
  274. {
  275. case CACHE_IP_ALL:{
  276. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  277. Cache_Ip_Invalidate_InstructionCache();
  278. #endif
  279. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  280. Cache_Ip_Invalidate_DataCache();
  281. #endif
  282. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  283. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  284. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  285. Status = ((Cache_Ip_Invalidate_AllCache() == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  286. #else
  287. Status = Cache_Ip_Invalidate_AllCache();
  288. #endif
  289. #else
  290. Status = Cache_Ip_Invalidate_AllCache();
  291. #endif
  292. #endif
  293. break;}
  294. case CACHE_IP_INSTRUCTION:{
  295. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  296. Cache_Ip_Invalidate_InstructionCache();
  297. #else
  298. CACHE_IP_DEV_ASSERT(FALSE);
  299. #endif
  300. break;}
  301. case CACHE_IP_DATA:{
  302. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  303. Cache_Ip_Invalidate_DataCache();
  304. #else
  305. CACHE_IP_DEV_ASSERT(FALSE);
  306. #endif
  307. break;}
  308. default:{
  309. CACHE_IP_DEV_ASSERT(FALSE);
  310. break;}
  311. }
  312. /* Exit exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIALLU */
  313. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_15();
  314. return Status;
  315. }
  316. /***************************************************************************************************
  317. * @brief The function cleans the specified cache.
  318. * @details The cache is cleaned by using set and way.
  319. *
  320. * @param[in] CacheType - cache type
  321. * @param[in] EnInvalidate - enable invalidation
  322. ***************************************************************************************************/
  323. Std_ReturnType Cache_Ip_Clean(const Cache_Ip_Type CacheType, const boolean EnInvalidate)
  324. {
  325. Std_ReturnType Status = E_OK;
  326. /* Enter exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIALLU */
  327. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_16();
  328. switch(CacheType)
  329. {
  330. case CACHE_IP_ALL:{
  331. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  332. Cache_Ip_Clean_InstructionCache(EnInvalidate);
  333. #endif
  334. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  335. Cache_Ip_Clean_DataCache(EnInvalidate);
  336. #endif
  337. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  338. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  339. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  340. Status = ((Cache_Ip_Clean_AllCache(EnInvalidate) == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  341. #else
  342. Status = Cache_Ip_Clean_AllCache(EnInvalidate);
  343. #endif
  344. #else
  345. Status = Cache_Ip_Clean_AllCache(EnInvalidate);
  346. #endif
  347. #endif
  348. break;}
  349. case CACHE_IP_INSTRUCTION:{
  350. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  351. Cache_Ip_Clean_InstructionCache(EnInvalidate);
  352. #else
  353. CACHE_IP_DEV_ASSERT(FALSE);
  354. #endif
  355. break;}
  356. case CACHE_IP_DATA:{
  357. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  358. Cache_Ip_Clean_DataCache(EnInvalidate);
  359. #else
  360. CACHE_IP_DEV_ASSERT(FALSE);
  361. #endif
  362. break;}
  363. default:{
  364. CACHE_IP_DEV_ASSERT(FALSE);
  365. break;}
  366. }
  367. /* Exit exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIALLU */
  368. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_16();
  369. return Status;
  370. }
  371. /***************************************************************************************************
  372. * @brief The function invalidates by address the specified cache.
  373. *
  374. * @param[in] CacheType - cache type
  375. * @param[in] Addr - start address to be invalidated
  376. * @param[in] Length - address space Length to be invalidated
  377. ***************************************************************************************************/
  378. Std_ReturnType Cache_Ip_InvalidateByAddr(const Cache_Ip_Type CacheType, const uint32 Addr, const uint32 Length)
  379. {
  380. Std_ReturnType Status = E_OK;
  381. /* Enter exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIMVAU */
  382. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_17();
  383. switch(CacheType)
  384. {
  385. case CACHE_IP_ALL:{
  386. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  387. Cache_Ip_Invalidate_InstructionCacheByAddr(Addr, Length);
  388. #endif
  389. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  390. Cache_Ip_Invalidate_DataCacheByAddr(Addr, Length);
  391. #endif
  392. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  393. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  394. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  395. Status = ((Cache_Ip_Invalidate_AllCacheByAddr(Addr, Length) == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  396. #else
  397. Status = Cache_Ip_Invalidate_AllCacheByAddr(Addr, Length);
  398. #endif
  399. #else
  400. Status = Cache_Ip_Invalidate_AllCacheByAddr(Addr, Length);
  401. #endif
  402. #endif
  403. break;}
  404. case CACHE_IP_INSTRUCTION:{
  405. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  406. Cache_Ip_Invalidate_InstructionCacheByAddr(Addr, Length);
  407. #else
  408. CACHE_IP_DEV_ASSERT(FALSE);
  409. #endif
  410. break;}
  411. case CACHE_IP_DATA:{
  412. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  413. Cache_Ip_Invalidate_DataCacheByAddr(Addr, Length);
  414. #else
  415. CACHE_IP_DEV_ASSERT(FALSE);
  416. #endif
  417. break;}
  418. default:{
  419. CACHE_IP_DEV_ASSERT(FALSE);
  420. break;}
  421. }
  422. /* Exit exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIMVAU */
  423. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_17();
  424. return Status;
  425. }
  426. /***************************************************************************************************
  427. * @brief The function cleans by address the specified cache.
  428. *
  429. * @param[in] CacheType - cache type
  430. * @param[in] EnInvalidate - enable invalidation
  431. * @param[in] Addr - start address to be cleaned
  432. * @param[in] Length - address space Length to be cleaned
  433. ***************************************************************************************************/
  434. Std_ReturnType Cache_Ip_CleanByAddr(const Cache_Ip_Type CacheType, const boolean EnInvalidate, const uint32 Addr, const uint32 Length)
  435. {
  436. Std_ReturnType Status = E_OK;
  437. /* Enter exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIMVAU */
  438. SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_18();
  439. switch(CacheType)
  440. {
  441. case CACHE_IP_ALL:{
  442. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  443. Cache_Ip_Clean_InstructionCacheByAddr(EnInvalidate, Addr, Length);
  444. #endif
  445. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  446. Cache_Ip_Clean_DataCacheByAddr(EnInvalidate, Addr, Length);
  447. #endif
  448. #if (STD_ON == CACHE_IP_ALL_IS_AVAILABLE)
  449. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  450. #if (STD_ON == CACHE_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
  451. Status = ((Cache_Ip_Clean_AllCacheByAddr(EnInvalidate, Addr, Length) == 0x00000000U) ? (Std_ReturnType)E_OK : (Std_ReturnType)E_NOT_OK);
  452. #else
  453. Status = Cache_Ip_Clean_AllCacheByAddr(EnInvalidate, Addr, Length);
  454. #endif
  455. #else
  456. Status = Cache_Ip_Clean_AllCacheByAddr(EnInvalidate, Addr, Length);
  457. #endif
  458. #endif
  459. break;}
  460. case CACHE_IP_INSTRUCTION:{
  461. #if (STD_ON == CACHE_IP_INSTRUCTION_IS_AVAILABLE)
  462. Cache_Ip_Clean_InstructionCacheByAddr(EnInvalidate, Addr, Length);
  463. #else
  464. CACHE_IP_DEV_ASSERT(FALSE);
  465. #endif
  466. break;}
  467. case CACHE_IP_DATA:{
  468. #if (STD_ON == CACHE_IP_DATA_IS_AVAILABLE)
  469. Cache_Ip_Clean_DataCacheByAddr(EnInvalidate, Addr, Length);
  470. #else
  471. CACHE_IP_DEV_ASSERT(FALSE);
  472. #endif
  473. break;}
  474. default:{
  475. CACHE_IP_DEV_ASSERT(FALSE);
  476. break;}
  477. }
  478. /* Exit exclusive area to protect S32_SCB_CSSELR, S32_SCB_ICIMVAU */
  479. SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_18();
  480. return Status;
  481. }
  482. #define MCL_STOP_SEC_CODE
  483. /* @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. */
  484. #include "Mcl_MemMap.h"
  485. #endif /* #if (CACHE_IP_IS_AVAILABLE == STD_ON) */
  486. /** @} */
  487. /*==================================================================================================
  488. * END OF FILE
  489. ==================================================================================================*/