Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sip_svc_driver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SIP_SVC_DRIVER_H_
8#define ZEPHYR_INCLUDE_SIP_SVC_DRIVER_H_
9
10#include <zephyr/device.h>
11#include <zephyr/kernel.h>
15
20#define SVC_CONDUIT_NAME_LENGTH (4)
21
26typedef void (*sip_supervisory_call_t)(const struct device *dev, unsigned long function_id,
27 unsigned long arg0, unsigned long arg1, unsigned long arg2,
28 unsigned long arg3, unsigned long arg4, unsigned long arg5,
29 unsigned long arg6, struct arm_smccc_res *res);
30
35typedef bool (*sip_svc_plat_func_id_valid_t)(const struct device *dev, uint32_t command,
36 uint32_t func_id);
37
42typedef uint32_t (*sip_svc_plat_format_trans_id_t)(const struct device *dev, uint32_t client_idx,
43 uint32_t trans_idx);
44
49typedef uint32_t (*sip_svc_plat_get_trans_idx_t)(const struct device *dev, uint32_t trans_id);
50
55typedef void (*sip_svc_plat_update_trans_id_t)(const struct device *dev,
56 struct sip_svc_request *request, uint32_t trans_id);
57
62typedef void (*sip_svc_plat_free_async_memory_t)(const struct device *dev,
63 struct sip_svc_request *request);
64
69typedef int (*sip_svc_plat_async_res_req_t)(const struct device *dev, unsigned long *a0,
70 unsigned long *a1, unsigned long *a2, unsigned long *a3,
71 unsigned long *a4, unsigned long *a5, unsigned long *a6,
72 unsigned long *a7, char *buf, size_t size);
73
78typedef int (*sip_svc_plat_async_res_res_t)(const struct device *dev, struct arm_smccc_res *res,
79 char *buf, size_t *size, uint32_t *trans_id);
80
85typedef uint32_t (*sip_svc_plat_get_error_code_t)(const struct device *dev,
86 struct arm_smccc_res *res);
87
103
118__syscall void sip_supervisory_call(const struct device *dev, unsigned long function_id,
119 unsigned long arg0, unsigned long arg1, unsigned long arg2,
120 unsigned long arg3, unsigned long arg4, unsigned long arg5,
121 unsigned long arg6, struct arm_smccc_res *res);
122static inline void z_impl_sip_supervisory_call(const struct device *dev, unsigned long function_id,
123 unsigned long arg0, unsigned long arg1,
124 unsigned long arg2, unsigned long arg3,
125 unsigned long arg4, unsigned long arg5,
126 unsigned long arg6, struct arm_smccc_res *res)
127{
128 __ASSERT(dev, "dev shouldn't be NULL");
129 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
130
131 __ASSERT(api->sip_supervisory_call, "sip_supervisory_call shouldn't be NULL");
132 __ASSERT(res, "response pointer shouldn't be NULL");
133
134 api->sip_supervisory_call(dev, function_id, arg0, arg1, arg2, arg3, arg4, arg5, arg6, res);
135}
136
147__syscall bool sip_svc_plat_func_id_valid(const struct device *dev, uint32_t command,
148 uint32_t func_id);
149static inline bool z_impl_sip_svc_plat_func_id_valid(const struct device *dev, uint32_t command,
150 uint32_t func_id)
151{
152 __ASSERT(dev, "dev shouldn't be NULL");
153 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
154
155 __ASSERT(api->sip_svc_plat_func_id_valid,
156 "sip_svc_plat_func_id_valid func shouldn't be NULL");
157
158 return api->sip_svc_plat_func_id_valid(dev, command, func_id);
159}
160
170__syscall uint32_t sip_svc_plat_format_trans_id(const struct device *dev, uint32_t client_idx,
171 uint32_t trans_idx);
172static inline uint32_t z_impl_sip_svc_plat_format_trans_id(const struct device *dev,
173 uint32_t client_idx, uint32_t trans_idx)
174{
175 __ASSERT(dev, "dev shouldn't be NULL");
176 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
177
178 __ASSERT(api->sip_svc_plat_format_trans_id,
179 "sip_svc_plat_format_trans_id func shouldn't be NULL");
180
181 return api->sip_svc_plat_format_trans_id(dev, client_idx, trans_idx);
182}
183
192__syscall uint32_t sip_svc_plat_get_trans_idx(const struct device *dev, uint32_t trans_id);
193static inline uint32_t z_impl_sip_svc_plat_get_trans_idx(const struct device *dev,
194 uint32_t trans_id)
195{
196 __ASSERT(dev, "dev shouldn't be NULL");
197 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
198
199 __ASSERT(api->sip_svc_plat_get_trans_idx,
200 "sip_svc_plat_get_trans_idx func shouldn't be NULL");
201
202 return api->sip_svc_plat_get_trans_idx(dev, trans_id);
203}
204
212__syscall void sip_svc_plat_update_trans_id(const struct device *dev,
213 struct sip_svc_request *request, uint32_t trans_id);
214static inline void z_impl_sip_svc_plat_update_trans_id(const struct device *dev,
215 struct sip_svc_request *request,
216 uint32_t trans_id)
217{
218 __ASSERT(dev, "dev shouldn't be NULL");
219 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
220
221 __ASSERT(api->sip_svc_plat_update_trans_id,
222 "sip_svc_plat_update_trans_id func shouldn't be NULL");
223 __ASSERT(request, "request shouldn't be NULL");
224
225 api->sip_svc_plat_update_trans_id(dev, request, trans_id);
226}
227
237__syscall uint32_t sip_svc_plat_get_error_code(const struct device *dev, struct arm_smccc_res *res);
238static inline uint32_t z_impl_sip_svc_plat_get_error_code(const struct device *dev,
239 struct arm_smccc_res *res)
240{
241 __ASSERT(dev, "dev shouldn't be NULL");
242 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
243
244 __ASSERT(api->sip_svc_plat_get_error_code,
245 "sip_svc_plat_get_error_code func shouldn't be NULL");
246 __ASSERT(res, "res shouldn't be NULL");
247
248 return api->sip_svc_plat_get_error_code(dev, res);
249}
250
268__syscall int sip_svc_plat_async_res_req(const struct device *dev, unsigned long *a0,
269 unsigned long *a1, unsigned long *a2, unsigned long *a3,
270 unsigned long *a4, unsigned long *a5, unsigned long *a6,
271 unsigned long *a7, char *buf, size_t size);
272static inline int z_impl_sip_svc_plat_async_res_req(const struct device *dev, unsigned long *a0,
273 unsigned long *a1, unsigned long *a2,
274 unsigned long *a3, unsigned long *a4,
275 unsigned long *a5, unsigned long *a6,
276 unsigned long *a7, char *buf, size_t size)
277{
278 __ASSERT(dev, "dev shouldn't be NULL");
279 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
280
281 __ASSERT(api->sip_svc_plat_async_res_req,
282 "sip_svc_plat_async_res_req func shouldn't be NULL");
283 __ASSERT(a0, "a0 shouldn't be NULL");
284 __ASSERT(a1, "a1 shouldn't be NULL");
285 __ASSERT(a2, "a2 shouldn't be NULL");
286 __ASSERT(a3, "a3 shouldn't be NULL");
287 __ASSERT(a4, "a4 shouldn't be NULL");
288 __ASSERT(a5, "a5 shouldn't be NULL");
289 __ASSERT(a6, "a6 shouldn't be NULL");
290 __ASSERT(a7, "a7 shouldn't be NULL");
291 __ASSERT(((buf == NULL && size == 0) || (buf != NULL && size != 0)),
292 "buf and size should represent a buffer");
293 return api->sip_svc_plat_async_res_req(dev, a0, a1, a2, a3, a4, a5, a6, a7, buf, size);
294}
295
309__syscall int sip_svc_plat_async_res_res(const struct device *dev, struct arm_smccc_res *res,
310 char *buf, size_t *size, uint32_t *trans_id);
311static inline int z_impl_sip_svc_plat_async_res_res(const struct device *dev,
312 struct arm_smccc_res *res, char *buf,
313 size_t *size, uint32_t *trans_id)
314{
315 __ASSERT(dev, "dev shouldn't be NULL");
316 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
317
318 __ASSERT(api->sip_svc_plat_async_res_res,
319 "sip_svc_plat_async_res_res func shouldn't be NULL");
320 __ASSERT(res, "res shouldn't be NULL");
321 __ASSERT(buf, "buf shouldn't be NULL");
322 __ASSERT(size, "size shouldn't be NULL");
323 __ASSERT(trans_id, "buf shouldn't be NULL");
324
325 return api->sip_svc_plat_async_res_res(dev, res, buf, size, trans_id);
326}
327
334__syscall void sip_svc_plat_free_async_memory(const struct device *dev,
335 struct sip_svc_request *request);
336static inline void z_impl_sip_svc_plat_free_async_memory(const struct device *dev,
337 struct sip_svc_request *request)
338{
339 __ASSERT(dev, "dev shouldn't be NULL");
340 const struct svc_driver_api *api = DEVICE_API_GET(svc, dev);
341
342 __ASSERT(api->sip_svc_plat_free_async_memory,
343 "sip_svc_plat_free_async_memory func shouldn't be NULL");
344 __ASSERT(request, "request shouldn't be NULL");
345
346 api->sip_svc_plat_free_async_memory(dev, request);
347}
348
349
350#include <zephyr/syscalls/sip_svc_driver.h>
351
352#endif /* ZEPHYR_INCLUDE_SIP_SVC_DRIVER_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
#define NULL
Definition iar_missing_defs.h:20
Public kernel APIs.
void sip_svc_plat_update_trans_id(const struct device *dev, struct sip_svc_request *request, uint32_t trans_id)
Update transaction id for sip_svc_request for lower layer.
int sip_svc_plat_async_res_res(const struct device *dev, struct arm_smccc_res *res, char *buf, size_t *size, uint32_t *trans_id)
Check the response of polling supervisory call and retrieve the response size and transaction id.
void(* sip_supervisory_call_t)(const struct device *dev, unsigned long function_id, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6, struct arm_smccc_res *res)
Callback API for executing the supervisory call See sip_supervisory_call() for argument description.
Definition sip_svc_driver.h:26
uint32_t sip_svc_plat_get_error_code(const struct device *dev, struct arm_smccc_res *res)
Retrieve the error code from arm_smccc_res response.
uint32_t(* sip_svc_plat_get_trans_idx_t)(const struct device *dev, uint32_t trans_id)
Callback API for retrieving client transaction id from transaction id See sip_svc_plat_get_trans_idx(...
Definition sip_svc_driver.h:49
uint32_t(* sip_svc_plat_format_trans_id_t)(const struct device *dev, uint32_t client_idx, uint32_t trans_idx)
Callback API for generating the transaction id from client id.
Definition sip_svc_driver.h:42
int(* sip_svc_plat_async_res_res_t)(const struct device *dev, struct arm_smccc_res *res, char *buf, size_t *size, uint32_t *trans_id)
Callback API to check the response of polling request See sip_svc_plat_async_res_res() for argument d...
Definition sip_svc_driver.h:78
void sip_supervisory_call(const struct device *dev, unsigned long function_id, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6, struct arm_smccc_res *res)
supervisory call function which will execute the smc/hvc call
bool sip_svc_plat_func_id_valid(const struct device *dev, uint32_t command, uint32_t func_id)
Validate the function id for the supervisory call.
uint32_t(* sip_svc_plat_get_error_code_t)(const struct device *dev, struct arm_smccc_res *res)
Callback API for retrieving error code from a supervisory call response.
Definition sip_svc_driver.h:85
void(* sip_svc_plat_update_trans_id_t)(const struct device *dev, struct sip_svc_request *request, uint32_t trans_id)
Callback API for updating transaction id for request packet for lower layer See sip_svc_plat_update_t...
Definition sip_svc_driver.h:55
int(* sip_svc_plat_async_res_req_t)(const struct device *dev, unsigned long *a0, unsigned long *a1, unsigned long *a2, unsigned long *a3, unsigned long *a4, unsigned long *a5, unsigned long *a6, unsigned long *a7, char *buf, size_t size)
Callback API to construct Polling packet for ASYNC transaction.
Definition sip_svc_driver.h:69
void sip_svc_plat_free_async_memory(const struct device *dev, struct sip_svc_request *request)
Free the command buffer used for ASYNC packet after sending it to lower layers.
void(* sip_svc_plat_free_async_memory_t)(const struct device *dev, struct sip_svc_request *request)
Callback API for freeing command buffer in ASYNC packets See sip_svc_plat_free_async_memory() for arg...
Definition sip_svc_driver.h:62
int sip_svc_plat_async_res_req(const struct device *dev, unsigned long *a0, unsigned long *a1, unsigned long *a2, unsigned long *a3, unsigned long *a4, unsigned long *a5, unsigned long *a6, unsigned long *a7, char *buf, size_t size)
Set arguments for polling supervisory call.
bool(* sip_svc_plat_func_id_valid_t)(const struct device *dev, uint32_t command, uint32_t func_id)
Callback API for validating function id for the supervisory call.
Definition sip_svc_driver.h:35
uint32_t sip_svc_plat_get_trans_idx(const struct device *dev, uint32_t trans_id)
Retrieve client transaction id from packet transaction id.
uint32_t sip_svc_plat_format_trans_id(const struct device *dev, uint32_t client_idx, uint32_t trans_idx)
Formats and generates the transaction id from client id.
Arm SiP services communication protocol between service provider and client.
#define bool
Definition stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Definition arm-smccc.h:14
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
SiP Service communication protocol request format.
Definition sip_svc_proto.h:133
API structure for sip_svc driver.
Definition sip_svc_driver.h:92
sip_svc_plat_update_trans_id_t sip_svc_plat_update_trans_id
Definition sip_svc_driver.h:97
sip_svc_plat_async_res_res_t sip_svc_plat_async_res_res
Definition sip_svc_driver.h:100
sip_svc_plat_get_trans_idx_t sip_svc_plat_get_trans_idx
Definition sip_svc_driver.h:96
sip_svc_plat_free_async_memory_t sip_svc_plat_free_async_memory
Definition sip_svc_driver.h:98
sip_supervisory_call_t sip_supervisory_call
Definition sip_svc_driver.h:93
sip_svc_plat_format_trans_id_t sip_svc_plat_format_trans_id
Definition sip_svc_driver.h:95
sip_svc_plat_async_res_req_t sip_svc_plat_async_res_req
Definition sip_svc_driver.h:99
sip_svc_plat_func_id_valid_t sip_svc_plat_func_id_valid
Definition sip_svc_driver.h:94
sip_svc_plat_get_error_code_t sip_svc_plat_get_error_code
Definition sip_svc_driver.h:101