SchM_Eth.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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_Eth.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_ETH_AR_RELEASE_MAJOR_VERSION_C 4
  50. #define SCHM_ETH_AR_RELEASE_MINOR_VERSION_C 4
  51. #define SCHM_ETH_AR_RELEASE_REVISION_VERSION_C 0
  52. #define SCHM_ETH_SW_MAJOR_VERSION_C 1
  53. #define SCHM_ETH_SW_MINOR_VERSION_C 0
  54. #define SCHM_ETH_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. #define RTE_STOP_SEC_VAR_CLEARED_32_NO_CACHEABLE
  107. #include "Rte_MemMap.h"
  108. /*==================================================================================================
  109. * GLOBAL CONSTANTS
  110. ==================================================================================================*/
  111. /*==================================================================================================
  112. * GLOBAL VARIABLES
  113. ==================================================================================================*/
  114. /*==================================================================================================
  115. * LOCAL FUNCTION PROTOTYPES
  116. ==================================================================================================*/
  117. #ifndef _COSMIC_C_S32K1XX_
  118. /*================================================================================================*/
  119. /**
  120. * @brief This function returns the MSR register value (32 bits).
  121. * @details This function returns the MSR register value (32 bits).
  122. *
  123. * @param[in] void No input parameters
  124. * @return uint32 msr This function returns the MSR register value (32 bits).
  125. *
  126. * @pre None
  127. * @post None
  128. *
  129. */
  130. uint32 Eth_schm_read_msr(void);
  131. #endif /*ifndef _COSMIC_C_S32K1XX_*/
  132. /*==================================================================================================
  133. * LOCAL FUNCTIONS
  134. ==================================================================================================*/
  135. #define RTE_START_SEC_CODE
  136. #include "Rte_MemMap.h"
  137. #if (defined(_GREENHILLS_C_S32K1XX_) || defined(_CODEWARRIOR_C_S32K1XX_))
  138. /*================================================================================================*/
  139. /**
  140. * @brief This macro returns the MSR register value (32 bits).
  141. * @details This macro function implementation returns the MSR register value in r3 (32 bits).
  142. *
  143. * @pre None
  144. * @post None
  145. *
  146. */
  147. #ifdef MCAL_PLATFORM_ARM
  148. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  149. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  150. {
  151. mrs x0, S3_3_c4_c2_1
  152. }
  153. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  154. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  155. {
  156. mrs r0, CPSR
  157. }
  158. #else
  159. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  160. {
  161. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  162. mrs r0, BASEPRI
  163. #else
  164. mrs r0, PRIMASK
  165. #endif
  166. }
  167. #endif
  168. #else
  169. #ifdef MCAL_PLATFORM_S12
  170. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  171. {
  172. tfr ccr, d6
  173. }
  174. #else
  175. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  176. {
  177. mfmsr r3
  178. }
  179. #endif
  180. #endif
  181. #endif /*#ifdef GHS||CW*/
  182. #ifdef _DIABDATA_C_S32K1XX_
  183. /**
  184. * @brief This function returns the MSR register value (32 bits).
  185. * @details This function returns the MSR register value (32 bits).
  186. *
  187. * @param[in] void No input parameters
  188. * @return uint32 msr This function returns the MSR register value (32 bits).
  189. *
  190. * @pre None
  191. * @post None
  192. *
  193. */
  194. #ifdef MCAL_PLATFORM_ARM
  195. uint32 Eth_schm_read_msr(void)
  196. {
  197. register uint32 reg_tmp;
  198. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  199. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  200. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  201. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  202. #else
  203. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  204. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  205. #else
  206. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  207. #endif
  208. #endif
  209. return (uint32)reg_tmp;
  210. }
  211. #else
  212. ASM_KEYWORD uint32 Eth_schm_read_msr(void)
  213. {
  214. mfmsr r3
  215. }
  216. #endif /* MCAL_PLATFORM_ARM */
  217. #endif /* _DIABDATA_C_S32K1XX_*/
  218. #ifdef _COSMIC_C_S32K1XX_
  219. /*================================================================================================*/
  220. /**
  221. * @brief This function returns the MSR register value (32 bits).
  222. * @details This function returns the MSR register value (32 bits).
  223. *
  224. * @param[in] void No input parameters
  225. * @return uint32 msr This function returns the MSR register value (32 bits).
  226. *
  227. * @pre None
  228. * @post None
  229. *
  230. */
  231. #ifdef MCAL_PLATFORM_S12
  232. #define Eth_schm_read_msr() ASM_KEYWORD("tfr ccr, d6")
  233. #else
  234. #define Eth_schm_read_msr() ASM_KEYWORD("mfmsr r3")
  235. #endif
  236. #endif /*Cosmic compiler only*/
  237. #ifdef _HITECH_C_S32K1XX_
  238. /*================================================================================================*/
  239. /**
  240. * @brief This function returns the MSR register value (32 bits).
  241. * @details This function returns the MSR register value (32 bits).
  242. *
  243. * @param[in] void No input parameters
  244. * @return uint32 msr This function returns the MSR register value (32 bits).
  245. *
  246. * @pre None
  247. * @post None
  248. *
  249. */
  250. uint32 Eth_schm_read_msr(void)
  251. {
  252. uint32 result;
  253. __asm volatile("mfmsr %0" : "=r" (result) :);
  254. return result;
  255. }
  256. #endif /*HighTec compiler only*/
  257. /*================================================================================================*/
  258. #ifdef _LINARO_C_S32K1XX_
  259. /**
  260. * @brief This function returns the MSR register value (32 bits).
  261. * @details This function returns the MSR register value (32 bits).
  262. *
  263. * @param[in] void No input parameters
  264. * @return uint32 msr This function returns the MSR register value (32 bits).
  265. *
  266. * @pre None
  267. * @post None
  268. *
  269. */
  270. uint32 Eth_schm_read_msr(void)
  271. {
  272. register uint32 reg_tmp;
  273. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  274. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  275. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  276. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  277. #else
  278. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  279. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  280. #else
  281. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  282. #endif
  283. #endif
  284. return (uint32)reg_tmp;
  285. }
  286. #endif /* _LINARO_C_S32K1XX_*/
  287. /*================================================================================================*/
  288. #ifdef _ARM_DS5_C_S32K1XX_
  289. /**
  290. * @brief This function returns the MSR register value (32 bits).
  291. * @details This function returns the MSR register value (32 bits).
  292. *
  293. * @param[in] void No input parameters
  294. * @return uint32 msr This function returns the MSR register value (32 bits).
  295. *
  296. * @pre None
  297. * @post None
  298. *
  299. */
  300. uint32 Eth_schm_read_msr(void)
  301. {
  302. register uint32 reg_tmp;
  303. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  304. __asm volatile( " mrs %x0, DAIF " : "=r" (reg_tmp) );
  305. #elif (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)
  306. __asm volatile( " mrs %0, CPSR " : "=r" (reg_tmp) );
  307. #else
  308. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  309. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  310. #else
  311. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  312. #endif
  313. #endif
  314. return (uint32)reg_tmp;
  315. }
  316. #endif /* _ARM_DS5_C_S32K1XX_ */
  317. #ifdef _IAR_C_S32K1XX_
  318. /**
  319. * @brief This function returns the MSR register value (32 bits).
  320. * @details This function returns the MSR register value (32 bits).
  321. *
  322. * @param[in] void No input parameters
  323. * @return uint32 msr This function returns the MSR register value (32 bits).
  324. *
  325. * @pre None
  326. * @post None
  327. *
  328. */
  329. uint32 Eth_schm_read_msr(void)
  330. {
  331. register uint32 reg_tmp;
  332. #if ((defined MCAL_ENABLE_USER_MODE_SUPPORT)&&(!defined MCAL_PLATFORM_ARM_M0PLUS))
  333. __asm volatile( " mrs %0, basepri " : "=r" (reg_tmp) );
  334. #else
  335. __asm volatile( " mrs %0, primask " : "=r" (reg_tmp) );
  336. #endif
  337. return (uint32)reg_tmp;
  338. }
  339. #endif /* _IAR_C_S32K1XX_ */
  340. #define RTE_STOP_SEC_CODE
  341. #include "Rte_MemMap.h"
  342. /*==================================================================================================
  343. * GLOBAL FUNCTIONS
  344. ==================================================================================================*/
  345. #define RTE_START_SEC_CODE
  346. #include "Rte_MemMap.h"
  347. #ifdef MCAL_TESTING_ENVIRONMENT
  348. /**
  349. @brief This function checks that all entered exclusive areas were also exited.
  350. @details This function checks that all entered exclusive areas were also exited. The check
  351. is done by verifying that all reentry_guard_* static variables are back to the
  352. zero value.
  353. @param[in] void No input parameters
  354. @return void This function does not return a value. Test asserts are used instead.
  355. @pre None
  356. @post None
  357. @remarks Covers
  358. @remarks Implements
  359. */
  360. void SchM_Check_eth(void)
  361. {
  362. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  363. }
  364. #endif /*MCAL_TESTING_ENVIRONMENT*/
  365. #define RTE_STOP_SEC_CODE
  366. #include "Rte_MemMap.h"
  367. #ifdef __cplusplus
  368. }
  369. #endif
  370. /** @} */