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 GTSI_SVC_H |
| 8 | #define GTSI_SVC_H |
| 9 | |
| 10 | /* GTSI error codes. */ |
| 11 | #define GTSI_SUCCESS 0 |
| 12 | #define GTSI_ERROR_NOT_SUPPORTED -1 |
| 13 | #define GTSI_ERROR_INVALID_ADDRESS -2 |
| 14 | #define GTSI_ERROR_INVALID_PAS -3 |
| 15 | |
| 16 | /* The macros below are used to identify GTSI calls from the SMC function ID */ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 17 | #define GTSI_FNUM_MIN_VALUE U(0x1B0) |
| 18 | #define GTSI_FNUM_MAX_VALUE U(0x1B1) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 19 | #define is_gtsi_fid(fid) __extension__ ({ \ |
| 20 | __typeof__(fid) _fid = (fid); \ |
| 21 | ((GET_SMC_NUM(_fid) >= GTSI_FNUM_MIN_VALUE) && \ |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 22 | (GET_SMC_NUM(_fid) <= GTSI_FNUM_MAX_VALUE) && \ |
| 23 | (GET_SMC_TYPE(_fid) == SMC_TYPE_FAST) && \ |
| 24 | (GET_SMC_CC(_fid) == SMC_64) && \ |
| 25 | (GET_SMC_OEN(_fid) == OEN_STD_START) && \ |
| 26 | ((_fid & 0x00FE0000) == 0U)); }) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 27 | |
| 28 | /* Get GTSI fastcall std FID from function number */ |
| 29 | #define GTSI_FID(smc_cc, func_num) \ |
| 30 | ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ |
| 31 | ((smc_cc) << FUNCID_CC_SHIFT) | \ |
| 32 | (OEN_STD_START << FUNCID_OEN_SHIFT) | \ |
| 33 | ((func_num) << FUNCID_NUM_SHIFT)) |
| 34 | |
Subhasish Ghosh | 8cc642c | 2021-11-14 17:19:09 +0000 | [diff] [blame] | 35 | #define GRAN_TRANS_TO_REALM_FNUM U(0x1B0) |
| 36 | #define GRAN_TRANS_TO_NS_FNUM U(0x1B1) |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 37 | |
| 38 | #define SMC_ASC_MARK_REALM GTSI_FID(SMC_64, GRAN_TRANS_TO_REALM_FNUM) |
| 39 | #define SMC_ASC_MARK_NONSECURE GTSI_FID(SMC_64, GRAN_TRANS_TO_NS_FNUM) |
| 40 | |
| 41 | #define GRAN_TRANS_RET_BAD_ADDR -2 |
| 42 | #define GRAN_TRANS_RET_BAD_PAS -3 |
| 43 | |
| 44 | #endif /* GTSI_SVC_H */ |