Achin Gupta | ae7152e | 2019-10-11 14:32:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SPCI_SVC_H |
| 8 | #define SPCI_SVC_H |
| 9 | |
| 10 | #include <lib/smccc.h> |
| 11 | #include <lib/utils_def.h> |
| 12 | #include <tools_share/uuid.h> |
| 13 | |
| 14 | /* SPCI error codes. */ |
| 15 | #define SPCI_ERROR_NOT_SUPPORTED -1 |
| 16 | #define SPCI_ERROR_INVALID_PARAMETER -2 |
| 17 | #define SPCI_ERROR_NO_MEMORY -3 |
| 18 | #define SPCI_ERROR_BUSY -4 |
| 19 | #define SPCI_ERROR_INTERRUPTED -5 |
| 20 | #define SPCI_ERROR_DENIED -6 |
| 21 | #define SPCI_ERROR_RETRY -7 |
| 22 | |
| 23 | /* The macros below are used to identify SPCI calls from the SMC function ID */ |
| 24 | #define SPCI_FNUM_MIN_VALUE U(0x60) |
| 25 | #define SPCI_FNUM_MAX_VALUE U(0x7f) |
| 26 | #define is_spci_fid(fid) __extension__ ({ \ |
| 27 | __typeof__(fid) _fid = (fid); \ |
| 28 | ((GET_SMC_NUM(_fid) >= SPCI_FNUM_MIN_VALUE) && \ |
| 29 | (GET_SMC_NUM(_fid) <= SPCI_FNUM_MAX_VALUE)); }) |
| 30 | |
| 31 | /* SPCI_VERSION helpers */ |
| 32 | #define SPCI_VERSION_MAJOR U(0) |
| 33 | #define SPCI_VERSION_MAJOR_SHIFT 16 |
| 34 | #define SPCI_VERSION_MAJOR_MASK U(0x7FFF) |
| 35 | #define SPCI_VERSION_MINOR U(9) |
| 36 | #define SPCI_VERSION_MINOR_SHIFT 0 |
| 37 | #define SPCI_VERSION_MINOR_MASK U(0xFFFF) |
| 38 | |
| 39 | #define MAKE_SPCI_VERSION(major, minor) \ |
| 40 | ((((major) & SPCI_VERSION_MAJOR_MASK) << SPCI_VERSION_MAJOR_SHIFT) | \ |
| 41 | (((minor) & SPCI_VERSION_MINOR_MASK) << SPCI_VERSION_MINOR_SHIFT)) |
| 42 | #define SPCI_VERSION_COMPILED MAKE_SPCI_VERSION(SPCI_VERSION_MAJOR, \ |
| 43 | SPCI_VERSION_MINOR) |
| 44 | |
| 45 | /* SPCI_MSG_SEND helpers */ |
| 46 | #define SPCI_MSG_SEND_ATTRS_BLK_SHIFT U(0) |
| 47 | #define SPCI_MSG_SEND_ATTRS_BLK_MASK U(0x1) |
| 48 | #define SPCI_MSG_SEND_ATTRS_BLK U(0) |
| 49 | #define SPCI_MSG_SEND_ATTRS_BLK_NOT U(1) |
| 50 | #define SPCI_MSG_SEND_ATTRS(blk) \ |
| 51 | (((blk) & SPCI_MSG_SEND_ATTRS_BLK_MASK) \ |
| 52 | << SPCI_MSG_SEND_ATTRS_BLK_SHIFT) |
| 53 | |
| 54 | /* Get SPCI fastcall std FID from function number */ |
| 55 | #define SPCI_FID(smc_cc, func_num) \ |
| 56 | ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ |
| 57 | ((smc_cc) << FUNCID_CC_SHIFT) | \ |
| 58 | (OEN_STD_START << FUNCID_OEN_SHIFT) | \ |
| 59 | ((func_num) << FUNCID_NUM_SHIFT)) |
| 60 | |
| 61 | /* SPCI function numbers */ |
| 62 | #define SPCI_FNUM_ERROR U(0x60) |
| 63 | #define SPCI_FNUM_SUCCESS U(0x61) |
| 64 | #define SPCI_FNUM_INTERRUPT U(0x62) |
| 65 | #define SPCI_FNUM_VERSION U(0x63) |
| 66 | #define SPCI_FNUM_FEATURES U(0x64) |
| 67 | #define SPCI_FNUM_RX_RELEASE U(0x65) |
| 68 | #define SPCI_FNUM_RXTX_MAP U(0x66) |
| 69 | #define SPCI_FNUM_RXTX_UNMAP U(0x67) |
| 70 | #define SPCI_FNUM_PARTITION_INFO_GET U(0x68) |
| 71 | #define SPCI_FNUM_ID_GET U(0x69) |
| 72 | #define SPCI_FNUM_MSG_POLL U(0x6A) |
| 73 | #define SPCI_FNUM_MSG_WAIT U(0x6B) |
| 74 | #define SPCI_FNUM_MSG_YIELD U(0x6C) |
| 75 | #define SPCI_FNUM_MSG_RUN U(0x6D) |
| 76 | #define SPCI_FNUM_MSG_SEND U(0x6E) |
| 77 | #define SPCI_FNUM_MSG_SEND_DIRECT_REQ U(0x6F) |
| 78 | #define SPCI_FNUM_MSG_SEND_DIRECT_RESP U(0x70) |
| 79 | #define SPCI_FNUM_MEM_DONATE U(0x71) |
| 80 | #define SPCI_FNUM_MEM_LEND U(0x72) |
| 81 | #define SPCI_FNUM_MEM_SHARE U(0x73) |
| 82 | #define SPCI_FNUM_MEM_RETRIEVE_REQ U(0x74) |
| 83 | #define SPCI_FNUM_MEM_RETRIEVE_RESP U(0x75) |
| 84 | #define SPCI_FNUM_MEM_RELINQUISH U(0x76) |
| 85 | #define SPCI_FNUM_MEM_RECLAIM U(0x77) |
| 86 | |
| 87 | /* SPCI SMC32 FIDs */ |
| 88 | #define SPCI_ERROR SPCI_FID(SMC_32, SPCI_FNUM_ERROR) |
| 89 | #define SPCI_SUCCESS_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_SUCCESS) |
| 90 | #define SPCI_INTERRUPT SPCI_FID(SMC_32, SPCI_FNUM_INTERRUPT) |
| 91 | #define SPCI_VERSION SPCI_FID(SMC_32, SPCI_FNUM_VERSION) |
| 92 | #define SPCI_FEATURES SPCI_FID(SMC_32, SPCI_FNUM_FEATURES) |
| 93 | #define SPCI_RX_RELEASE SPCI_FID(SMC_32, SPCI_FNUM_RX_RELEASE) |
| 94 | #define SPCI_RXTX_MAP_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_RXTX_MAP) |
| 95 | #define SPCI_RXTX_UNMAP SPCI_FID(SMC_32, SPCI_FNUM_RXTX_UNMAP) |
| 96 | #define SPCI_PARTITION_INFO_GET SPCI_FID(SMC_32, SPCI_FNUM_PARTITION_INFO_GET) |
| 97 | #define SPCI_ID_GET SPCI_FID(SMC_32, SPCI_FNUM_ID_GET) |
| 98 | #define SPCI_MSG_POLL SPCI_FID(SMC_32, SPCI_FNUM_MSG_POLL) |
| 99 | #define SPCI_MSG_WAIT SPCI_FID(SMC_32, SPCI_FNUM_MSG_WAIT) |
| 100 | #define SPCI_MSG_YIELD SPCI_FID(SMC_32, SPCI_FNUM_MSG_YIELD) |
| 101 | #define SPCI_MSG_RUN SPCI_FID(SMC_32, SPCI_FNUM_MSG_RUN) |
| 102 | #define SPCI_MSG_SEND SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND) |
| 103 | #define SPCI_MSG_SEND_DIRECT_REQ_SMC32 \ |
| 104 | SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND_DIRECT_REQ) |
| 105 | #define SPCI_MSG_SEND_DIRECT_RESP_SMC32 \ |
| 106 | SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND_DIRECT_RESP) |
| 107 | #define SPCI_MEM_DONATE_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_DONATE) |
| 108 | #define SPCI_MEM_LEND_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_LEND) |
| 109 | #define SPCI_MEM_SHARE_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_SHARE) |
| 110 | #define SPCI_MEM_RETRIEVE_REQ_SMC32 \ |
| 111 | SPCI_FID(SMC_32, SPCI_FNUM_MEM_RETRIEVE_REQ) |
| 112 | #define SPCI_MEM_RETRIEVE_RESP SPCI_FID(SMC_32, SPCI_FNUM_MEM_RETRIEVE_RESP) |
| 113 | #define SPCI_MEM_RELINQUISH SPCI_FID(SMC_32, SPCI_FNUM_MEM_RELINQUISH) |
| 114 | #define SPCI_MEM_RECLAIM SPCI_FID(SMC_32, SPCI_FNUM_MEM_RECLAIM) |
| 115 | |
| 116 | /* SPCI SMC64 FIDs */ |
| 117 | #define SPCI_SUCCESS_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_SUCCESS) |
| 118 | #define SPCI_RXTX_MAP_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_RXTX_MAP) |
| 119 | #define SPCI_MSG_SEND_DIRECT_REQ_SMC64 \ |
| 120 | SPCI_FID(SMC_64, SPCI_FNUM_MSG_SEND_DIRECT_REQ) |
| 121 | #define SPCI_MSG_SEND_DIRECT_RESP_SMC64 \ |
| 122 | SPCI_FID(SMC_64, SPCI_FNUM_MSG_SEND_DIRECT_RESP) |
| 123 | #define SPCI_MEM_DONATE_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_DONATE) |
| 124 | #define SPCI_MEM_LEND_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_LEND) |
| 125 | #define SPCI_MEM_SHARE_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_SHARE) |
| 126 | #define SPCI_MEM_RETRIEVE_REQ_SMC64 \ |
| 127 | SPCI_FID(SMC_64, SPCI_FNUM_MEM_RETRIEVE_REQ) |
| 128 | |
| 129 | /* |
| 130 | * Reserve a special value for traffic targeted to the Hypervisor or SPM. |
| 131 | */ |
| 132 | #define SPCI_TARGET_INFO_MBZ U(0x0) |
| 133 | |
| 134 | /* |
| 135 | * Reserve a special value for MBZ parameters. |
| 136 | */ |
| 137 | #define SPCI_PARAM_MBZ U(0x0) |
| 138 | |
| 139 | #endif /* SPCI_SVC_H */ |