blob: b82cf1e304657d06c5ed7b09ed5d08ac1a9487f4 [file] [log] [blame]
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +00001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SPCI_SVC_H
8#define SPCI_SVC_H
9
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/smccc.h>
11#include <lib/utils_def.h>
Antonio Nino Diazf939a6a2018-11-08 14:12:40 +000012
13/* SPCI_VERSION helpers */
14
15#define SPCI_VERSION_MAJOR U(0)
16#define SPCI_VERSION_MAJOR_SHIFT 16
17#define SPCI_VERSION_MAJOR_MASK U(0x7FFF)
18#define SPCI_VERSION_MINOR U(1)
19#define SPCI_VERSION_MINOR_SHIFT 0
20#define SPCI_VERSION_MINOR_MASK U(0xFFFF)
21#define SPCI_VERSION_FORM(major, minor) ((((major) & SPCI_VERSION_MAJOR_MASK) \
22 << SPCI_VERSION_MAJOR_SHIFT) | \
23 ((minor) & SPCI_VERSION_MINOR_MASK))
24#define SPCI_VERSION_COMPILED SPCI_VERSION_FORM(SPCI_VERSION_MAJOR, \
25 SPCI_VERSION_MINOR)
26
27/* Definitions to build the complete SMC ID */
28
29#define SPCI_FID_MISC_FLAG (U(0) << 27)
30#define SPCI_FID_MISC_SHIFT U(20)
31#define SPCI_FID_MISC_MASK U(0x7F)
32
33#define SPCI_FID_TUN_FLAG (U(1) << 27)
34#define SPCI_FID_TUN_SHIFT U(24)
35#define SPCI_FID_TUN_MASK U(0x7)
36
37#define SPCI_SMC(spci_fid) ((FUNCID_NAMESPACE_SPCI << FUNCID_NAMESPACE_SHIFT) | \
38 (U(1) << 31) | (spci_fid))
39#define SPCI_MISC_32(misc_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \
40 SPCI_FID_MISC_FLAG | \
41 SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT))
42#define SPCI_MISC_64(misc_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \
43 SPCI_FID_MISC_FLAG | \
44 SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT))
45#define SPCI_TUN_32(tun_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \
46 SPCI_FID_TUN_FLAG | \
47 SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT))
48#define SPCI_TUN_64(tun_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \
49 SPCI_FID_TUN_FLAG | \
50 SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT))
51
52/* SPCI miscellaneous functions */
53
54#define SPCI_FID_VERSION U(0x0)
55#define SPCI_FID_SERVICE_HANDLE_OPEN U(0x2)
56#define SPCI_FID_SERVICE_HANDLE_CLOSE U(0x3)
57#define SPCI_FID_SERVICE_MEM_REGISTER U(0x4)
58#define SPCI_FID_SERVICE_MEM_UNREGISTER U(0x5)
59#define SPCI_FID_SERVICE_MEM_PUBLISH U(0x6)
60#define SPCI_FID_SERVICE_REQUEST_BLOCKING U(0x7)
61#define SPCI_FID_SERVICE_REQUEST_START U(0x8)
62#define SPCI_FID_SERVICE_GET_RESPONSE U(0x9)
63#define SPCI_FID_SERVICE_RESET_CLIENT_STATE U(0xA)
64
65/* SPCI tunneling functions */
66
67#define SPCI_FID_SERVICE_TUN_REQUEST_START U(0x0)
68#define SPCI_FID_SERVICE_REQUEST_RESUME U(0x1)
69#define SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING U(0x2)
70
71/* Complete SMC IDs and associated values */
72
73#define SPCI_VERSION SPCI_MISC_32(SPCI_FID_VERSION)
74
75#define SPCI_SERVICE_HANDLE_OPEN SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_OPEN)
76#define SPCI_SERVICE_HANDLE_OPEN_NOTIFY_BIT U(1)
77
78#define SPCI_SERVICE_HANDLE_CLOSE SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_CLOSE)
79
80#define SPCI_SERVICE_MEM_REGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_REGISTER)
81#define SPCI_SERVICE_MEM_REGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_REGISTER)
82
83#define SPCI_SERVICE_MEM_UNREGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_UNREGISTER)
84#define SPCI_SERVICE_MEM_UNREGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_UNREGISTER)
85
86#define SPCI_SERVICE_MEM_PUBLISH_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_PUBLISH)
87#define SPCI_SERVICE_MEM_PUBLISH_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_PUBLISH)
88
89#define SPCI_SERVICE_REQUEST_BLOCKING_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_BLOCKING)
90#define SPCI_SERVICE_REQUEST_BLOCKING_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_BLOCKING)
91
92#define SPCI_SERVICE_REQUEST_START_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_START)
93#define SPCI_SERVICE_REQUEST_START_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_START)
94
95#define SPCI_SERVICE_GET_RESPONSE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_GET_RESPONSE)
96#define SPCI_SERVICE_GET_RESPONSE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_GET_RESPONSE)
97
98#define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_RESET_CLIENT_STATE)
99#define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_RESET_CLIENT_STATE)
100
101#define SPCI_SERVICE_TUN_REQUEST_START_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_START)
102#define SPCI_SERVICE_TUN_REQUEST_START_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_START)
103
104#define SPCI_SERVICE_REQUEST_RESUME_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_REQUEST_RESUME)
105#define SPCI_SERVICE_REQUEST_RESUME_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_REQUEST_RESUME)
106
107#define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING)
108#define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING)
109
110/* SPCI error codes. */
111
112#define SPCI_SUCCESS 0
113#define SPCI_NOT_SUPPORTED -1
114#define SPCI_INVALID_PARAMETER -2
115#define SPCI_NO_MEMORY -3
116#define SPCI_BUSY -4
117#define SPCI_QUEUED -5
118#define SPCI_DENIED -6
119#define SPCI_NOT_PRESENT -7
120
121#endif /* SPCI_SVC_H */