Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef SPM_SVC_H |
| 8 | #define SPM_SVC_H |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 9 | |
Antonio Nino Diaz | b05de3f | 2018-11-30 10:53:26 +0000 | [diff] [blame] | 10 | #if SPM_DEPRECATED |
| 11 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 12 | #include <utils_def.h> |
| 13 | |
| 14 | #define SPM_VERSION_MAJOR U(0) |
Antonio Nino Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 15 | #define SPM_VERSION_MAJOR_SHIFT 16 |
| 16 | #define SPM_VERSION_MAJOR_MASK U(0x7FFF) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 17 | #define SPM_VERSION_MINOR U(1) |
Antonio Nino Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 18 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 21 | #define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR) |
| 22 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 23 | /* 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 Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 35 | * They occupy the range 0x60-0x7f. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 36 | */ |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 37 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 41 | |
| 42 | /* |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 43 | * Macros used by SP_MEMORY_ATTRIBUTES_SET_AARCH64. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 44 | */ |
| 45 | |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 46 | #define SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0) |
| 47 | #define SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 48 | /* Value U(2) is reserved. */ |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 49 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 52 | |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 53 | #define SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2) |
| 54 | #define SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 55 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 56 | |
| 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 Diaz | b05de3f | 2018-11-30 10:53:26 +0000 | [diff] [blame] | 64 | #endif /* SPM_DEPRECATED */ |
| 65 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 66 | #ifndef __ASSEMBLY__ |
| 67 | |
| 68 | #include <stdint.h> |
| 69 | |
| 70 | int32_t spm_setup(void); |
| 71 | |
Antonio Nino Diaz | b05de3f | 2018-11-30 10:53:26 +0000 | [diff] [blame] | 72 | #if SPM_DEPRECATED |
| 73 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 74 | uint64_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 Diaz | 10c3e98 | 2018-06-20 12:05:02 +0100 | [diff] [blame] | 83 | /* Helper to enter a Secure Partition */ |
| 84 | uint64_t spm_sp_call(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3); |
| 85 | |
Antonio Nino Diaz | b05de3f | 2018-11-30 10:53:26 +0000 | [diff] [blame] | 86 | #endif /* SPM_DEPRECATED */ |
| 87 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 88 | #endif /* __ASSEMBLY__ */ |
| 89 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 90 | #endif /* SPM_SVC_H */ |