blob: 3a52a3ee837f939ca480e5e6105107f459881f83 [file] [log] [blame]
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +00001/*
Nishant Sharma96107d72022-04-28 00:13:50 +01002 * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Paul Beesley15a96a92019-10-15 14:23:23 +00007#ifndef SPM_MM_PRIVATE_H
8#define SPM_MM_PRIVATE_H
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +00009
10#include <context.h>
Marc Bonnici758bd242021-12-19 21:37:50 +000011#include "spm_common.h"
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000012
13/*******************************************************************************
14 * Constants that allow assembler code to preserve callee-saved registers of the
15 * C runtime context while performing a security state switch.
16 ******************************************************************************/
17#define SP_C_RT_CTX_X19 0x0
18#define SP_C_RT_CTX_X20 0x8
19#define SP_C_RT_CTX_X21 0x10
20#define SP_C_RT_CTX_X22 0x18
21#define SP_C_RT_CTX_X23 0x20
22#define SP_C_RT_CTX_X24 0x28
23#define SP_C_RT_CTX_X25 0x30
24#define SP_C_RT_CTX_X26 0x38
25#define SP_C_RT_CTX_X27 0x40
26#define SP_C_RT_CTX_X28 0x48
27#define SP_C_RT_CTX_X29 0x50
28#define SP_C_RT_CTX_X30 0x58
29
30#define SP_C_RT_CTX_SIZE 0x60
31#define SP_C_RT_CTX_ENTRIES (SP_C_RT_CTX_SIZE >> DWORD_SHIFT)
32
Julius Werner53456fc2019-07-09 13:49:11 -070033#ifndef __ASSEMBLER__
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000034
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000035#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000036
37#include <lib/spinlock.h>
38#include <lib/xlat_tables/xlat_tables_v2.h>
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000039
40typedef enum sp_state {
41 SP_STATE_RESET = 0,
42 SP_STATE_IDLE,
43 SP_STATE_BUSY
44} sp_state_t;
45
46typedef struct sp_context {
47 uint64_t c_rt_ctx;
48 cpu_context_t cpu_ctx;
49 xlat_ctx_t *xlat_ctx_handle;
50
51 sp_state_t state;
52 spinlock_t state_lock;
53} sp_context_t;
54
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000055
56void spm_sp_setup(sp_context_t *sp_ctx);
57
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000058int32_t spm_memory_attributes_get_smc_handler(sp_context_t *sp_ctx,
59 uintptr_t base_va);
60int spm_memory_attributes_set_smc_handler(sp_context_t *sp_ctx,
61 u_register_t page_address,
62 u_register_t pages_count,
63 u_register_t smc_attributes);
64
Julius Werner53456fc2019-07-09 13:49:11 -070065#endif /* __ASSEMBLER__ */
Antonio Nino Diaz8cd7ea32018-10-30 11:08:08 +000066
Paul Beesley15a96a92019-10-15 14:23:23 +000067#endif /* SPM_MM_PRIVATE_H */