blob: 46fd5109dcd98c104e62aa69d3b24678671aedfb [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 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 Ghosh8cc642c2021-11-14 17:19:09 +000020#define RMI_FNUM_MIN_VALUE U(0x150)
21#define RMI_FNUM_MAX_VALUE U(0x18F)
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050022#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 Ghosh8cc642c2021-11-14 17:19:09 +000028 (GET_SMC_OEN(_fid) == OEN_STD_START) && \
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050029 ((_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 Ghosh8cc642c2021-11-14 17:19:09 +000035 (OEN_STD_START << FUNCID_OEN_SHIFT) | \
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050036 ((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 Ghosh8cc642c2021-11-14 17:19:09 +000044#define RMI_FNUM_REQ_COMPLETE U(0x18F)
45#define RMI_FNUM_VERSION_REQ U(0x150)
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050046
Subhasish Ghosh8cc642c2021-11-14 17:19:09 +000047#define RMI_FNUM_GRANULE_DELEGATE U(0x151)
48#define RMI_FNUM_GRANULE_UNDELEGATE U(0x152)
Zelalem Aweke13dc8f12021-07-09 14:20:03 -050049
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 Ghosh8cc642c2021-11-14 17:19:09 +000054#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 Aweke13dc8f12021-07-09 14:20:03 -050058
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 */