Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef RMI_SVC_H |
| 8 | #define RMI_SVC_H |
| 9 | |
| 10 | #include <lib/smccc.h> |
| 11 | #include <lib/utils_def.h> |
| 12 | |
| 13 | /* RMI error codes. */ |
| 14 | #define RMI_SUCCESS 0 |
| 15 | #define RMI_ERROR_NOT_SUPPORTED -1 |
| 16 | #define RMI_ERROR_INVALID_ADDRESS -2 |
| 17 | #define RMI_ERROR_INVALID_PAS -3 |
| 18 | |
| 19 | /* The macros below are used to identify RMI calls from the SMC function ID */ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 20 | #define RMI_FNUM_MIN_VALUE U(0x150) |
| 21 | #define RMI_FNUM_MAX_VALUE U(0x18F) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 22 | #define is_rmi_fid(fid) __extension__ ({ \ |
| 23 | __typeof__(fid) _fid = (fid); \ |
| 24 | ((GET_SMC_NUM(_fid) >= RMI_FNUM_MIN_VALUE) && \ |
| 25 | (GET_SMC_NUM(_fid) <= RMI_FNUM_MAX_VALUE) && \ |
| 26 | (GET_SMC_TYPE(_fid) == SMC_TYPE_FAST) && \ |
| 27 | (GET_SMC_CC(_fid) == SMC_64) && \ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 28 | (GET_SMC_OEN(_fid) == OEN_STD_START) && \ |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 29 | ((_fid & 0x00FE0000) == 0U)); }) |
| 30 | |
| 31 | /* Get RMI fastcall std FID from function number */ |
| 32 | #define RMI_FID(smc_cc, func_num) \ |
| 33 | ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ |
| 34 | ((smc_cc) << FUNCID_CC_SHIFT) | \ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 35 | (OEN_STD_START << FUNCID_OEN_SHIFT) | \ |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 36 | ((func_num) << FUNCID_NUM_SHIFT)) |
| 37 | |
| 38 | /* |
| 39 | * SMC_RMM_INIT_COMPLETE is the only function in the RMI that originates from |
| 40 | * the Realm world and is handled by the RMMD. The remaining functions are |
| 41 | * always invoked by the Normal world, forwarded by RMMD and handled by the |
| 42 | * RMM |
| 43 | */ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 44 | #define RMI_FNUM_REQ_COMPLETE U(0x18F) |
| 45 | #define RMI_FNUM_VERSION_REQ U(0x150) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 46 | |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 47 | #define RMI_FNUM_GRANULE_DELEGATE U(0x151) |
| 48 | #define RMI_FNUM_GRANULE_UNDELEGATE U(0x152) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 49 | |
| 50 | /* RMI SMC64 FIDs handled by the RMMD */ |
| 51 | #define RMI_RMM_REQ_COMPLETE RMI_FID(SMC_64, RMI_FNUM_REQ_COMPLETE) |
| 52 | #define RMI_RMM_REQ_VERSION RMI_FID(SMC_64, RMI_FNUM_VERSION_REQ) |
| 53 | |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 54 | #define RMI_RMM_GRANULE_DELEGATE RMI_FID(SMC_64, \ |
| 55 | RMI_FNUM_GRANULE_DELEGATE) |
| 56 | #define RMI_RMM_GRANULE_UNDELEGATE RMI_FID(SMC_64, \ |
| 57 | RMI_FNUM_GRANULE_UNDELEGATE) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 58 | |
| 59 | #define RMI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16) |
| 60 | #define RMI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFF) |
| 61 | |
| 62 | /* Reserve a special value for MBZ parameters. */ |
| 63 | #define RMI_PARAM_MBZ U(0x0) |
| 64 | |
| 65 | #endif /* RMI_SVC_H */ |