blob: 771572ce9c49b2c4091ef326ea77b0bca40e882d [file] [log] [blame]
Soby Mathewb911cc72017-02-13 12:46:28 +00001/*
Zelalem Aweke4d666ac2021-07-08 17:13:09 -05002 * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
Soby Mathewb911cc72017-02-13 12:46:28 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathewb911cc72017-02-13 12:46:28 +00005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef EP_INFO_H
8#define EP_INFO_H
Soby Mathewb911cc72017-02-13 12:46:28 +00009
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <common/param_header.h>
Soby Mathewb911cc72017-02-13 12:46:28 +000011
Julius Werner53456fc2019-07-09 13:49:11 -070012#ifndef __ASSEMBLER__
Julius Werner2a231e32019-05-28 21:03:58 -070013#include <stdint.h>
14#include <lib/cassert.h>
Julius Werner53456fc2019-07-09 13:49:11 -070015#endif /* __ASSEMBLER__ */
Julius Werner2a231e32019-05-28 21:03:58 -070016
17#include <export/common/ep_info_exp.h>
18
19#define SECURE EP_SECURE
20#define NON_SECURE EP_NON_SECURE
Zelalem Aweke4d666ac2021-07-08 17:13:09 -050021#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
Soby Mathewb911cc72017-02-13 12:46:28 +000027#define sec_state_is_valid(s) (((s) == SECURE) || ((s) == NON_SECURE))
Zelalem Aweke4d666ac2021-07-08 17:13:09 -050028#endif
Soby Mathewb911cc72017-02-13 12:46:28 +000029
Julius Werner2a231e32019-05-28 21:03:58 -070030#define PARAM_EP_SECURITY_MASK EP_SECURITY_MASK
Soby Mathewb911cc72017-02-13 12:46:28 +000031
Julius Werner2a231e32019-05-28 21:03:58 -070032#define NON_EXECUTABLE EP_NON_EXECUTABLE
33#define EXECUTABLE EP_EXECUTABLE
Soby Mathewb911cc72017-02-13 12:46:28 +000034
Zelalem Aweke4d666ac2021-07-08 17:13:09 -050035/* Get/set security state of an image */
Julius Werner2a231e32019-05-28 21:03:58 -070036#define GET_SECURITY_STATE(x) ((x) & EP_SECURITY_MASK)
Soby Mathewb911cc72017-02-13 12:46:28 +000037#define SET_SECURITY_STATE(x, security) \
Julius Werner2a231e32019-05-28 21:03:58 -070038 ((x) = ((x) & ~EP_SECURITY_MASK) | (security))
Soby Mathewb911cc72017-02-13 12:46:28 +000039
Julius Werner53456fc2019-07-09 13:49:11 -070040#ifndef __ASSEMBLER__
Soby Mathewb911cc72017-02-13 12:46:28 +000041
Soby Mathewb911cc72017-02-13 12:46:28 +000042/*
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 */
47CASSERT(ENTRY_POINT_INFO_PC_OFFSET ==
48 __builtin_offsetof(entry_point_info_t, pc), \
49 assert_BL31_pc_offset_mismatch);
50
Julius Werner8e0ef0f2019-07-09 14:02:43 -070051#ifndef __aarch64__
Etienne Carriere094041d2018-02-02 13:16:18 +010052CASSERT(ENTRY_POINT_INFO_LR_SVC_OFFSET ==
53 __builtin_offsetof(entry_point_info_t, lr_svc),
54 assert_entrypoint_lr_offset_error);
55#endif
56
Soby Mathewb911cc72017-02-13 12:46:28 +000057CASSERT(ENTRY_POINT_INFO_ARGS_OFFSET == \
58 __builtin_offsetof(entry_point_info_t, args), \
59 assert_BL31_args_offset_mismatch);
60
61CASSERT(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
Julius Werner53456fc2019-07-09 13:49:11 -070066#endif /*__ASSEMBLER__*/
Soby Mathewb911cc72017-02-13 12:46:28 +000067
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000068#endif /* EP_INFO_H */