blob: 61b479a8bcc6d3a1269f424cf5a866fd9ace766f [file] [log] [blame]
Achin Gupta86f23532019-10-11 15:41:16 +01001/*
2 * Copyright (c) 2019-2020, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SPMD_PRIVATE_H
8#define SPMD_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 SPMD_C_RT_CTX_X19 0x0
17#define SPMD_C_RT_CTX_X20 0x8
18#define SPMD_C_RT_CTX_X21 0x10
19#define SPMD_C_RT_CTX_X22 0x18
20#define SPMD_C_RT_CTX_X23 0x20
21#define SPMD_C_RT_CTX_X24 0x28
22#define SPMD_C_RT_CTX_X25 0x30
23#define SPMD_C_RT_CTX_X26 0x38
24#define SPMD_C_RT_CTX_X27 0x40
25#define SPMD_C_RT_CTX_X28 0x48
26#define SPMD_C_RT_CTX_X29 0x50
27#define SPMD_C_RT_CTX_X30 0x58
28
29#define SPMD_C_RT_CTX_SIZE 0x60
30#define SPMD_C_RT_CTX_ENTRIES (SPMD_C_RT_CTX_SIZE >> DWORD_SHIFT)
31
32#ifndef __ASSEMBLER__
33#include <services/spci_svc.h>
34#include <stdint.h>
35
36/*
37 * Convert a function no. in a FID to a bit position. All function nos. are
38 * between 0 and 0x1f
39 */
40#define SPCI_FNO_TO_BIT_POS(_fid) (1 << ((_fid) & U(0x1f)))
41
42typedef enum spmc_state {
43 SPMC_STATE_RESET = 0,
44 SPMC_STATE_IDLE
45} spmc_state_t;
46
47/*
48 * Data structure used by the SPM dispatcher (SPMD) in EL3 to track context of
49 * the SPM core (SPMC) at the next lower EL.
50 */
51typedef struct spmd_spm_core_context {
52 uint64_t c_rt_ctx;
53 cpu_context_t cpu_ctx;
54 spmc_state_t state;
55} spmd_spm_core_context_t;
56
57/*
58 * Data structure used by the SPM dispatcher (SPMD) in EL3 to track sequence of
59 * SPCI calls from lower ELs.
60 *
61 * next_smc_bit_map: Per-cpu bit map of SMCs from each world that are expected
62 * next.
63 */
64typedef struct spmd_spci_context {
65 uint32_t next_smc_bit_map[2];
66} spmd_spci_context_t;
67
68/* Functions used to enter/exit a Secure Partition synchronously */
69uint64_t spmd_spm_core_sync_entry(spmd_spm_core_context_t *ctx);
70__dead2 void spmd_spm_core_sync_exit(uint64_t rc);
71
72/* Assembly helpers */
73uint64_t spmd_spm_core_enter(uint64_t *c_rt_ctx);
74void __dead2 spmd_spm_core_exit(uint64_t c_rt_ctx, uint64_t ret);
75
76#endif /* __ASSEMBLER__ */
77
78#endif /* SPMD_PRIVATE_H */