blob: 2c8c7cd871cca1c2db3c50c23d74ffde6912f849 [file] [log] [blame]
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __SPM_SVC_H__
8#define __SPM_SVC_H__
9
10#include <utils_def.h>
11
12#define SPM_VERSION_MAJOR U(0)
13#define SPM_VERSION_MINOR U(1)
14#define SPM_VERSION_FORM(major, minor) ((major << 16) | (minor))
15#define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR)
16
17#define SP_VERSION_MAJOR U(1)
18#define SP_VERSION_MINOR U(0)
19#define SP_VERSION_FORM(major, minor) ((major << 16) | (minor))
20#define SP_VERSION_COMPILED SP_VERSION_FORM(SP_VERSION_MAJOR, SP_VERSION_MINOR)
21
22/* The macros below are used to identify SPM calls from the SMC function ID */
23#define SPM_FID_MASK U(0xffff)
24#define SPM_FID_MIN_VALUE U(0x40)
25#define SPM_FID_MAX_VALUE U(0x7f)
26#define is_spm_fid(_fid) \
27 ((((_fid) & SPM_FID_MASK) >= SPM_FID_MIN_VALUE) && \
28 (((_fid) & SPM_FID_MASK) <= SPM_FID_MAX_VALUE))
29
30/*
31 * SMC IDs defined for accessing services implemented by the Secure Partition
32 * Manager from the Secure Partition(s). These services enable a partition to
33 * handle delegated events and request privileged operations from the manager.
34 */
35#define SPM_VERSION_AARCH32 U(0x84000060)
36#define SP_EVENT_COMPLETE_AARCH64 U(0xC4000061)
37#define SP_MEM_ATTRIBUTES_GET_AARCH64 U(0xC4000064)
38#define SP_MEM_ATTRIBUTES_SET_AARCH64 U(0xC4000065)
39
40/*
41 * Macros used by SP_MEM_ATTRIBUTES_SET_AARCH64.
42 */
43
44#define SP_MEM_ATTR_ACCESS_NOACCESS U(0)
45#define SP_MEM_ATTR_ACCESS_RW U(1)
46/* Value U(2) is reserved. */
47#define SP_MEM_ATTR_ACCESS_RO U(3)
48#define SP_MEM_ATTR_ACCESS_MASK U(3)
49#define SP_MEM_ATTR_ACCESS_SHIFT 0
50
51#define SP_MEM_ATTR_EXEC (U(0) << 2)
52#define SP_MEM_ATTR_NON_EXEC (U(1) << 2)
53
54/*
55 * SMC IDs defined in [1] for accessing secure partition services from the
56 * Non-secure world. These FIDs occupy the range 0x40 - 0x5f
57 * [1] DEN0060A_ARM_MM_Interface_Specification.pdf
58 */
59#define SP_VERSION_AARCH64 U(0xC4000040)
60#define SP_VERSION_AARCH32 U(0x84000040)
61
62#define SP_COMMUNICATE_AARCH64 U(0xC4000041)
63#define SP_COMMUNICATE_AARCH32 U(0x84000041)
64
65/* SPM error codes. */
66#define SPM_SUCCESS 0
67#define SPM_NOT_SUPPORTED -1
68#define SPM_INVALID_PARAMETER -2
69#define SPM_DENIED -3
70#define SPM_NO_MEMORY -5
71
72#ifndef __ASSEMBLY__
73
74#include <stdint.h>
75
76int32_t spm_setup(void);
77
78uint64_t spm_smc_handler(uint32_t smc_fid,
79 uint64_t x1,
80 uint64_t x2,
81 uint64_t x3,
82 uint64_t x4,
83 void *cookie,
84 void *handle,
85 uint64_t flags);
86
87#endif /* __ASSEMBLY__ */
88
89#endif /* __SPM_SVC_H__ */