blob: ba94a4d0884fd53f7fb496c689df4e318d14761b [file] [log] [blame]
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +00001/*
2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SPM_PRIVATE_H
8#define SPM_PRIVATE_H
9
10#include <context.h>
11
12/*******************************************************************************
13 * Constants that allow assembler code to preserve callee-saved registers of the
14 * C runtime context while performing a security state switch.
15 ******************************************************************************/
16#define SP_C_RT_CTX_X19 0x0
17#define SP_C_RT_CTX_X20 0x8
18#define SP_C_RT_CTX_X21 0x10
19#define SP_C_RT_CTX_X22 0x18
20#define SP_C_RT_CTX_X23 0x20
21#define SP_C_RT_CTX_X24 0x28
22#define SP_C_RT_CTX_X25 0x30
23#define SP_C_RT_CTX_X26 0x38
24#define SP_C_RT_CTX_X27 0x40
25#define SP_C_RT_CTX_X28 0x48
26#define SP_C_RT_CTX_X29 0x50
27#define SP_C_RT_CTX_X30 0x58
28
29#define SP_C_RT_CTX_SIZE 0x60
30#define SP_C_RT_CTX_ENTRIES (SP_C_RT_CTX_SIZE >> DWORD_SHIFT)
31
Julius Werner53456fc2019-07-09 13:49:11 -070032#ifndef __ASSEMBLER__
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000033
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000034#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000035
36#include <lib/spinlock.h>
37#include <lib/xlat_tables/xlat_tables_v2.h>
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000038
39typedef enum sp_state {
40 SP_STATE_RESET = 0,
41 SP_STATE_IDLE,
42 SP_STATE_BUSY
43} sp_state_t;
44
45typedef struct sp_context {
46 uint64_t c_rt_ctx;
47 cpu_context_t cpu_ctx;
48 xlat_ctx_t *xlat_ctx_handle;
49
50 sp_state_t state;
51 spinlock_t state_lock;
52} sp_context_t;
53
54/* Assembly helpers */
55uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx);
56void __dead2 spm_secure_partition_exit(uint64_t c_rt_ctx, uint64_t ret);
57
58void spm_sp_setup(sp_context_t *sp_ctx);
59
60xlat_ctx_t *spm_get_sp_xlat_context(void);
61
62int32_t spm_memory_attributes_get_smc_handler(sp_context_t *sp_ctx,
63 uintptr_t base_va);
64int spm_memory_attributes_set_smc_handler(sp_context_t *sp_ctx,
65 u_register_t page_address,
66 u_register_t pages_count,
67 u_register_t smc_attributes);
68
Julius Werner53456fc2019-07-09 13:49:11 -070069#endif /* __ASSEMBLER__ */
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000070
71#endif /* SPM_PRIVATE_H */