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 | |
| 10 | #include <utils_def.h> |
| 11 | |
| 12 | #define SPM_VERSION_MAJOR U(0) |
Antonio Nino Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 13 | #define SPM_VERSION_MAJOR_SHIFT 16 |
| 14 | #define SPM_VERSION_MAJOR_MASK U(0x7FFF) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 15 | #define SPM_VERSION_MINOR U(1) |
Antonio Nino Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 16 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 19 | #define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR) |
| 20 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 21 | /* 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 Diaz | 35b37f0 | 2018-01-08 17:33:34 +0000 | [diff] [blame] | 33 | * They occupy the range 0x60-0x7f. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 34 | */ |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 35 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 39 | |
| 40 | /* |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 41 | * Macros used by SP_MEMORY_ATTRIBUTES_SET_AARCH64. |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 42 | */ |
| 43 | |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 44 | #define SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0) |
| 45 | #define SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 46 | /* Value U(2) is reserved. */ |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 47 | #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 Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 50 | |
Antonio Nino Diaz | 837173f | 2017-12-01 14:12:43 +0000 | [diff] [blame] | 51 | #define SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2) |
| 52 | #define SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2) |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 53 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 54 | |
| 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 | |
| 66 | int32_t spm_setup(void); |
| 67 | |
| 68 | uint64_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 Diaz | 10c3e98 | 2018-06-20 12:05:02 +0100 | [diff] [blame] | 77 | /* Helper to enter a Secure Partition */ |
| 78 | uint64_t spm_sp_call(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3); |
| 79 | |
Antonio Nino Diaz | c41f206 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 80 | #endif /* __ASSEMBLY__ */ |
| 81 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 82 | #endif /* SPM_SVC_H */ |