1 /* 2 * Copyright 2020-2023 NXP. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /** 8 * @file 9 * 10 * @addtogroup osif_drv 11 * @{ 12 */ 13 14 #ifdef __cplusplus 15 extern "C"{ 16 #endif 17 18 /*================================================================================================== 19 * INCLUDE FILES 20 * 1) system and project includes 21 * 2) needed interfaces from external units 22 * 3) internal and external interfaces from this unit 23 ==================================================================================================*/ 24 #include "OsIf.h" 25 #include "OsIf_Interrupts.h" 26 27 #if defined(USING_OS_ZEPHYR) 28 #include <zephyr/kernel.h> 29 30 /*================================================================================================== 31 * SOURCE FILE VERSION INFORMATION 32 ==================================================================================================*/ 33 #define OSIF_INTERRUPTS_VENDOR_ID_C 43 34 #define OSIF_INTERRUPTS_AR_RELEASE_MAJOR_VERSION_C 4 35 #define OSIF_INTERRUPTS_AR_RELEASE_MINOR_VERSION_C 7 36 #define OSIF_INTERRUPTS_AR_RELEASE_REVISION_VERSION_C 0 37 #define OSIF_INTERRUPTS_SW_MAJOR_VERSION_C 2 38 #define OSIF_INTERRUPTS_SW_MINOR_VERSION_C 0 39 #define OSIF_INTERRUPTS_SW_PATCH_VERSION_C 0 40 41 /*================================================================================================== 42 * FILE VERSION CHECKS 43 ==================================================================================================*/ 44 /* Check if OsIf_Interrupts.c file and OsIf.h file are of the same vendor */ 45 #if (OSIF_INTERRUPTS_VENDOR_ID_C != OSIF_VENDOR_ID) 46 #error "OsIf_Interrupts.c and OsIf.h have different vendor ids" 47 #endif 48 /* Check if OsIf_Interrupts.c file and OsIf.h file are of the same Autosar version */ 49 #if ((OSIF_INTERRUPTS_AR_RELEASE_MAJOR_VERSION_C != OSIF_AR_RELEASE_MAJOR_VERSION) || \ 50 (OSIF_INTERRUPTS_AR_RELEASE_MINOR_VERSION_C != OSIF_AR_RELEASE_MINOR_VERSION) || \ 51 (OSIF_INTERRUPTS_AR_RELEASE_REVISION_VERSION_C != OSIF_AR_RELEASE_REVISION_VERSION)) 52 #error "AUTOSAR Version Numbers of OsIf_Interrupts.c and OsIf.h are different" 53 #endif 54 /* Check if OsIf_Interrupts.c file and OsIf.h file are of the same Software version */ 55 #if ((OSIF_INTERRUPTS_SW_MAJOR_VERSION_C != OSIF_SW_MAJOR_VERSION) || \ 56 (OSIF_INTERRUPTS_SW_MINOR_VERSION_C != OSIF_SW_MINOR_VERSION) || \ 57 (OSIF_INTERRUPTS_SW_PATCH_VERSION_C != OSIF_SW_PATCH_VERSION) \ 58 ) 59 #error "Software Version Numbers of OsIf_Interrupts.c and OsIf.h are different" 60 #endif 61 62 /* Check if OsIf_Interrupts.c file and OsIf_Interrupts.h file are of the same vendor */ 63 #if (OSIF_INTERRUPTS_VENDOR_ID_C != OSIF_INTERRUPTS_VENDOR_ID) 64 #error "OsIf_Interrupts.c and OsIf_Interrupts.h have different vendor ids" 65 #endif 66 /* Check if OsIf_Interrupts.c file and OsIf_Interrupts.h file are of the same Autosar version */ 67 #if ((OSIF_INTERRUPTS_AR_RELEASE_MAJOR_VERSION_C != OSIF_INTERRUPTS_AR_RELEASE_MAJOR_VERSION) || \ 68 (OSIF_INTERRUPTS_AR_RELEASE_MINOR_VERSION_C != OSIF_INTERRUPTS_AR_RELEASE_MINOR_VERSION) || \ 69 (OSIF_INTERRUPTS_AR_RELEASE_REVISION_VERSION_C != OSIF_INTERRUPTS_AR_RELEASE_REVISION_VERSION)) 70 #error "AUTOSAR Version Numbers of OsIf_Interrupts.c and OsIf_Interrupts.h are different" 71 #endif 72 /* Check if OsIf_Interrupts.c file and OsIf_Interrupts.h file are of the same Software version */ 73 #if ((OSIF_INTERRUPTS_SW_MAJOR_VERSION_C != OSIF_INTERRUPTS_SW_MAJOR_VERSION) || \ 74 (OSIF_INTERRUPTS_SW_MINOR_VERSION_C != OSIF_INTERRUPTS_SW_MINOR_VERSION) || \ 75 (OSIF_INTERRUPTS_SW_PATCH_VERSION_C != OSIF_INTERRUPTS_SW_PATCH_VERSION) \ 76 ) 77 #error "Software Version Numbers of OsIf_Interrupts.c and OsIf_Interrupts.h are different" 78 #endif 79 80 /*================================================================================================== 81 * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS) 82 ==================================================================================================*/ 83 84 /*================================================================================================== 85 * LOCAL MACROS 86 ==================================================================================================*/ 87 #if (STD_ON == OSIF_ENABLE_MULTICORE_SUPPORT) 88 #define OsIfCoreID() (OsIf_GetCoreID()) 89 #else 90 #define OsIfCoreID() (0U) 91 #endif 92 /*================================================================================================== 93 * LOCAL CONSTANTS 94 ==================================================================================================*/ 95 96 /*================================================================================================== 97 * LOCAL VARIABLES 98 ==================================================================================================*/ 99 #define BASENXP_START_SEC_VAR_CLEARED_32 100 #include "BaseNXP_MemMap.h" 101 102 static uint32 OsIf_au32OldIrqMask[OSIF_MAX_COREIDX_SUPPORTED]; 103 static uint32 OsIf_au32SuspendLevel[OSIF_MAX_COREIDX_SUPPORTED]; 104 105 #define BASENXP_STOP_SEC_VAR_CLEARED_32 106 #include "BaseNXP_MemMap.h" 107 108 /*================================================================================================== 109 * GLOBAL CONSTANTS 110 ==================================================================================================*/ 111 112 /*================================================================================================== 113 * GLOBAL VARIABLES 114 ==================================================================================================*/ 115 116 /*================================================================================================== 117 * LOCAL FUNCTION PROTOTYPES 118 ==================================================================================================*/ 119 120 /*================================================================================================== 121 * LOCAL FUNCTIONS 122 ==================================================================================================*/ 123 124 /*================================================================================================== 125 * GLOBAL FUNCTIONS 126 ==================================================================================================*/ 127 #define BASENXP_START_SEC_CODE 128 #include "BaseNXP_MemMap.h" 129 130 /*FUNCTION********************************************************************** 131 * 132 * Function Name : OsIf_Interrupts_SuspendAllInterrupts. 133 * Description : Suspend all interrupts. 134 * 135 *END**************************************************************************/ OsIf_Interrupts_SuspendAllInterrupts(void)136void OsIf_Interrupts_SuspendAllInterrupts(void) 137 { 138 uint32 CoreId = OsIfCoreID(); 139 140 if (OsIf_au32SuspendLevel[CoreId]++ == 0U) 141 { 142 OsIf_au32OldIrqMask[CoreId] = arch_irq_lock(); 143 } 144 } 145 146 /*FUNCTION********************************************************************** 147 * 148 * Function Name : OsIf_Interrupts_ResumeAllInterrupts. 149 * Description : Resume all interrupts. 150 * 151 *END**************************************************************************/ OsIf_Interrupts_ResumeAllInterrupts(void)152void OsIf_Interrupts_ResumeAllInterrupts(void) 153 { 154 uint32 CoreId = OsIfCoreID(); 155 156 if (--OsIf_au32SuspendLevel[CoreId] == 0U) 157 { 158 arch_irq_unlock(OsIf_au32OldIrqMask[CoreId]); 159 } 160 } 161 162 #define BASENXP_STOP_SEC_CODE 163 #include "BaseNXP_MemMap.h" 164 165 #endif /* defined(USING_OS_ZEPHYR) */ 166 167 #ifdef __cplusplus 168 } 169 #endif 170 171 /** @} */ 172