Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SPRT_SVC_H |
| 8 | #define SPRT_SVC_H |
| 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame^] | 10 | #include <lib/smccc.h> |
| 11 | #include <lib/utils_def.h> |
Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 12 | |
| 13 | /* SPRT_VERSION helpers */ |
| 14 | |
| 15 | #define SPRT_VERSION_MAJOR U(0) |
| 16 | #define SPRT_VERSION_MAJOR_SHIFT 16 |
| 17 | #define SPRT_VERSION_MAJOR_MASK U(0x7FFF) |
| 18 | #define SPRT_VERSION_MINOR U(1) |
| 19 | #define SPRT_VERSION_MINOR_SHIFT 0 |
| 20 | #define SPRT_VERSION_MINOR_MASK U(0xFFFF) |
| 21 | #define SPRT_VERSION_FORM(major, minor) ((((major) & SPRT_VERSION_MAJOR_MASK) \ |
| 22 | << SPRT_VERSION_MAJOR_SHIFT) | \ |
| 23 | ((minor) & SPRT_VERSION_MINOR_MASK)) |
| 24 | #define SPRT_VERSION_COMPILED SPRT_VERSION_FORM(SPRT_VERSION_MAJOR, \ |
| 25 | SPRT_VERSION_MINOR) |
| 26 | |
| 27 | /* SPRT function IDs */ |
| 28 | |
| 29 | #define SPRT_FID_VERSION U(0x0) |
| 30 | #define SPRT_FID_PUT_RESPONSE U(0x1) |
| 31 | #define SPRT_FID_YIELD U(0x5) |
| 32 | #define SPRT_FID_PANIC U(0x7) |
| 33 | #define SPRT_FID_MEMORY_PERM_ATTR_GET U(0xB) |
| 34 | #define SPRT_FID_MEMORY_PERM_ATTR_SET U(0xC) |
| 35 | |
| 36 | #define SPRT_FID_MASK U(0xFF) |
| 37 | |
| 38 | /* Definitions to build the complete SMC ID */ |
| 39 | |
| 40 | #define SPRT_SMC_64(sprt_fid) ((FUNCID_NAMESPACE_SPRT << FUNCID_NAMESPACE_SHIFT) | \ |
| 41 | (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \ |
| 42 | (SMC_64 << FUNCID_CC_SHIFT)) |
| 43 | #define SPRT_SMC_32(sprt_fid) ((FUNCID_NAMESPACE_SPRT << FUNCID_NAMESPACE_SHIFT) | \ |
| 44 | (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \ |
| 45 | (SMC_32 << FUNCID_CC_SHIFT)) |
| 46 | |
| 47 | /* Complete SMC IDs */ |
| 48 | |
| 49 | #define SPRT_VERSION SPRT_SMC_32(SPRT_FID_VERSION) |
| 50 | #define SPRT_PUT_RESPONSE_AARCH64 SPRT_SMC_64(SPRT_FID_PUT_RESPONSE) |
| 51 | #define SPRT_YIELD_AARCH64 SPRT_SMC_64(SPRT_FID_YIELD) |
| 52 | #define SPRT_PANIC_AARCH64 SPRT_SMC_64(SPRT_FID_PANIC) |
| 53 | #define SPRT_MEMORY_PERM_ATTR_GET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_GET) |
| 54 | #define SPRT_MEMORY_PERM_ATTR_SET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_SET) |
| 55 | |
Antonio Nino Diaz | 124a1fc | 2018-11-30 10:52:09 +0000 | [diff] [blame] | 56 | /* Defines used by SPRT_MEMORY_PERM_ATTR_{GET,SET}_AARCH64 */ |
| 57 | |
| 58 | #define SPRT_MEMORY_PERM_ATTR_RO U(0) |
| 59 | #define SPRT_MEMORY_PERM_ATTR_RW U(1) |
| 60 | #define SPRT_MEMORY_PERM_ATTR_RO_EXEC U(2) |
| 61 | /* U(3) is reserved */ |
| 62 | #define SPRT_MEMORY_PERM_ATTR_MASK U(3) |
| 63 | #define SPRT_MEMORY_PERM_ATTR_SHIFT 3 |
| 64 | |
Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 65 | /* SPRT error codes. */ |
| 66 | |
| 67 | #define SPRT_SUCCESS 0 |
| 68 | #define SPRT_NOT_SUPPORTED -1 |
| 69 | #define SPRT_INVALID_PARAMETER -2 |
| 70 | |
| 71 | #endif /* SPRT_SVC_H */ |