OsIf_Internal.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : S32K14X
  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. #ifndef OSIF_INTERNAL_H
  25. #define OSIF_INTERNAL_H
  26. /**
  27. * @file
  28. * @implements OsIf_Internal.h_Artifact
  29. * @addtogroup osif_drv
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C"{
  34. #endif
  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 "StandardTypes.h"
  42. #include "Soc_Ips.h"
  43. #include "OsIf_Cfg.h"
  44. #if defined(USING_OS_AUTOSAROS)
  45. #include "Os.h"
  46. #endif /* defined(USING_OS_AUTOSAROS) */
  47. #if !defined(USING_OS_AUTOSAROS)
  48. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  49. /* prototypes defined in system.h*/
  50. uint32 Sys_GoToUser_Return(uint32 u32SwitchToSupervisor, uint32 u32returnValue);
  51. uint32 Sys_GoToSupervisor(void);
  52. uint32 Sys_GoToUser(void);
  53. void Sys_SuspendInterrupts(void);
  54. void Sys_ResumeInterrupts(void);
  55. #endif /* def MCAL_ENABLE_USER_MODE_SUPPORT */
  56. uint8 Sys_GetCoreID(void);
  57. #endif /* !defined(USING_OS_AUTOSAROS) */
  58. /*==================================================================================================
  59. * SOURCE FILE VERSION INFORMATION
  60. ==================================================================================================*/
  61. #define OSIF_INTERNAL_VENDOR_ID 43
  62. #define OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION 4
  63. #define OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION 4
  64. #define OSIF_INTERNAL_AR_RELEASE_REVISION_VERSION 0
  65. #define OSIF_INTERNAL_SW_MAJOR_VERSION 1
  66. #define OSIF_INTERNAL_SW_MINOR_VERSION 0
  67. #define OSIF_INTERNAL_SW_PATCH_VERSION 0
  68. /*==================================================================================================
  69. * FILE VERSION CHECKS
  70. ==================================================================================================*/
  71. /* Checks against StandardTypes.h */
  72. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  73. #if ((OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
  74. (OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
  75. #error "AutoSar Version Numbers of OsIf_Internal.h and StandardTypes.h are different"
  76. #endif
  77. #endif
  78. /* Checks against Soc_Ips.h */
  79. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  80. #if ((OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION != SOC_IPS_AR_RELEASE_MAJOR_VERSION) || \
  81. (OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION != SOC_IPS_AR_RELEASE_MINOR_VERSION))
  82. #error "AutoSar Version Numbers of OsIf_Internal.h and Soc_Ips.h are different"
  83. #endif
  84. #endif
  85. #if defined(USING_OS_AUTOSAROS)
  86. /* Checks against Os.h */
  87. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  88. #if ((OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION != OS_AR_RELEASE_MAJOR_VERSION) || \
  89. (OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION != OS_AR_RELEASE_MINOR_VERSION))
  90. #error "AutoSar Version Numbers of OsIf_Internal.h and Os.h are different"
  91. #endif
  92. #endif
  93. #endif /* defined(USING_OS_AUTOSAROS) */
  94. /*==================================================================================================
  95. * CONSTANTS
  96. ==================================================================================================*/
  97. /*==================================================================================================
  98. * DEFINES AND MACROS
  99. ==================================================================================================*/
  100. /*
  101. * OsIf_Trusted_Call*
  102. */
  103. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  104. #ifdef USING_OS_AUTOSAROS
  105. #define OsIf_Trusted_Call(name) Call_##name##_TRUSTED()
  106. #define OsIf_Trusted_Call1param(name,param) Call_##name##_TRUSTED(param)
  107. #define OsIf_Trusted_Call2params(name,param1,param2) Call_##name##_TRUSTED(param1,param2)
  108. #define OsIf_Trusted_Call3params(name,param1,param2,param3) Call_##name##_TRUSTED(param1,param2,param3)
  109. #define OsIf_Trusted_Call4params(name,param1,param2,param3,param4) Call_##name##_TRUSTED(param1,param2,param3,param4)
  110. #define OsIf_Trusted_Call5params(name,param1,param2,param3,param4,param5) Call_##name##_TRUSTED(param1,param2,param3,param4,param5)
  111. #define OsIf_Trusted_Call6params(name,param1,param2,param3,param4,param5,param6) Call_##name##_TRUSTED(param1,param2,param3,param4,param5,param6)
  112. #define OsIf_Trusted_Call_Return(name) Call_##name##_TRUSTED()
  113. #define OsIf_Trusted_Call_Return1param(name,param1) Call_##name##_TRUSTED(param1)
  114. #define OsIf_Trusted_Call_Return2param(name,param1,param2) Call_##name##_TRUSTED(param1,param2)
  115. #define OsIf_Trusted_Call_Return3param(name,param1,param2,param3) Call_##name##_TRUSTED(param1,param2,param3)
  116. #define OsIf_Trusted_Call_Return4param(name,param1,param2,param3,param4) Call_##name##_TRUSTED(param1,param2,param3,param4)
  117. #define OsIf_Trusted_Call_Return5param(name,param1,param2,param3,param4,param5) Call_##name##_TRUSTED(param1,param2,param3,param4,param5)
  118. #define OsIf_Trusted_Call_Return6param(name,param1,param2,param3,param4,param5,param6) Call_##name##_TRUSTED(param1,param2,param3,param4,param5,param6)
  119. #else /* USING_OS_AUTOSAROS */
  120. /* Baremetal and FreeRTOS */
  121. #define OsIf_Trusted_Call(name) \
  122. ((1UL == Sys_GoToSupervisor()) ? (name(), (void)Sys_GoToUser()) : (name(),(void)0U))
  123. #define OsIf_Trusted_Call1param(name,param) \
  124. ((1UL == Sys_GoToSupervisor()) ? (name(param), (void)Sys_GoToUser()) : (name(param),(void)0U))
  125. #define OsIf_Trusted_Call2params(name,param1,param2) \
  126. ((1UL == Sys_GoToSupervisor()) ? (name(param1,param2), (void)Sys_GoToUser()) : (name(param1,param2),(void)0U))
  127. #define OsIf_Trusted_Call3params(name,param1,param2,param3) \
  128. ((1UL == Sys_GoToSupervisor()) ? (name(param1,param2,param3), (void)Sys_GoToUser()) : (name(param1,param2,param3),(void)0U))
  129. #define OsIf_Trusted_Call4params(name,param1,param2,param3,param4) \
  130. ((1UL == Sys_GoToSupervisor()) ? (name(param1,param2,param3,param4), (void)Sys_GoToUser()) : (name(param1,param2,param3,param4),(void)0U))
  131. #define OsIf_Trusted_Call5params(name,param1,param2,param3,param4,param5) \
  132. ((1UL == Sys_GoToSupervisor()) ? (name(param1,param2,param3,param4,param5), (void)Sys_GoToUser()) : (name(param1,param2,param3,param4,param5),(void)0U))
  133. #define OsIf_Trusted_Call6params(name,param1,param2,param3,param4,param5,param6) \
  134. ((1UL == Sys_GoToSupervisor()) ? (name(param1,param2,param3,param4,param5,param6), (void)Sys_GoToUser()) : (name(param1,param2,param3,param4,param5,param6),(void)0U))
  135. #define OsIf_Trusted_Call_Return(name) \
  136. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name()) : Sys_GoToUser_Return(0U, name()))
  137. #define OsIf_Trusted_Call_Return1param(name,param) \
  138. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param)) : Sys_GoToUser_Return(0U, name(param)))
  139. #define OsIf_Trusted_Call_Return2param(name,param1,param2) \
  140. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param1,param2)) : Sys_GoToUser_Return(0U, name(param1,param2)))
  141. #define OsIf_Trusted_Call_Return3param(name,param1,param2,param3) \
  142. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param1,param2,param3)) : Sys_GoToUser_Return(0U, name(param1,param2,param3)))
  143. #define OsIf_Trusted_Call_Return4param(name,param1,param2,param3,param4) \
  144. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param1,param2,param3,param4)) : Sys_GoToUser_Return(0U, name(param1,param2,param3,param4)))
  145. #define OsIf_Trusted_Call_Return5param(name,param1,param2,param3,param4,param5) \
  146. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param1,param2,param3,param4,param5)) : Sys_GoToUser_Return(0U, name(param1,param2,param3,param4,param5)))
  147. #define OsIf_Trusted_Call_Return6param(name,param1,param2,param3,param4,param5,param6) \
  148. ((1UL == Sys_GoToSupervisor()) ? Sys_GoToUser_Return(1U, name(param1,param2,param3,param4,param5,param6)) : Sys_GoToUser_Return(0U, name(param1,param2,param3,param4,param5,param6)))
  149. #endif /* USING_OS_AUTOSAROS */
  150. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  151. /*
  152. * OsIf_GetCoreID
  153. */
  154. #ifdef USING_OS_AUTOSAROS
  155. #if STD_ON == OSIF_ENABLE_MULTICORE_SUPPORT
  156. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  157. #define OsIf_GetCoreID() OsIf_Trusted_Call_Return(GetCoreID)
  158. #else
  159. #define OsIf_GetCoreID() GetCoreID()
  160. #endif
  161. #else
  162. #define OsIf_GetCoreID() (0U)
  163. #endif
  164. #else /* USING_OS_AUTOSAROS */
  165. /* Baremetal and FreeRTOS */
  166. #if STD_ON == OSIF_ENABLE_MULTICORE_SUPPORT
  167. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  168. #define OsIf_GetCoreID() OsIf_Trusted_Call_Return(Sys_GetCoreID)
  169. #else
  170. /* @implements OsIf_GetCoreID_define */
  171. #define OsIf_GetCoreID() Sys_GetCoreID()
  172. #endif
  173. #else
  174. #define OsIf_GetCoreID() (0U)
  175. #endif
  176. #endif
  177. /*
  178. * OsIf_SuspendAllInterrupts
  179. * OsIf_ResumeAllInterrupts
  180. */
  181. #if !defined(USING_OS_AUTOSAROS)
  182. /* Baremetal or FreeRTOS case */
  183. #if (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64)
  184. #define ResumeAllInterrupts() ASM_KEYWORD(" msr DAIFClr,#0xf")
  185. #define SuspendAllInterrupts() ASM_KEYWORD(" msr DAIFSet,#0xf")
  186. #else
  187. #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
  188. #define ResumeAllInterrupts() Sys_ResumeInterrupts() /* BASEPRI will be set to 0x0 from SVC handler */
  189. #define SuspendAllInterrupts() Sys_SuspendInterrupts() /* BASEPRI will be set to 0x10 from SVC handler */
  190. #else
  191. #define ResumeAllInterrupts() ASM_KEYWORD(" cpsie i")
  192. #define SuspendAllInterrupts() ASM_KEYWORD(" cpsid i")
  193. #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
  194. #endif /* MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64 */
  195. #endif /* !defined(USING_OS_AUTOSAROS) */
  196. /* @implements OsIf_SuspendAllInterrupts_define */
  197. #define OsIf_SuspendAllInterrupts() SuspendAllInterrupts()
  198. /* @implements OsIf_ResumeAllInterrupts_define */
  199. #define OsIf_ResumeAllInterrupts() ResumeAllInterrupts()
  200. /*
  201. * ISR macro definition
  202. */
  203. #ifdef USING_OS_AUTOSAROS
  204. /* ISR() macro defined by Autosar OS*/
  205. #else
  206. /* Baremetal or FreeRTOS case */
  207. #if defined (USE_SW_VECTOR_MODE)
  208. #define ISR(IsrName) void IsrName(void)
  209. #else
  210. #define ISR(IsrName) INTERRUPT_FUNC void IsrName(void)
  211. #endif /* defined (USE_SW_VECTOR_MODE) */
  212. #endif /* USING_OS_AUTOSAROS */
  213. /*==================================================================================================
  214. * ENUMS
  215. ==================================================================================================*/
  216. /*==================================================================================================
  217. * STRUCTURES AND OTHER TYPEDEFS
  218. ==================================================================================================*/
  219. /*==================================================================================================
  220. * GLOBAL VARIABLE DECLARATIONS
  221. ==================================================================================================*/
  222. /*==================================================================================================
  223. * FUNCTION PROTOTYPES
  224. ==================================================================================================*/
  225. #ifdef __cplusplus
  226. }
  227. #endif
  228. /** @} */
  229. #endif /* OSIF_INTERNAL_H */