1 /*
2  * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef EP_INFO_H
8 #define EP_INFO_H
9 
10 #include <common/param_header.h>
11 
12 #ifndef __ASSEMBLER__
13 #include <stdint.h>
14 #include <lib/cassert.h>
15 #endif /* __ASSEMBLER__ */
16 
17 #include <export/common/ep_info_exp.h>
18 
19 #define SECURE		EP_SECURE
20 #define NON_SECURE	EP_NON_SECURE
21 #define REALM		EP_REALM
22 #if ENABLE_RME
23 #define sec_state_is_valid(s)	(((s) == SECURE) ||	\
24 				((s) == NON_SECURE) ||	\
25 				((s) == REALM))
26 #else
27 #define sec_state_is_valid(s) (((s) == SECURE) || ((s) == NON_SECURE))
28 #endif
29 
30 #define PARAM_EP_SECURITY_MASK	EP_SECURITY_MASK
31 
32 #define NON_EXECUTABLE	EP_NON_EXECUTABLE
33 #define EXECUTABLE	EP_EXECUTABLE
34 
35 /* Get/set security state of an image */
36 #define GET_SECURITY_STATE(x) ((x) & EP_SECURITY_MASK)
37 #define SET_SECURITY_STATE(x, security) \
38 			((x) = ((x) & ~EP_SECURITY_MASK) | (security))
39 
40 #ifndef __ASSEMBLER__
41 
42 /*
43  * Compile time assertions related to the 'entry_point_info' structure to
44  * ensure that the assembler and the compiler view of the offsets of
45  * the structure members is the same.
46  */
47 CASSERT(ENTRY_POINT_INFO_PC_OFFSET ==
48 		__builtin_offsetof(entry_point_info_t, pc), \
49 		assert_BL31_pc_offset_mismatch);
50 
51 #ifndef __aarch64__
52 CASSERT(ENTRY_POINT_INFO_LR_SVC_OFFSET ==
53 		__builtin_offsetof(entry_point_info_t, lr_svc),
54 		assert_entrypoint_lr_offset_error);
55 #endif
56 
57 CASSERT(ENTRY_POINT_INFO_ARGS_OFFSET == \
58 		__builtin_offsetof(entry_point_info_t, args), \
59 		assert_BL31_args_offset_mismatch);
60 
61 CASSERT(sizeof(uintptr_t) ==
62 		__builtin_offsetof(entry_point_info_t, spsr) - \
63 		__builtin_offsetof(entry_point_info_t, pc), \
64 		assert_entrypoint_and_spsr_should_be_adjacent);
65 
66 #endif /*__ASSEMBLER__*/
67 
68 #endif /* EP_INFO_H */
69