blob: a3723a0f50e6a840d266b21282475ee1e4733619 [file] [log] [blame]
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01001/*
Antonio Nino Diazcbccdbf2019-01-21 11:53:29 +00002 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef SPM_SVC_H
8#define SPM_SVC_H
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01009
Antonio Nino Diazcbccdbf2019-01-21 11:53:29 +000010#if SPM_MM
Antonio Nino Diazb05de3f2018-11-30 10:53:26 +000011
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/utils_def.h>
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010013
14#define SPM_VERSION_MAJOR U(0)
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000015#define SPM_VERSION_MAJOR_SHIFT 16
16#define SPM_VERSION_MAJOR_MASK U(0x7FFF)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010017#define SPM_VERSION_MINOR U(1)
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000018#define SPM_VERSION_MINOR_SHIFT 0
19#define SPM_VERSION_MINOR_MASK U(0xFFFF)
20#define SPM_VERSION_FORM(major, minor) ((major << SPM_VERSION_MAJOR_SHIFT) | (minor))
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010021#define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR)
22
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010023/* The macros below are used to identify SPM calls from the SMC function ID */
24#define SPM_FID_MASK U(0xffff)
25#define SPM_FID_MIN_VALUE U(0x40)
26#define SPM_FID_MAX_VALUE U(0x7f)
27#define is_spm_fid(_fid) \
28 ((((_fid) & SPM_FID_MASK) >= SPM_FID_MIN_VALUE) && \
29 (((_fid) & SPM_FID_MASK) <= SPM_FID_MAX_VALUE))
30
31/*
32 * SMC IDs defined for accessing services implemented by the Secure Partition
33 * Manager from the Secure Partition(s). These services enable a partition to
34 * handle delegated events and request privileged operations from the manager.
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000035 * They occupy the range 0x60-0x7f.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010036 */
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000037#define SPM_VERSION_AARCH32 U(0x84000060)
38#define SP_EVENT_COMPLETE_AARCH64 U(0xC4000061)
39#define SP_MEMORY_ATTRIBUTES_GET_AARCH64 U(0xC4000064)
40#define SP_MEMORY_ATTRIBUTES_SET_AARCH64 U(0xC4000065)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010041
42/*
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000043 * Macros used by SP_MEMORY_ATTRIBUTES_SET_AARCH64.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010044 */
45
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000046#define SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0)
47#define SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010048/* Value U(2) is reserved. */
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000049#define SP_MEMORY_ATTRIBUTES_ACCESS_RO U(3)
50#define SP_MEMORY_ATTRIBUTES_ACCESS_MASK U(3)
51#define SP_MEMORY_ATTRIBUTES_ACCESS_SHIFT 0
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010052
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000053#define SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2)
54#define SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010055
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010056
57/* SPM error codes. */
58#define SPM_SUCCESS 0
59#define SPM_NOT_SUPPORTED -1
60#define SPM_INVALID_PARAMETER -2
61#define SPM_DENIED -3
62#define SPM_NO_MEMORY -5
63
Antonio Nino Diazcbccdbf2019-01-21 11:53:29 +000064#endif /* SPM_MM */
Antonio Nino Diazb05de3f2018-11-30 10:53:26 +000065
Julius Werner53456fc2019-07-09 13:49:11 -070066#ifndef __ASSEMBLER__
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010067
68#include <stdint.h>
69
70int32_t spm_setup(void);
71
Antonio Nino Diazcbccdbf2019-01-21 11:53:29 +000072#if SPM_MM
Antonio Nino Diazb05de3f2018-11-30 10:53:26 +000073
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010074uint64_t spm_smc_handler(uint32_t smc_fid,
75 uint64_t x1,
76 uint64_t x2,
77 uint64_t x3,
78 uint64_t x4,
79 void *cookie,
80 void *handle,
81 uint64_t flags);
82
Antonio Nino Diaz10c3e982018-06-20 12:05:02 +010083/* Helper to enter a Secure Partition */
84uint64_t spm_sp_call(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3);
85
Antonio Nino Diazcbccdbf2019-01-21 11:53:29 +000086#endif /* SPM_MM */
Antonio Nino Diazb05de3f2018-11-30 10:53:26 +000087
Julius Werner53456fc2019-07-09 13:49:11 -070088#endif /* __ASSEMBLER__ */
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010089
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000090#endif /* SPM_SVC_H */