blob: fe321750a0249f5d92a288d6bf4e64d707ff5a8d [file] [log] [blame]
J-Alves2672cde2020-05-07 18:42:25 +01001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef FFA_SVC_H
8#define FFA_SVC_H
9
10#include <lib/smccc.h>
11#include <lib/utils_def.h>
12#include <tools_share/uuid.h>
13
14/* FFA error codes. */
15#define FFA_ERROR_NOT_SUPPORTED -1
16#define FFA_ERROR_INVALID_PARAMETER -2
17#define FFA_ERROR_NO_MEMORY -3
18#define FFA_ERROR_BUSY -4
19#define FFA_ERROR_INTERRUPTED -5
20#define FFA_ERROR_DENIED -6
21#define FFA_ERROR_RETRY -7
22
23/* The macros below are used to identify FFA calls from the SMC function ID */
24#define FFA_FNUM_MIN_VALUE U(0x60)
25#define FFA_FNUM_MAX_VALUE U(0x7f)
26#define is_ffa_fid(fid) __extension__ ({ \
27 __typeof__(fid) _fid = (fid); \
28 ((GET_SMC_NUM(_fid) >= FFA_FNUM_MIN_VALUE) && \
29 (GET_SMC_NUM(_fid) <= FFA_FNUM_MAX_VALUE)); })
30
31/* FFA_VERSION helpers */
32#define FFA_VERSION_MAJOR U(1)
33#define FFA_VERSION_MAJOR_SHIFT 16
34#define FFA_VERSION_MAJOR_MASK U(0x7FFF)
35#define FFA_VERSION_MINOR U(0)
36#define FFA_VERSION_MINOR_SHIFT 0
37#define FFA_VERSION_MINOR_MASK U(0xFFFF)
38
39#define MAKE_FFA_VERSION(major, minor) \
40 ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \
41 (((minor) & FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_SHIFT))
42#define FFA_VERSION_COMPILED MAKE_FFA_VERSION(FFA_VERSION_MAJOR, \
43 FFA_VERSION_MINOR)
44
45/* FFA_MSG_SEND helpers */
46#define FFA_MSG_SEND_ATTRS_BLK_SHIFT U(0)
47#define FFA_MSG_SEND_ATTRS_BLK_MASK U(0x1)
48#define FFA_MSG_SEND_ATTRS_BLK U(0)
49#define FFA_MSG_SEND_ATTRS_BLK_NOT U(1)
50#define FFA_MSG_SEND_ATTRS(blk) \
51 (((blk) & FFA_MSG_SEND_ATTRS_BLK_MASK) \
52 << FFA_MSG_SEND_ATTRS_BLK_SHIFT)
53
54/* Get FFA fastcall std FID from function number */
55#define FFA_FID(smc_cc, func_num) \
56 ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
57 ((smc_cc) << FUNCID_CC_SHIFT) | \
58 (OEN_STD_START << FUNCID_OEN_SHIFT) | \
59 ((func_num) << FUNCID_NUM_SHIFT))
60
61/* FFA function numbers */
62#define FFA_FNUM_ERROR U(0x60)
63#define FFA_FNUM_SUCCESS U(0x61)
64#define FFA_FNUM_INTERRUPT U(0x62)
65#define FFA_FNUM_VERSION U(0x63)
66#define FFA_FNUM_FEATURES U(0x64)
67#define FFA_FNUM_RX_RELEASE U(0x65)
68#define FFA_FNUM_RXTX_MAP U(0x66)
69#define FFA_FNUM_RXTX_UNMAP U(0x67)
70#define FFA_FNUM_PARTITION_INFO_GET U(0x68)
71#define FFA_FNUM_ID_GET U(0x69)
72#define FFA_FNUM_MSG_POLL U(0x6A)
73#define FFA_FNUM_MSG_WAIT U(0x6B)
74#define FFA_FNUM_MSG_YIELD U(0x6C)
75#define FFA_FNUM_MSG_RUN U(0x6D)
76#define FFA_FNUM_MSG_SEND U(0x6E)
77#define FFA_FNUM_MSG_SEND_DIRECT_REQ U(0x6F)
78#define FFA_FNUM_MSG_SEND_DIRECT_RESP U(0x70)
79#define FFA_FNUM_MEM_DONATE U(0x71)
80#define FFA_FNUM_MEM_LEND U(0x72)
81#define FFA_FNUM_MEM_SHARE U(0x73)
82#define FFA_FNUM_MEM_RETRIEVE_REQ U(0x74)
83#define FFA_FNUM_MEM_RETRIEVE_RESP U(0x75)
84#define FFA_FNUM_MEM_RELINQUISH U(0x76)
85#define FFA_FNUM_MEM_RECLAIM U(0x77)
86
87/* FFA SMC32 FIDs */
88#define FFA_ERROR FFA_FID(SMC_32, FFA_FNUM_ERROR)
89#define FFA_SUCCESS_SMC32 FFA_FID(SMC_32, FFA_FNUM_SUCCESS)
90#define FFA_INTERRUPT FFA_FID(SMC_32, FFA_FNUM_INTERRUPT)
91#define FFA_VERSION FFA_FID(SMC_32, FFA_FNUM_VERSION)
92#define FFA_FEATURES FFA_FID(SMC_32, FFA_FNUM_FEATURES)
93#define FFA_RX_RELEASE FFA_FID(SMC_32, FFA_FNUM_RX_RELEASE)
94#define FFA_RXTX_MAP_SMC32 FFA_FID(SMC_32, FFA_FNUM_RXTX_MAP)
95#define FFA_RXTX_UNMAP FFA_FID(SMC_32, FFA_FNUM_RXTX_UNMAP)
96#define FFA_PARTITION_INFO_GET FFA_FID(SMC_32, FFA_FNUM_PARTITION_INFO_GET)
97#define FFA_ID_GET FFA_FID(SMC_32, FFA_FNUM_ID_GET)
98#define FFA_MSG_POLL FFA_FID(SMC_32, FFA_FNUM_MSG_POLL)
99#define FFA_MSG_WAIT FFA_FID(SMC_32, FFA_FNUM_MSG_WAIT)
100#define FFA_MSG_YIELD FFA_FID(SMC_32, FFA_FNUM_MSG_YIELD)
101#define FFA_MSG_RUN FFA_FID(SMC_32, FFA_FNUM_MSG_RUN)
102#define FFA_MSG_SEND FFA_FID(SMC_32, FFA_FNUM_MSG_SEND)
103#define FFA_MSG_SEND_DIRECT_REQ_SMC32 \
104 FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_REQ)
105#define FFA_MSG_SEND_DIRECT_RESP_SMC32 \
106 FFA_FID(SMC_32, FFA_FNUM_MSG_SEND_DIRECT_RESP)
107#define FFA_MEM_DONATE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_DONATE)
108#define FFA_MEM_LEND_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_LEND)
109#define FFA_MEM_SHARE_SMC32 FFA_FID(SMC_32, FFA_FNUM_MEM_SHARE)
110#define FFA_MEM_RETRIEVE_REQ_SMC32 \
111 FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_REQ)
112#define FFA_MEM_RETRIEVE_RESP FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_RESP)
113#define FFA_MEM_RELINQUISH FFA_FID(SMC_32, FFA_FNUM_MEM_RELINQUISH)
114#define FFA_MEM_RECLAIM FFA_FID(SMC_32, FFA_FNUM_MEM_RECLAIM)
115
116/* FFA SMC64 FIDs */
117#define FFA_SUCCESS_SMC64 FFA_FID(SMC_64, FFA_FNUM_SUCCESS)
118#define FFA_RXTX_MAP_SMC64 FFA_FID(SMC_64, FFA_FNUM_RXTX_MAP)
119#define FFA_MSG_SEND_DIRECT_REQ_SMC64 \
120 FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_REQ)
121#define FFA_MSG_SEND_DIRECT_RESP_SMC64 \
122 FFA_FID(SMC_64, FFA_FNUM_MSG_SEND_DIRECT_RESP)
123#define FFA_MEM_DONATE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_DONATE)
124#define FFA_MEM_LEND_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_LEND)
125#define FFA_MEM_SHARE_SMC64 FFA_FID(SMC_64, FFA_FNUM_MEM_SHARE)
126#define FFA_MEM_RETRIEVE_REQ_SMC64 \
127 FFA_FID(SMC_64, FFA_FNUM_MEM_RETRIEVE_REQ)
128
129/*
130 * Reserve a special value for traffic targeted to the Hypervisor or SPM.
131 */
132#define FFA_TARGET_INFO_MBZ U(0x0)
133
134/*
135 * Reserve a special value for MBZ parameters.
136 */
137#define FFA_PARAM_MBZ U(0x0)
138
139#endif /* FFA_SVC_H */