blob: 598762e2a4585b8238ad4ce818c10b4ddde78252 [file] [log] [blame]
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +01001/*
Antonio Nino Diaz22282bb2018-05-23 11:40:46 +01002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +01003 *
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
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010032#ifndef __ASSEMBLY__
33
Antonio Nino Diaza43c85d2018-01-08 09:59:33 +000034#include <spinlock.h>
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010035#include <stdint.h>
36#include <xlat_tables_v2.h>
37
Antonio Nino Diaz07f3f632018-05-22 16:26:48 +010038typedef struct sp_context {
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010039 uint64_t c_rt_ctx;
40 cpu_context_t cpu_ctx;
Antonio Nino Diaz22282bb2018-05-23 11:40:46 +010041 xlat_ctx_t *xlat_ctx_handle;
Antonio Nino Diaz26bd5f82017-12-18 10:51:58 +000042 unsigned int sp_init_in_progress;
Antonio Nino Diaza43c85d2018-01-08 09:59:33 +000043 spinlock_t lock;
Antonio Nino Diaz07f3f632018-05-22 16:26:48 +010044} sp_context_t;
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010045
Antonio Nino Diaz22282bb2018-05-23 11:40:46 +010046/* Assembly helpers */
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010047uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx);
48void __dead2 spm_secure_partition_exit(uint64_t c_rt_ctx, uint64_t ret);
Antonio Nino Diaz22282bb2018-05-23 11:40:46 +010049
Antonio Nino Diaz07f3f632018-05-22 16:26:48 +010050void spm_sp_setup(sp_context_t *sp_ctx);
Antonio Nino Diaz22282bb2018-05-23 11:40:46 +010051
Antonio Nino Diazbfcdda42018-05-22 16:45:35 +010052xlat_ctx_t *spm_get_sp_xlat_context(void);
53
Antonio Nino Diaz07f3f632018-05-22 16:26:48 +010054int32_t spm_memory_attributes_get_smc_handler(sp_context_t *sp_ctx,
Antonio Nino Diazbfcdda42018-05-22 16:45:35 +010055 uintptr_t base_va);
Antonio Nino Diaz07f3f632018-05-22 16:26:48 +010056int spm_memory_attributes_set_smc_handler(sp_context_t *sp_ctx,
Antonio Nino Diazbfcdda42018-05-22 16:45:35 +010057 u_register_t page_address,
58 u_register_t pages_count,
59 u_register_t smc_attributes);
60
Antonio Nino Diaz2fccb222017-10-24 10:07:35 +010061#endif /* __ASSEMBLY__ */
62
63#endif /* __SPM_PRIVATE_H__ */