xref: /rk3399_ARM-atf/include/common/ep_info.h (revision 1d651211748cdc01b6a838925e7987572a5816e0)
15dffb46cSSoby Mathew /*
2*4693ff72SZelalem Aweke  * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
35dffb46cSSoby Mathew  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
55dffb46cSSoby Mathew  */
65dffb46cSSoby Mathew 
7c3cf06f1SAntonio Nino Diaz #ifndef EP_INFO_H
8c3cf06f1SAntonio Nino Diaz #define EP_INFO_H
95dffb46cSSoby Mathew 
1009d40e0eSAntonio Nino Diaz #include <common/param_header.h>
115dffb46cSSoby Mathew 
12d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__
1393c78ed2SAntonio Nino Diaz #include <stdint.h>
1409d40e0eSAntonio Nino Diaz #include <lib/cassert.h>
15d5dfdeb6SJulius Werner #endif /* __ASSEMBLER__ */
1609d40e0eSAntonio Nino Diaz 
1757bf6057SJulius Werner #include <export/common/ep_info_exp.h>
185dffb46cSSoby Mathew 
1957bf6057SJulius Werner #define SECURE		EP_SECURE
2057bf6057SJulius Werner #define NON_SECURE	EP_NON_SECURE
21*4693ff72SZelalem Aweke #define REALM		EP_REALM
22*4693ff72SZelalem Aweke #if ENABLE_RME
23*4693ff72SZelalem Aweke #define sec_state_is_valid(s)	(((s) == SECURE) ||	\
24*4693ff72SZelalem Aweke 				((s) == NON_SECURE) ||	\
25*4693ff72SZelalem Aweke 				((s) == REALM))
26*4693ff72SZelalem Aweke #else
2757bf6057SJulius Werner #define sec_state_is_valid(s) (((s) == SECURE) || ((s) == NON_SECURE))
28*4693ff72SZelalem Aweke #endif
295dffb46cSSoby Mathew 
3057bf6057SJulius Werner #define PARAM_EP_SECURITY_MASK	EP_SECURITY_MASK
3157bf6057SJulius Werner 
3257bf6057SJulius Werner #define NON_EXECUTABLE	EP_NON_EXECUTABLE
3357bf6057SJulius Werner #define EXECUTABLE	EP_EXECUTABLE
3457bf6057SJulius Werner 
35*4693ff72SZelalem Aweke /* Get/set security state of an image */
3657bf6057SJulius Werner #define GET_SECURITY_STATE(x) ((x) & EP_SECURITY_MASK)
3757bf6057SJulius Werner #define SET_SECURITY_STATE(x, security) \
3857bf6057SJulius Werner 			((x) = ((x) & ~EP_SECURITY_MASK) | (security))
3957bf6057SJulius Werner 
40d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__
415dffb46cSSoby Mathew 
425dffb46cSSoby Mathew /*
435dffb46cSSoby Mathew  * Compile time assertions related to the 'entry_point_info' structure to
445dffb46cSSoby Mathew  * ensure that the assembler and the compiler view of the offsets of
455dffb46cSSoby Mathew  * the structure members is the same.
465dffb46cSSoby Mathew  */
475dffb46cSSoby Mathew CASSERT(ENTRY_POINT_INFO_PC_OFFSET ==
485dffb46cSSoby Mathew 		__builtin_offsetof(entry_point_info_t, pc), \
495dffb46cSSoby Mathew 		assert_BL31_pc_offset_mismatch);
505dffb46cSSoby Mathew 
51402b3cf8SJulius Werner #ifndef __aarch64__
523fe81dcfSEtienne Carriere CASSERT(ENTRY_POINT_INFO_LR_SVC_OFFSET ==
533fe81dcfSEtienne Carriere 		__builtin_offsetof(entry_point_info_t, lr_svc),
543fe81dcfSEtienne Carriere 		assert_entrypoint_lr_offset_error);
553fe81dcfSEtienne Carriere #endif
563fe81dcfSEtienne Carriere 
575dffb46cSSoby Mathew CASSERT(ENTRY_POINT_INFO_ARGS_OFFSET == \
585dffb46cSSoby Mathew 		__builtin_offsetof(entry_point_info_t, args), \
595dffb46cSSoby Mathew 		assert_BL31_args_offset_mismatch);
605dffb46cSSoby Mathew 
615dffb46cSSoby Mathew CASSERT(sizeof(uintptr_t) ==
625dffb46cSSoby Mathew 		__builtin_offsetof(entry_point_info_t, spsr) - \
635dffb46cSSoby Mathew 		__builtin_offsetof(entry_point_info_t, pc), \
645dffb46cSSoby Mathew 		assert_entrypoint_and_spsr_should_be_adjacent);
655dffb46cSSoby Mathew 
66d5dfdeb6SJulius Werner #endif /*__ASSEMBLER__*/
675dffb46cSSoby Mathew 
68c3cf06f1SAntonio Nino Diaz #endif /* EP_INFO_H */
69