1 /*
2  * Copyright 2021-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             1
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_AR_RELEASE_MAJOR_VERSION) || \
37          (DEVASSERT_AR_RELEASE_MINOR_VERSION != PLATFORM_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 
57  #if ((MCAL_PLATFORM_ARM == MCAL_ARM_AARCH64) || \
58      (MCAL_PLATFORM_ARM == MCAL_ARM_AARCH32) || \
59      (MCAL_PLATFORM_ARM == MCAL_ARM_RARCH))
60     #define BREAKPOINT_INSTR        "HLT #0"
61 #elif (MCAL_PLATFORM_ARM == MCAL_ARM_MARCH)
62     #define BREAKPOINT_INSTR        "BKPT #0"
63 #else
64     #error "Unsupported architecture!"
65 #endif
66 
67 /* Implement default assert macro */
DevAssert(volatile boolean x)68 static inline void DevAssert(volatile boolean x)
69 {
70     if(x) { } else { for(;;) {ASM_KEYWORD(BREAKPOINT_INSTR);} }
71 }
72 #endif
73 
74  #endif /* DEVASSERT_H */
75 
76 /*******************************************************************************
77  * EOF
78  ******************************************************************************/
79