SchM_Uart.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  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_Uart.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_UART_AR_RELEASE_MAJOR_VERSION_C 4
  50. #define SCHM_UART_AR_RELEASE_MINOR_VERSION_C 4
  51. #define SCHM_UART_AR_RELEASE_REVISION_VERSION_C 0
  52. #define SCHM_UART_SW_MAJOR_VERSION_C 1
  53. #define SCHM_UART_SW_MINOR_VERSION_C 0
  54. #define SCHM_UART_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_UART_EXCLUSIVE_AREA_00[NUMBER_OF_CORES];
  107. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_00[NUMBER_OF_CORES];
  108. static volatile uint32 msr_UART_EXCLUSIVE_AREA_01[NUMBER_OF_CORES];
  109. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_01[NUMBER_OF_CORES];
  110. static volatile uint32 msr_UART_EXCLUSIVE_AREA_02[NUMBER_OF_CORES];
  111. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_02[NUMBER_OF_CORES];
  112. static volatile uint32 msr_UART_EXCLUSIVE_AREA_03[NUMBER_OF_CORES];
  113. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_03[NUMBER_OF_CORES];
  114. static volatile uint32 msr_UART_EXCLUSIVE_AREA_04[NUMBER_OF_CORES];
  115. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_04[NUMBER_OF_CORES];
  116. static volatile uint32 msr_UART_EXCLUSIVE_AREA_05[NUMBER_OF_CORES];
  117. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_05[NUMBER_OF_CORES];
  118. static volatile uint32 msr_UART_EXCLUSIVE_AREA_06[NUMBER_OF_CORES];
  119. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_06[NUMBER_OF_CORES];
  120. static volatile uint32 msr_UART_EXCLUSIVE_AREA_07[NUMBER_OF_CORES];
  121. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_07[NUMBER_OF_CORES];
  122. static volatile uint32 msr_UART_EXCLUSIVE_AREA_08[NUMBER_OF_CORES];
  123. static volatile uint32 reentry_guard_UART_EXCLUSIVE_AREA_08[NUMBER_OF_CORES];
  124. #define RTE_STOP_SEC_VAR_CLEARED_32_NO_CACHEABLE
  125. #include "Rte_MemMap.h"
  126. /*==================================================================================================
  127. * GLOBAL CONSTANTS
  128. ==================================================================================================*/
  129. /*==================================================================================================
  130. * GLOBAL VARIABLES
  131. ==================================================================================================*/
  132. /*==================================================================================================
  133. * LOCAL FUNCTION PROTOTYPES
  134. ==================================================================================================*/
  135. #ifndef _COSMIC_C_S32K1XX_
  136. /*================================================================================================*/
  137. /**
  138. * @brief This function returns the MSR register value (32 bits).
  139. * @details This function returns the MSR register value (32 bits).
  140. *
  141. * @param[in] void No input parameters
  142. * @return uint32 msr This function returns the MSR register value (32 bits).
  143. *
  144. * @pre None
  145. * @post None
  146. *
  147. */
  148. uint32 Uart_schm_read_msr(void);
  149. #endif /*ifndef _COSMIC_C_S32K1XX_*/
  150. /*==================================================================================================
  151. * LOCAL FUNCTIONS
  152. ==================================================================================================*/
  153. #define RTE_START_SEC_CODE
  154. #include "Rte_MemMap.h"
  155. #if (defined(_GREENHILLS_C_S32K1XX_) || defined(_CODEWARRIOR_C_S32K1XX_))
  156. /*================================================================================================*/
  157. /**
  158. * @brief This macro returns the MSR register value (32 bits).
  159. * @details This macro function implementation returns the MSR register value in r3 (32 bits).
  160. *
  161. * @pre None
  162. * @post None
  163. *
  164. */
  165. #ifdef MCAL_PLATFORM_ARM
  166. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  167. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  168. {
  169. mrs x0, S3_3_c4_c2_1
  170. }
  171. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  172. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  173. {
  174. mrs r0, CPSR
  175. }
  176. #else
  177. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  178. {
  179. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  180. mrs r0, BASEPRI
  181. #else
  182. mrs r0, PRIMASK
  183. #endif
  184. }
  185. #endif
  186. #else
  187. #ifdef MCAL_PLATFORM_S12
  188. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  189. {
  190. tfr ccr, d6
  191. }
  192. #else
  193. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  194. {
  195. mfmsr r3
  196. }
  197. #endif
  198. #endif
  199. #endif /*#ifdef GHS||CW*/
  200. #ifdef _DIABDATA_C_S32K1XX_
  201. /**
  202. * @brief This function returns the MSR register value (32 bits).
  203. * @details This function returns the MSR register value (32 bits).
  204. *
  205. * @param[in] void No input parameters
  206. * @return uint32 msr This function returns the MSR register value (32 bits).
  207. *
  208. * @pre None
  209. * @post None
  210. *
  211. */
  212. #ifdef MCAL_PLATFORM_ARM
  213. uint32 Uart_schm_read_msr(void)
  214. {
  215. register uint32 reg_tmp;
  216. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  217. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  218. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  219. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  220. #else
  221. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  222. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  223. #else
  224. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  225. #endif
  226. #endif
  227. return (uint32)reg_tmp;
  228. }
  229. #else
  230. ASM_KEYWORD uint32 Uart_schm_read_msr(void)
  231. {
  232. mfmsr r3
  233. }
  234. #endif /* MCAL_PLATFORM_ARM */
  235. #endif /* _DIABDATA_C_S32K1XX_*/
  236. #ifdef _COSMIC_C_S32K1XX_
  237. /*================================================================================================*/
  238. /**
  239. * @brief This function returns the MSR register value (32 bits).
  240. * @details This function returns the MSR register value (32 bits).
  241. *
  242. * @param[in] void No input parameters
  243. * @return uint32 msr This function returns the MSR register value (32 bits).
  244. *
  245. * @pre None
  246. * @post None
  247. *
  248. */
  249. #ifdef MCAL_PLATFORM_S12
  250. #define Uart_schm_read_msr() ASM_KEYWORD("tfr ccr, d6")
  251. #else
  252. #define Uart_schm_read_msr() ASM_KEYWORD("mfmsr r3")
  253. #endif
  254. #endif /*Cosmic compiler only*/
  255. #ifdef _HITECH_C_S32K1XX_
  256. /*================================================================================================*/
  257. /**
  258. * @brief This function returns the MSR register value (32 bits).
  259. * @details This function returns the MSR register value (32 bits).
  260. *
  261. * @param[in] void No input parameters
  262. * @return uint32 msr This function returns the MSR register value (32 bits).
  263. *
  264. * @pre None
  265. * @post None
  266. *
  267. */
  268. uint32 Uart_schm_read_msr(void)
  269. {
  270. uint32 result;
  271. __asm volatile("mfmsr %0" : "=r" (result) :);
  272. return result;
  273. }
  274. #endif /*HighTec compiler only*/
  275. /*================================================================================================*/
  276. #ifdef _LINARO_C_S32K1XX_
  277. /**
  278. * @brief This function returns the MSR register value (32 bits).
  279. * @details This function returns the MSR register value (32 bits).
  280. *
  281. * @param[in] void No input parameters
  282. * @return uint32 msr This function returns the MSR register value (32 bits).
  283. *
  284. * @pre None
  285. * @post None
  286. *
  287. */
  288. uint32 Uart_schm_read_msr(void)
  289. {
  290. register uint32 reg_tmp;
  291. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  292. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  293. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  294. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  295. #else
  296. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  297. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  298. #else
  299. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  300. #endif
  301. #endif
  302. return (uint32)reg_tmp;
  303. }
  304. #endif /* _LINARO_C_S32K1XX_*/
  305. /*================================================================================================*/
  306. #ifdef _ARM_DS5_C_S32K1XX_
  307. /**
  308. * @brief This function returns the MSR register value (32 bits).
  309. * @details This function returns the MSR register value (32 bits).
  310. *
  311. * @param[in] void No input parameters
  312. * @return uint32 msr This function returns the MSR register value (32 bits).
  313. *
  314. * @pre None
  315. * @post None
  316. *
  317. */
  318. uint32 Uart_schm_read_msr(void)
  319. {
  320. register uint32 reg_tmp;
  321. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  322. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  323. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  324. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  325. #else
  326. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  327. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  328. #else
  329. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  330. #endif
  331. #endif
  332. return (uint32)reg_tmp;
  333. }
  334. #endif /* _ARM_DS5_C_S32K1XX_ */
  335. #ifdef _IAR_C_S32K1XX_
  336. /**
  337. * @brief This function returns the MSR register value (32 bits).
  338. * @details This function returns the MSR register value (32 bits).
  339. *
  340. * @param[in] void No input parameters
  341. * @return uint32 msr This function returns the MSR register value (32 bits).
  342. *
  343. * @pre None
  344. * @post None
  345. *
  346. */
  347. uint32 Uart_schm_read_msr(void)
  348. {
  349. register uint32 reg_tmp;
  350. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  351. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  352. #else
  353. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  354. #endif
  355. return (uint32)reg_tmp;
  356. }
  357. #endif /* _IAR_C_S32K1XX_ */
  358. #define RTE_STOP_SEC_CODE
  359. #include "Rte_MemMap.h"
  360. /*==================================================================================================
  361. * GLOBAL FUNCTIONS
  362. ==================================================================================================*/
  363. #define RTE_START_SEC_CODE
  364. #include "Rte_MemMap.h"
  365. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_00(void)
  366. {
  367. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  368. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId])
  369. {
  370. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  371. msr_UART_EXCLUSIVE_AREA_00[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  372. #else
  373. msr_UART_EXCLUSIVE_AREA_00[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  374. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  375. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_00[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  376. {
  377. OsIf_SuspendAllInterrupts();
  378. #ifdef _ARM_DS5_C_S32K1XX_
  379. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  380. #endif
  381. }
  382. }
  383. reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId]++;
  384. }
  385. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_00(void)
  386. {
  387. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  388. reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId]--;
  389. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_00[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId])) /*if interrupts were enabled*/
  390. {
  391. OsIf_ResumeAllInterrupts();
  392. #ifdef _ARM_DS5_C_S32K1XX_
  393. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  394. #endif
  395. }
  396. }
  397. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_01(void)
  398. {
  399. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  400. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId])
  401. {
  402. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  403. msr_UART_EXCLUSIVE_AREA_01[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  404. #else
  405. msr_UART_EXCLUSIVE_AREA_01[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  406. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  407. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_01[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  408. {
  409. OsIf_SuspendAllInterrupts();
  410. #ifdef _ARM_DS5_C_S32K1XX_
  411. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  412. #endif
  413. }
  414. }
  415. reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId]++;
  416. }
  417. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_01(void)
  418. {
  419. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  420. reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId]--;
  421. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_01[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId])) /*if interrupts were enabled*/
  422. {
  423. OsIf_ResumeAllInterrupts();
  424. #ifdef _ARM_DS5_C_S32K1XX_
  425. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  426. #endif
  427. }
  428. }
  429. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_02(void)
  430. {
  431. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  432. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId])
  433. {
  434. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  435. msr_UART_EXCLUSIVE_AREA_02[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  436. #else
  437. msr_UART_EXCLUSIVE_AREA_02[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  438. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  439. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_02[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  440. {
  441. OsIf_SuspendAllInterrupts();
  442. #ifdef _ARM_DS5_C_S32K1XX_
  443. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  444. #endif
  445. }
  446. }
  447. reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId]++;
  448. }
  449. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_02(void)
  450. {
  451. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  452. reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId]--;
  453. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_02[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId])) /*if interrupts were enabled*/
  454. {
  455. OsIf_ResumeAllInterrupts();
  456. #ifdef _ARM_DS5_C_S32K1XX_
  457. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  458. #endif
  459. }
  460. }
  461. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_03(void)
  462. {
  463. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  464. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId])
  465. {
  466. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  467. msr_UART_EXCLUSIVE_AREA_03[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  468. #else
  469. msr_UART_EXCLUSIVE_AREA_03[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  470. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  471. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_03[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  472. {
  473. OsIf_SuspendAllInterrupts();
  474. #ifdef _ARM_DS5_C_S32K1XX_
  475. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  476. #endif
  477. }
  478. }
  479. reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId]++;
  480. }
  481. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_03(void)
  482. {
  483. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  484. reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId]--;
  485. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_03[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId])) /*if interrupts were enabled*/
  486. {
  487. OsIf_ResumeAllInterrupts();
  488. #ifdef _ARM_DS5_C_S32K1XX_
  489. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  490. #endif
  491. }
  492. }
  493. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_04(void)
  494. {
  495. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  496. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId])
  497. {
  498. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  499. msr_UART_EXCLUSIVE_AREA_04[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  500. #else
  501. msr_UART_EXCLUSIVE_AREA_04[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  502. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  503. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_04[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  504. {
  505. OsIf_SuspendAllInterrupts();
  506. #ifdef _ARM_DS5_C_S32K1XX_
  507. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  508. #endif
  509. }
  510. }
  511. reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId]++;
  512. }
  513. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_04(void)
  514. {
  515. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  516. reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId]--;
  517. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_04[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId])) /*if interrupts were enabled*/
  518. {
  519. OsIf_ResumeAllInterrupts();
  520. #ifdef _ARM_DS5_C_S32K1XX_
  521. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  522. #endif
  523. }
  524. }
  525. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_05(void)
  526. {
  527. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  528. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId])
  529. {
  530. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  531. msr_UART_EXCLUSIVE_AREA_05[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  532. #else
  533. msr_UART_EXCLUSIVE_AREA_05[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  534. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  535. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_05[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  536. {
  537. OsIf_SuspendAllInterrupts();
  538. #ifdef _ARM_DS5_C_S32K1XX_
  539. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  540. #endif
  541. }
  542. }
  543. reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId]++;
  544. }
  545. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_05(void)
  546. {
  547. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  548. reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId]--;
  549. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_05[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId])) /*if interrupts were enabled*/
  550. {
  551. OsIf_ResumeAllInterrupts();
  552. #ifdef _ARM_DS5_C_S32K1XX_
  553. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  554. #endif
  555. }
  556. }
  557. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_06(void)
  558. {
  559. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  560. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId])
  561. {
  562. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  563. msr_UART_EXCLUSIVE_AREA_06[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  564. #else
  565. msr_UART_EXCLUSIVE_AREA_06[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  566. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  567. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_06[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  568. {
  569. OsIf_SuspendAllInterrupts();
  570. #ifdef _ARM_DS5_C_S32K1XX_
  571. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  572. #endif
  573. }
  574. }
  575. reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId]++;
  576. }
  577. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_06(void)
  578. {
  579. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  580. reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId]--;
  581. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_06[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId])) /*if interrupts were enabled*/
  582. {
  583. OsIf_ResumeAllInterrupts();
  584. #ifdef _ARM_DS5_C_S32K1XX_
  585. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  586. #endif
  587. }
  588. }
  589. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_07(void)
  590. {
  591. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  592. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId])
  593. {
  594. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  595. msr_UART_EXCLUSIVE_AREA_07[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  596. #else
  597. msr_UART_EXCLUSIVE_AREA_07[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  598. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  599. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_07[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  600. {
  601. OsIf_SuspendAllInterrupts();
  602. #ifdef _ARM_DS5_C_S32K1XX_
  603. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  604. #endif
  605. }
  606. }
  607. reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId]++;
  608. }
  609. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_07(void)
  610. {
  611. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  612. reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId]--;
  613. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_07[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId])) /*if interrupts were enabled*/
  614. {
  615. OsIf_ResumeAllInterrupts();
  616. #ifdef _ARM_DS5_C_S32K1XX_
  617. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  618. #endif
  619. }
  620. }
  621. void SchM_Enter_Uart_UART_EXCLUSIVE_AREA_08(void)
  622. {
  623. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  624. if(0UL == reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId])
  625. {
  626. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  627. msr_UART_EXCLUSIVE_AREA_08[u32CoreId] = OsIf_Trusted_Call_Return(Uart_schm_read_msr);
  628. #else
  629. msr_UART_EXCLUSIVE_AREA_08[u32CoreId] = Uart_schm_read_msr(); /*read MSR (to store interrupts state)*/
  630. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  631. if (ISR_ON(msr_UART_EXCLUSIVE_AREA_08[u32CoreId])) /*if MSR[EE] = 0, skip calling Suspend/Resume AllInterrupts*/
  632. {
  633. OsIf_SuspendAllInterrupts();
  634. #ifdef _ARM_DS5_C_S32K1XX_
  635. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  636. #endif
  637. }
  638. }
  639. reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId]++;
  640. }
  641. void SchM_Exit_Uart_UART_EXCLUSIVE_AREA_08(void)
  642. {
  643. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  644. reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId]--;
  645. if ((ISR_ON(msr_UART_EXCLUSIVE_AREA_08[u32CoreId]))&&(0UL == reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId])) /*if interrupts were enabled*/
  646. {
  647. OsIf_ResumeAllInterrupts();
  648. #ifdef _ARM_DS5_C_S32K1XX_
  649. ASM_KEYWORD(" nop ");/* Compiler fix - forces the CSPID instruction to be generated with -02, -Ospace are selected*/
  650. #endif
  651. }
  652. }
  653. #ifdef MCAL_TESTING_ENVIRONMENT
  654. /**
  655. @brief This function checks that all entered exclusive areas were also exited.
  656. @details This function checks that all entered exclusive areas were also exited. The check
  657. is done by verifying that all reentry_guard_* static variables are back to the
  658. zero value.
  659. @param[in] void No input parameters
  660. @return void This function does not return a value. Test asserts are used instead.
  661. @pre None
  662. @post None
  663. @remarks Covers
  664. @remarks Implements
  665. */
  666. void SchM_Check_uart(void)
  667. {
  668. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  669. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId]);
  670. reentry_guard_UART_EXCLUSIVE_AREA_00[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_00 for the next test in the suite*/
  671. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId]);
  672. reentry_guard_UART_EXCLUSIVE_AREA_01[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_01 for the next test in the suite*/
  673. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId]);
  674. reentry_guard_UART_EXCLUSIVE_AREA_02[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_02 for the next test in the suite*/
  675. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId]);
  676. reentry_guard_UART_EXCLUSIVE_AREA_03[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_03 for the next test in the suite*/
  677. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId]);
  678. reentry_guard_UART_EXCLUSIVE_AREA_04[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_04 for the next test in the suite*/
  679. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId]);
  680. reentry_guard_UART_EXCLUSIVE_AREA_05[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_05 for the next test in the suite*/
  681. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId]);
  682. reentry_guard_UART_EXCLUSIVE_AREA_06[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_06 for the next test in the suite*/
  683. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId]);
  684. reentry_guard_UART_EXCLUSIVE_AREA_07[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_07 for the next test in the suite*/
  685. EU_ASSERT(0UL == reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId]);
  686. reentry_guard_UART_EXCLUSIVE_AREA_08[u32CoreId] = 0UL; /*reset reentry_guard_UART_EXCLUSIVE_AREA_08 for the next test in the suite*/
  687. }
  688. #endif /*MCAL_TESTING_ENVIRONMENT*/
  689. #define RTE_STOP_SEC_CODE
  690. #include "Rte_MemMap.h"
  691. #ifdef __cplusplus
  692. }
  693. #endif
  694. /** @} */