1 /* 2 * Copyright 2020-2023 M4_SRC_COPYRIGHTED_TOs 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef DEVASSERT_H 8 #define DEVASSERT_H 9 10 #include "PlatformTypes.h" 11 #include "Mcal.h" 12 13 /* 14 Drivers can use a mechanism to validate data coming from upper software layers (application code) by performing 15 a number of checks on input parameters' range or other invariants that can be statically checked (not dependent on 16 runtime conditions). A failed validation is indicative of a software bug in application code, therefore it is important 17 to use this mechanism during development. 18 */ 19 20 /*================================================================================================== 21 * SOURCE FILE VERSION INFORMATION 22 ==================================================================================================*/ 23 #define DEVASSERT_VENDOR_ID 43 24 #define DEVASSERT_AR_RELEASE_MAJOR_VERSION 4 25 #define DEVASSERT_AR_RELEASE_MINOR_VERSION 7 26 #define DEVASSERT_AR_RELEASE_REVISION_VERSION 0 27 #define DEVASSERT_SW_MAJOR_VERSION 3 28 #define DEVASSERT_SW_MINOR_VERSION 0 29 #define DEVASSERT_SW_PATCH_VERSION 0 30 31 /*================================================================================================== 32 * FILE VERSION CHECKS 33 ==================================================================================================*/ 34 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 35 /* Check if the files Devassert.h and PlatformTypes.h are of the same version */ 36 #if ((DEVASSERT_AR_RELEASE_MAJOR_VERSION != PLATFORM_TYPES_AR_RELEASE_MAJOR_VERSION) || \ 37 (DEVASSERT_AR_RELEASE_MINOR_VERSION != PLATFORM_TYPES_AR_RELEASE_MINOR_VERSION) \ 38 ) 39 #error "AUTOSAR Version Numbers of Devassert.h and PlatformTypes.h are different" 40 #endif 41 /* Check if the files Devassert.h and Mcal.h are of the same version */ 42 #if ((DEVASSERT_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \ 43 (DEVASSERT_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION) \ 44 ) 45 #error "AUTOSAR Version Numbers of Devassert.h and Mcal.h are different" 46 #endif 47 #endif 48 49 /*================================================================================================== 50 * FUNCTION PROTOTYPES 51 ==================================================================================================*/ 52 #ifdef CCOV_ENABLE 53 #define DevAssert(x) 54 #else 55 56 #if ((MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64) || \ 57 (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH32) || \ 58 (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH)) 59 #define BREAKPOINT_INSTR "HLT #0" 60 #elif (MCAL_PLATFORM_ARM == MCAL_ARM_MARCH) 61 #define BREAKPOINT_INSTR "BKPT #0" 62 #else 63 #error "Unsupported architecture!" 64 #endif 65 66 /* Implement default assert macro */ DevAssert(volatile boolean x)67static inline void DevAssert(volatile boolean x) 68 { 69 if(x) { } else { for(;;) {ASM_KEYWORD(BREAKPOINT_INSTR);} } 70 } 71 #endif 72 73 #endif /* DEVASSERT_H */ 74 75 /******************************************************************************* 76 * EOF 77 ******************************************************************************/ 78