blob: 7a69b282875b4be00a795c906b7553ca356ad0e1 [file] [log] [blame]
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01001/*
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +00002 * Copyright (c) 2017-2018, 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
10#include <utils_def.h>
11
12#define SPM_VERSION_MAJOR U(0)
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000013#define SPM_VERSION_MAJOR_SHIFT 16
14#define SPM_VERSION_MAJOR_MASK U(0x7FFF)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010015#define SPM_VERSION_MINOR U(1)
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000016#define SPM_VERSION_MINOR_SHIFT 0
17#define SPM_VERSION_MINOR_MASK U(0xFFFF)
18#define SPM_VERSION_FORM(major, minor) ((major << SPM_VERSION_MAJOR_SHIFT) | (minor))
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010019#define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR)
20
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010021/* The macros below are used to identify SPM calls from the SMC function ID */
22#define SPM_FID_MASK U(0xffff)
23#define SPM_FID_MIN_VALUE U(0x40)
24#define SPM_FID_MAX_VALUE U(0x7f)
25#define is_spm_fid(_fid) \
26 ((((_fid) & SPM_FID_MASK) >= SPM_FID_MIN_VALUE) && \
27 (((_fid) & SPM_FID_MASK) <= SPM_FID_MAX_VALUE))
28
29/*
30 * SMC IDs defined for accessing services implemented by the Secure Partition
31 * Manager from the Secure Partition(s). These services enable a partition to
32 * handle delegated events and request privileged operations from the manager.
Antonio Nino Diaz35b37f02018-01-08 17:33:34 +000033 * They occupy the range 0x60-0x7f.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010034 */
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000035#define SPM_VERSION_AARCH32 U(0x84000060)
36#define SP_EVENT_COMPLETE_AARCH64 U(0xC4000061)
37#define SP_MEMORY_ATTRIBUTES_GET_AARCH64 U(0xC4000064)
38#define SP_MEMORY_ATTRIBUTES_SET_AARCH64 U(0xC4000065)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010039
40/*
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000041 * Macros used by SP_MEMORY_ATTRIBUTES_SET_AARCH64.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010042 */
43
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000044#define SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0)
45#define SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010046/* Value U(2) is reserved. */
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000047#define SP_MEMORY_ATTRIBUTES_ACCESS_RO U(3)
48#define SP_MEMORY_ATTRIBUTES_ACCESS_MASK U(3)
49#define SP_MEMORY_ATTRIBUTES_ACCESS_SHIFT 0
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010050
Antonio Nino Diaz837173f2017-12-01 14:12:43 +000051#define SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2)
52#define SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2)
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010053
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010054
55/* SPM error codes. */
56#define SPM_SUCCESS 0
57#define SPM_NOT_SUPPORTED -1
58#define SPM_INVALID_PARAMETER -2
59#define SPM_DENIED -3
60#define SPM_NO_MEMORY -5
61
62#ifndef __ASSEMBLY__
63
64#include <stdint.h>
65
66int32_t spm_setup(void);
67
68uint64_t spm_smc_handler(uint32_t smc_fid,
69 uint64_t x1,
70 uint64_t x2,
71 uint64_t x3,
72 uint64_t x4,
73 void *cookie,
74 void *handle,
75 uint64_t flags);
76
Antonio Nino Diaz10c3e982018-06-20 12:05:02 +010077/* Helper to enter a Secure Partition */
78uint64_t spm_sp_call(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3);
79
Antonio Nino Diazc41f2062017-10-24 10:07:35 +010080#endif /* __ASSEMBLY__ */
81
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000082#endif /* SPM_SVC_H */