Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 0e402d3 | 2019-01-30 16:01:49 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SPCI_SVC_H |
| 8 | #define SPCI_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 | /* SPCI_VERSION helpers */ |
| 14 | |
| 15 | #define SPCI_VERSION_MAJOR U(0) |
| 16 | #define SPCI_VERSION_MAJOR_SHIFT 16 |
| 17 | #define SPCI_VERSION_MAJOR_MASK U(0x7FFF) |
| 18 | #define SPCI_VERSION_MINOR U(1) |
| 19 | #define SPCI_VERSION_MINOR_SHIFT 0 |
| 20 | #define SPCI_VERSION_MINOR_MASK U(0xFFFF) |
| 21 | #define SPCI_VERSION_FORM(major, minor) ((((major) & SPCI_VERSION_MAJOR_MASK) \ |
| 22 | << SPCI_VERSION_MAJOR_SHIFT) | \ |
| 23 | ((minor) & SPCI_VERSION_MINOR_MASK)) |
| 24 | #define SPCI_VERSION_COMPILED SPCI_VERSION_FORM(SPCI_VERSION_MAJOR, \ |
| 25 | SPCI_VERSION_MINOR) |
| 26 | |
| 27 | /* Definitions to build the complete SMC ID */ |
| 28 | |
| 29 | #define SPCI_FID_MISC_FLAG (U(0) << 27) |
| 30 | #define SPCI_FID_MISC_SHIFT U(20) |
| 31 | #define SPCI_FID_MISC_MASK U(0x7F) |
| 32 | |
| 33 | #define SPCI_FID_TUN_FLAG (U(1) << 27) |
| 34 | #define SPCI_FID_TUN_SHIFT U(24) |
| 35 | #define SPCI_FID_TUN_MASK U(0x7) |
| 36 | |
Antonio Nino Diaz | 0e402d3 | 2019-01-30 16:01:49 +0000 | [diff] [blame] | 37 | #define OEN_SPCI_START U(0x30) |
| 38 | #define OEN_SPCI_END U(0x3F) |
| 39 | |
| 40 | #define SPCI_SMC(spci_fid) ((OEN_SPCI_START << FUNCID_OEN_SHIFT) | \ |
Antonio Nino Diaz | f939a6a | 2018-11-08 14:12:40 +0000 | [diff] [blame] | 41 | (U(1) << 31) | (spci_fid)) |
| 42 | #define SPCI_MISC_32(misc_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \ |
| 43 | SPCI_FID_MISC_FLAG | \ |
| 44 | SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT)) |
| 45 | #define SPCI_MISC_64(misc_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \ |
| 46 | SPCI_FID_MISC_FLAG | \ |
| 47 | SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT)) |
| 48 | #define SPCI_TUN_32(tun_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \ |
| 49 | SPCI_FID_TUN_FLAG | \ |
| 50 | SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT)) |
| 51 | #define SPCI_TUN_64(tun_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \ |
| 52 | SPCI_FID_TUN_FLAG | \ |
| 53 | SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT)) |
| 54 | |
| 55 | /* SPCI miscellaneous functions */ |
| 56 | |
| 57 | #define SPCI_FID_VERSION U(0x0) |
| 58 | #define SPCI_FID_SERVICE_HANDLE_OPEN U(0x2) |
| 59 | #define SPCI_FID_SERVICE_HANDLE_CLOSE U(0x3) |
| 60 | #define SPCI_FID_SERVICE_MEM_REGISTER U(0x4) |
| 61 | #define SPCI_FID_SERVICE_MEM_UNREGISTER U(0x5) |
| 62 | #define SPCI_FID_SERVICE_MEM_PUBLISH U(0x6) |
| 63 | #define SPCI_FID_SERVICE_REQUEST_BLOCKING U(0x7) |
| 64 | #define SPCI_FID_SERVICE_REQUEST_START U(0x8) |
| 65 | #define SPCI_FID_SERVICE_GET_RESPONSE U(0x9) |
| 66 | #define SPCI_FID_SERVICE_RESET_CLIENT_STATE U(0xA) |
| 67 | |
| 68 | /* SPCI tunneling functions */ |
| 69 | |
| 70 | #define SPCI_FID_SERVICE_TUN_REQUEST_START U(0x0) |
| 71 | #define SPCI_FID_SERVICE_REQUEST_RESUME U(0x1) |
| 72 | #define SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING U(0x2) |
| 73 | |
| 74 | /* Complete SMC IDs and associated values */ |
| 75 | |
| 76 | #define SPCI_VERSION SPCI_MISC_32(SPCI_FID_VERSION) |
| 77 | |
| 78 | #define SPCI_SERVICE_HANDLE_OPEN SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_OPEN) |
| 79 | #define SPCI_SERVICE_HANDLE_OPEN_NOTIFY_BIT U(1) |
| 80 | |
| 81 | #define SPCI_SERVICE_HANDLE_CLOSE SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_CLOSE) |
| 82 | |
| 83 | #define SPCI_SERVICE_MEM_REGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_REGISTER) |
| 84 | #define SPCI_SERVICE_MEM_REGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_REGISTER) |
| 85 | |
| 86 | #define SPCI_SERVICE_MEM_UNREGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_UNREGISTER) |
| 87 | #define SPCI_SERVICE_MEM_UNREGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_UNREGISTER) |
| 88 | |
| 89 | #define SPCI_SERVICE_MEM_PUBLISH_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_PUBLISH) |
| 90 | #define SPCI_SERVICE_MEM_PUBLISH_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_PUBLISH) |
| 91 | |
| 92 | #define SPCI_SERVICE_REQUEST_BLOCKING_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_BLOCKING) |
| 93 | #define SPCI_SERVICE_REQUEST_BLOCKING_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_BLOCKING) |
| 94 | |
| 95 | #define SPCI_SERVICE_REQUEST_START_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_START) |
| 96 | #define SPCI_SERVICE_REQUEST_START_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_START) |
| 97 | |
| 98 | #define SPCI_SERVICE_GET_RESPONSE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_GET_RESPONSE) |
| 99 | #define SPCI_SERVICE_GET_RESPONSE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_GET_RESPONSE) |
| 100 | |
| 101 | #define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_RESET_CLIENT_STATE) |
| 102 | #define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_RESET_CLIENT_STATE) |
| 103 | |
| 104 | #define SPCI_SERVICE_TUN_REQUEST_START_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_START) |
| 105 | #define SPCI_SERVICE_TUN_REQUEST_START_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_START) |
| 106 | |
| 107 | #define SPCI_SERVICE_REQUEST_RESUME_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_REQUEST_RESUME) |
| 108 | #define SPCI_SERVICE_REQUEST_RESUME_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_REQUEST_RESUME) |
| 109 | |
| 110 | #define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING) |
| 111 | #define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING) |
| 112 | |
| 113 | /* SPCI error codes. */ |
| 114 | |
| 115 | #define SPCI_SUCCESS 0 |
| 116 | #define SPCI_NOT_SUPPORTED -1 |
| 117 | #define SPCI_INVALID_PARAMETER -2 |
| 118 | #define SPCI_NO_MEMORY -3 |
| 119 | #define SPCI_BUSY -4 |
| 120 | #define SPCI_QUEUED -5 |
| 121 | #define SPCI_DENIED -6 |
| 122 | #define SPCI_NOT_PRESENT -7 |
| 123 | |
| 124 | #endif /* SPCI_SVC_H */ |