blob: ef4289f50339b509e07eaf97d1eb89011cdee6cc [file] [log] [blame]
Zelalem Aweke13dc8f12021-07-09 14:20:03 -05001/*
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 Ghosh8cc642c2021-11-14 17:19:09 +000017#define GTSI_FNUM_MIN_VALUE U(0x1B0)
18#define GTSI_FNUM_MAX_VALUE U(0x1B1)
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050019#define is_gtsi_fid(fid) __extension__ ({ \
20 __typeof__(fid) _fid = (fid); \
21 ((GET_SMC_NUM(_fid) >= GTSI_FNUM_MIN_VALUE) && \
Subhasish Ghosh8cc642c2021-11-14 17:19:09 +000022 (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 Aweke13dc8f12021-07-09 14:20:03 -050027
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 Ghosh8cc642c2021-11-14 17:19:09 +000035#define GRAN_TRANS_TO_REALM_FNUM U(0x1B0)
36#define GRAN_TRANS_TO_NS_FNUM U(0x1B1)
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050037
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 */