blob: 22f635babb7fc9946d98ae874cd65d3e7458e44a [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 */
20#define RMI_FNUM_MIN_VALUE U(0x00)
21#define RMI_FNUM_MAX_VALUE U(0x20)
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) && \
28 (GET_SMC_OEN(_fid) == OEN_ARM_START) && \
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) | \
35 (OEN_ARM_START << FUNCID_OEN_SHIFT) | \
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 */
44#define RMI_FNUM_REQ_COMPLETE U(0x10)
45#define RMI_FNUM_VERSION_REQ U(0x00)
46
47#define RMI_FNUM_GRAN_NS_REALM U(0x01)
Mark Dykes28e7b3d2021-11-08 10:36:53 -060048#define RMI_FNUM_GRAN_REALM_NS U(0x02)
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
54#define RMI_RMM_GRANULE_DELEGATE RMI_FID(SMC_64, RMI_FNUM_GRAN_NS_REALM)
55#define RMI_RMM_GRANULE_UNDELEGATE RMI_FID(SMC_64, RMI_FNUM_GRAN_REALM_NS)
56
57
58#define RMI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16)
59#define RMI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFF)
60
61/* Reserve a special value for MBZ parameters. */
62#define RMI_PARAM_MBZ U(0x0)
63
64#endif /* RMI_SVC_H */