SchM_Fee.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral :
  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
  26. *
  27. * @addtogroup RTE_MODULE
  28. * @{
  29. */
  30. #ifdef __cplusplus
  31. extern "C"{
  32. #endif
  33. /*==================================================================================================
  34. * INCLUDE FILES
  35. * 1) system and project includes
  36. * 2) needed interfaces from external units
  37. * 3) internal and external interfaces from this unit
  38. ==================================================================================================*/
  39. #include "Std_Types.h"
  40. #include "Mcal.h"
  41. #include "OsIf.h"
  42. #include "SchM_Fee.h"
  43. #ifdef MCAL_TESTING_ENVIRONMENT
  44. #include "EUnit.h" /* EUnit Test Suite */
  45. #endif
  46. /*==================================================================================================
  47. * SOURCE FILE VERSION INFORMATION
  48. ==================================================================================================*/
  49. #define SCHM_FEE_AR_RELEASE_MAJOR_VERSION_C 4
  50. #define SCHM_FEE_AR_RELEASE_MINOR_VERSION_C 4
  51. #define SCHM_FEE_AR_RELEASE_REVISION_VERSION_C 0
  52. #define SCHM_FEE_SW_MAJOR_VERSION_C 1
  53. #define SCHM_FEE_SW_MINOR_VERSION_C 0
  54. #define SCHM_FEE_SW_PATCH_VERSION_C 0
  55. /*==================================================================================================
  56. * LOCAL CONSTANTS
  57. ==================================================================================================*/
  58. #ifdef MCAL_PLATFORM_ARM
  59. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  60. #define ISR_STATE_MASK ((uint32)0x00000002UL) /**< @brief DAIF bit I and F */
  61. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  62. #define ISR_STATE_MASK ((uint32)0x00000080UL) /**< @brief CPSR bit I */
  63. #else
  64. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  65. #define ISR_STATE_MASK ((uint32)0x000000FFUL) /**< @brief BASEPRI[7:0] mask */
  66. #else
  67. #define ISR_STATE_MASK ((uint32)0x00000001UL) /**< @brief PRIMASK bit 0 */
  68. #endif
  69. #endif
  70. #else
  71. #ifdef MCAL_PLATFORM_S12
  72. #define ISR_STATE_MASK ((uint32)0x00000010UL) /**< @brief I bit of CCR */
  73. #else
  74. #define ISR_STATE_MASK ((uint32)0x00008000UL) /**< @brief EE bit of MSR */
  75. #endif
  76. #endif
  77. /*==================================================================================================
  78. * LOCAL MACROS
  79. ==================================================================================================*/
  80. #ifdef MCAL_PLATFORM_ARM
  81. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  82. #define ISR_ON(msr) (uint32)(((uint32)(msr) & (uint32)(ISR_STATE_MASK)) != (uint32)3)
  83. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  84. #define ISR_ON(msr) (uint32)(((uint32)(msr) & (uint32)(ISR_STATE_MASK)) != (uint32)(ISR_STATE_MASK))
  85. #else
  86. #define ISR_ON(msr) (uint32)(((uint32)(msr) & (uint32)(ISR_STATE_MASK)) == (uint32)0)
  87. #endif
  88. #else
  89. #ifdef MCAL_PLATFORM_S12
  90. #define ISR_ON(msr) (uint32)(((uint32)(msr) & (uint32)(ISR_STATE_MASK)) == (uint32)0)
  91. #else
  92. #define ISR_ON(msr) (uint32)((uint32)(msr) & (uint32)(ISR_STATE_MASK))
  93. #endif
  94. #endif
  95. /*==================================================================================================
  96. * FILE VERSION CHECKS
  97. ==================================================================================================*/
  98. /*==================================================================================================
  99. * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  100. ==================================================================================================*/
  101. /*==================================================================================================
  102. * LOCAL VARIABLES
  103. ==================================================================================================*/
  104. #define RTE_START_SEC_VAR_CLEARED_32_NO_CACHEABLE
  105. #include "Rte_MemMap.h"
  106. static volatile uint32 msr_FEE_EXCLUSIVE_AREA_00[NUMBER_OF_CORES];
  107. static volatile uint32 reentry_guard_FEE_EXCLUSIVE_AREA_00[NUMBER_OF_CORES];
  108. static volatile uint32 msr_FEE_EXCLUSIVE_AREA_01[NUMBER_OF_CORES];
  109. static volatile uint32 reentry_guard_FEE_EXCLUSIVE_AREA_01[NUMBER_OF_CORES];
  110. static volatile uint32 msr_FEE_EXCLUSIVE_AREA_02[NUMBER_OF_CORES];
  111. static volatile uint32 reentry_guard_FEE_EXCLUSIVE_AREA_02[NUMBER_OF_CORES];
  112. static volatile uint32 msr_FEE_EXCLUSIVE_AREA_03[NUMBER_OF_CORES];
  113. static volatile uint32 reentry_guard_FEE_EXCLUSIVE_AREA_03[NUMBER_OF_CORES];
  114. #define RTE_STOP_SEC_VAR_CLEARED_32_NO_CACHEABLE
  115. #include "Rte_MemMap.h"
  116. /*==================================================================================================
  117. * GLOBAL CONSTANTS
  118. ==================================================================================================*/
  119. /*==================================================================================================
  120. * GLOBAL VARIABLES
  121. ==================================================================================================*/
  122. /*==================================================================================================
  123. * LOCAL FUNCTION PROTOTYPES
  124. ==================================================================================================*/
  125. #ifndef _COSMIC_C_S32K1XX_
  126. /*================================================================================================*/
  127. /**
  128. * @brief This function returns the MSR register value (32 bits).
  129. * @details This function returns the MSR register value (32 bits).
  130. *
  131. * @param[in] void No input parameters
  132. * @return uint32 msr This function returns the MSR register value (32 bits).
  133. *
  134. * @pre None
  135. * @post None
  136. *
  137. */
  138. uint32 Fee_schm_read_msr(void);
  139. #endif /*ifndef _COSMIC_C_S32K1XX_*/
  140. /*==================================================================================================
  141. * LOCAL FUNCTIONS
  142. ==================================================================================================*/
  143. #define RTE_START_SEC_CODE
  144. #include "Rte_MemMap.h"
  145. #if (defined(_GREENHILLS_C_S32K1XX_) || defined(_CODEWARRIOR_C_S32K1XX_))
  146. /*================================================================================================*/
  147. /**
  148. * @brief This macro returns the MSR register value (32 bits).
  149. * @details This macro function implementation returns the MSR register value in r3 (32 bits).
  150. *
  151. * @pre None
  152. * @post None
  153. *
  154. */
  155. #ifdef MCAL_PLATFORM_ARM
  156. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  157. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  158. {
  159. mrs x0, S3_3_c4_c2_1
  160. }
  161. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  162. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  163. {
  164. mrs r0, CPSR
  165. }
  166. #else
  167. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  168. {
  169. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  170. mrs r0, BASEPRI
  171. #else
  172. mrs r0, PRIMASK
  173. #endif
  174. }
  175. #endif
  176. #else
  177. #ifdef MCAL_PLATFORM_S12
  178. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  179. {
  180. tfr ccr, d6
  181. }
  182. #else
  183. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  184. {
  185. mfmsr r3
  186. }
  187. #endif
  188. #endif
  189. #endif /*#ifdef GHS||CW*/
  190. #ifdef _DIABDATA_C_S32K1XX_
  191. /**
  192. * @brief This function returns the MSR register value (32 bits).
  193. * @details This function returns the MSR register value (32 bits).
  194. *
  195. * @param[in] void No input parameters
  196. * @return uint32 msr This function returns the MSR register value (32 bits).
  197. *
  198. * @pre None
  199. * @post None
  200. *
  201. */
  202. #ifdef MCAL_PLATFORM_ARM
  203. uint32 Fee_schm_read_msr(void)
  204. {
  205. register uint32 reg_tmp;
  206. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  207. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  208. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  209. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  210. #else
  211. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  212. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  213. #else
  214. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  215. #endif
  216. #endif
  217. return (uint32)reg_tmp;
  218. }
  219. #else
  220. ASM_KEYWORD uint32 Fee_schm_read_msr(void)
  221. {
  222. mfmsr r3
  223. }
  224. #endif /* MCAL_PLATFORM_ARM */
  225. #endif /* _DIABDATA_C_S32K1XX_*/
  226. #ifdef _COSMIC_C_S32K1XX_
  227. /*================================================================================================*/
  228. /**
  229. * @brief This function returns the MSR register value (32 bits).
  230. * @details This function returns the MSR register value (32 bits).
  231. *
  232. * @param[in] void No input parameters
  233. * @return uint32 msr This function returns the MSR register value (32 bits).
  234. *
  235. * @pre None
  236. * @post None
  237. *
  238. */
  239. #ifdef MCAL_PLATFORM_S12
  240. #define Fee_schm_read_msr() ASM_KEYWORD("tfr ccr, d6")
  241. #else
  242. #define Fee_schm_read_msr() ASM_KEYWORD("mfmsr r3")
  243. #endif
  244. #endif /*Cosmic compiler only*/
  245. #ifdef _HITECH_C_S32K1XX_
  246. /*================================================================================================*/
  247. /**
  248. * @brief This function returns the MSR register value (32 bits).
  249. * @details This function returns the MSR register value (32 bits).
  250. *
  251. * @param[in] void No input parameters
  252. * @return uint32 msr This function returns the MSR register value (32 bits).
  253. *
  254. * @pre None
  255. * @post None
  256. *
  257. */
  258. uint32 Fee_schm_read_msr(void)
  259. {
  260. uint32 result;
  261. __asm volatile("mfmsr %0" : "=r" (result) :);
  262. return result;
  263. }
  264. #endif /*HighTec compiler only*/
  265. /*================================================================================================*/
  266. #ifdef _LINARO_C_S32K1XX_
  267. /**
  268. * @brief This function returns the MSR register value (32 bits).
  269. * @details This function returns the MSR register value (32 bits).
  270. *
  271. * @param[in] void No input parameters
  272. * @return uint32 msr This function returns the MSR register value (32 bits).
  273. *
  274. * @pre None
  275. * @post None
  276. *
  277. */
  278. uint32 Fee_schm_read_msr(void)
  279. {
  280. register uint32 reg_tmp;
  281. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  282. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  283. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  284. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  285. #else
  286. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  287. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  288. #else
  289. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  290. #endif
  291. #endif
  292. return (uint32)reg_tmp;
  293. }
  294. #endif /* _LINARO_C_S32K1XX_*/
  295. /*================================================================================================*/
  296. #ifdef _ARM_DS5_C_S32K1XX_
  297. /**
  298. * @brief This function returns the MSR register value (32 bits).
  299. * @details This function returns the MSR register value (32 bits).
  300. *
  301. * @param[in] void No input parameters
  302. * @return uint32 msr This function returns the MSR register value (32 bits).
  303. *
  304. * @pre None
  305. * @post None
  306. *
  307. */
  308. uint32 Fee_schm_read_msr(void)
  309. {
  310. register uint32 reg_tmp;
  311. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  312. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  313. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  314. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  315. #else
  316. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  317. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  318. #else
  319. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  320. #endif
  321. #endif
  322. return (uint32)reg_tmp;
  323. }
  324. #endif /* _ARM_DS5_C_S32K1XX_ */
  325. #ifdef _IAR_C_S32K1XX_
  326. /**
  327. * @brief This function returns the MSR register value (32 bits).
  328. * @details This function returns the MSR register value (32 bits).
  329. *
  330. * @param[in] void No input parameters
  331. * @return uint32 msr This function returns the MSR register value (32 bits).
  332. *
  333. * @pre None
  334. * @post None
  335. *
  336. */
  337. uint32 Fee_schm_read_msr(void)
  338. {
  339. register uint32 reg_tmp;
  340. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  341. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  342. #else
  343. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  344. #endif
  345. return (uint32)reg_tmp;
  346. }
  347. #endif /* _IAR_C_S32K1XX_ */
  348. #define RTE_STOP_SEC_CODE
  349. #include "Rte_MemMap.h"
  350. /*==================================================================================================
  351. * GLOBAL FUNCTIONS
  352. ==================================================================================================*/
  353. #define RTE_START_SEC_CODE
  354. #include "Rte_MemMap.h"
  355. void SchM_Enter_Fee_FEE_EXCLUSIVE_AREA_00(void)
  356. {
  357. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  358. if(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId])
  359. {
  360. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  361. msr_FEE_EXCLUSIVE_AREA_00[u32CoreId] = OsIf_Trusted_Call_Return(Fee_schm_read_msr);
  362. #else
  363. msr_FEE_EXCLUSIVE_AREA_00[u32CoreId] = Fee_schm_read_msr(); /*read MSR (to store interrupts state)*/
  364. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  365. if (ISR_ON(msr_FEE_EXCLUSIVE_AREA_00[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  366. {
  367. OsIf_SuspendAllInterrupts();
  368. #ifdef _ARM_DS5_C_S32K1XX_
  369. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  370. #endif
  371. }
  372. }
  373. reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId]++;
  374. }
  375. void SchM_Exit_Fee_FEE_EXCLUSIVE_AREA_00(void)
  376. {
  377. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  378. reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId]--;
  379. if ((ISR_ON(msr_FEE_EXCLUSIVE_AREA_00[u32CoreId]))&&(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId])) /*if interrupts were enabled*/
  380. {
  381. OsIf_ResumeAllInterrupts();
  382. #ifdef _ARM_DS5_C_S32K1XX_
  383. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  384. #endif
  385. }
  386. }
  387. void SchM_Enter_Fee_FEE_EXCLUSIVE_AREA_01(void)
  388. {
  389. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  390. if(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId])
  391. {
  392. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  393. msr_FEE_EXCLUSIVE_AREA_01[u32CoreId] = OsIf_Trusted_Call_Return(Fee_schm_read_msr);
  394. #else
  395. msr_FEE_EXCLUSIVE_AREA_01[u32CoreId] = Fee_schm_read_msr(); /*read MSR (to store interrupts state)*/
  396. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  397. if (ISR_ON(msr_FEE_EXCLUSIVE_AREA_01[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  398. {
  399. OsIf_SuspendAllInterrupts();
  400. #ifdef _ARM_DS5_C_S32K1XX_
  401. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  402. #endif
  403. }
  404. }
  405. reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId]++;
  406. }
  407. void SchM_Exit_Fee_FEE_EXCLUSIVE_AREA_01(void)
  408. {
  409. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  410. reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId]--;
  411. if ((ISR_ON(msr_FEE_EXCLUSIVE_AREA_01[u32CoreId]))&&(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId])) /*if interrupts were enabled*/
  412. {
  413. OsIf_ResumeAllInterrupts();
  414. #ifdef _ARM_DS5_C_S32K1XX_
  415. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  416. #endif
  417. }
  418. }
  419. void SchM_Enter_Fee_FEE_EXCLUSIVE_AREA_02(void)
  420. {
  421. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  422. if(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId])
  423. {
  424. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  425. msr_FEE_EXCLUSIVE_AREA_02[u32CoreId] = OsIf_Trusted_Call_Return(Fee_schm_read_msr);
  426. #else
  427. msr_FEE_EXCLUSIVE_AREA_02[u32CoreId] = Fee_schm_read_msr(); /*read MSR (to store interrupts state)*/
  428. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  429. if (ISR_ON(msr_FEE_EXCLUSIVE_AREA_02[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  430. {
  431. OsIf_SuspendAllInterrupts();
  432. #ifdef _ARM_DS5_C_S32K1XX_
  433. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  434. #endif
  435. }
  436. }
  437. reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId]++;
  438. }
  439. void SchM_Exit_Fee_FEE_EXCLUSIVE_AREA_02(void)
  440. {
  441. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  442. reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId]--;
  443. if ((ISR_ON(msr_FEE_EXCLUSIVE_AREA_02[u32CoreId]))&&(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId])) /*if interrupts were enabled*/
  444. {
  445. OsIf_ResumeAllInterrupts();
  446. #ifdef _ARM_DS5_C_S32K1XX_
  447. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  448. #endif
  449. }
  450. }
  451. void SchM_Enter_Fee_FEE_EXCLUSIVE_AREA_03(void)
  452. {
  453. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  454. if(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId])
  455. {
  456. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  457. msr_FEE_EXCLUSIVE_AREA_03[u32CoreId] = OsIf_Trusted_Call_Return(Fee_schm_read_msr);
  458. #else
  459. msr_FEE_EXCLUSIVE_AREA_03[u32CoreId] = Fee_schm_read_msr(); /*read MSR (to store interrupts state)*/
  460. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  461. if (ISR_ON(msr_FEE_EXCLUSIVE_AREA_03[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  462. {
  463. OsIf_SuspendAllInterrupts();
  464. #ifdef _ARM_DS5_C_S32K1XX_
  465. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  466. #endif
  467. }
  468. }
  469. reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId]++;
  470. }
  471. void SchM_Exit_Fee_FEE_EXCLUSIVE_AREA_03(void)
  472. {
  473. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  474. reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId]--;
  475. if ((ISR_ON(msr_FEE_EXCLUSIVE_AREA_03[u32CoreId]))&&(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId])) /*if interrupts were enabled*/
  476. {
  477. OsIf_ResumeAllInterrupts();
  478. #ifdef _ARM_DS5_C_S32K1XX_
  479. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  480. #endif
  481. }
  482. }
  483. #ifdef MCAL_TESTING_ENVIRONMENT
  484. /**
  485. @brief This function checks that all entered exclusive areas were also exited.
  486. @details This function checks that all entered exclusive areas were also exited. The check
  487. is done by verifying that all reentry_guard_* static variables are back to the
  488. zero value.
  489. @param[in] void No input parameters
  490. @return void This function does not return a value. Test asserts are used instead.
  491. @pre None
  492. @post None
  493. @remarks Covers
  494. @remarks Implements
  495. */
  496. void SchM_Check_fee(void)
  497. {
  498. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  499. EU_ASSERT(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId]);
  500. reentry_guard_FEE_EXCLUSIVE_AREA_00[u32CoreId] = 0UL; /*reset reentry_guard_FEE_EXCLUSIVE_AREA_00 for the next test in the suite*/
  501. EU_ASSERT(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId]);
  502. reentry_guard_FEE_EXCLUSIVE_AREA_01[u32CoreId] = 0UL; /*reset reentry_guard_FEE_EXCLUSIVE_AREA_01 for the next test in the suite*/
  503. EU_ASSERT(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId]);
  504. reentry_guard_FEE_EXCLUSIVE_AREA_02[u32CoreId] = 0UL; /*reset reentry_guard_FEE_EXCLUSIVE_AREA_02 for the next test in the suite*/
  505. EU_ASSERT(0UL == reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId]);
  506. reentry_guard_FEE_EXCLUSIVE_AREA_03[u32CoreId] = 0UL; /*reset reentry_guard_FEE_EXCLUSIVE_AREA_03 for the next test in the suite*/
  507. }
  508. #endif /*MCAL_TESTING_ENVIRONMENT*/
  509. #define RTE_STOP_SEC_CODE
  510. #include "Rte_MemMap.h"
  511. #ifdef __cplusplus
  512. }
  513. #endif
  514. /** @} */