Zephyr Project API 3.7.0
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
16#define DEV_API(dev) ((struct svc_driver_api *)(dev)->api)
17
22#define SVC_CONDUIT_NAME_LENGTH (4)
23
28typedef void (*sip_supervisory_call_t)(const struct device *dev, unsigned long function_id,
29 unsigned long arg0, unsigned long arg1, unsigned long arg2,
30 unsigned long arg3, unsigned long arg4, unsigned long arg5,
31 unsigned long arg6, struct arm_smccc_res *res);
32
37typedef bool (*sip_svc_plat_func_id_valid_t)(const struct device *dev, uint32_t command,
38 uint32_t func_id);
39
44typedef uint32_t (*sip_svc_plat_format_trans_id_t)(const struct device *dev, uint32_t client_idx,
45 uint32_t trans_idx);
46
51typedef uint32_t (*sip_svc_plat_get_trans_idx_t)(const struct device *dev, uint32_t trans_id);
52
57typedef void (*sip_svc_plat_update_trans_id_t)(const struct device *dev,
58 struct sip_svc_request *request, uint32_t trans_id);
59
64typedef void (*sip_svc_plat_free_async_memory_t)(const struct device *dev,
65 struct sip_svc_request *request);
66
71typedef int (*sip_svc_plat_async_res_req_t)(const struct device *dev, unsigned long *a0,
72 unsigned long *a1, unsigned long *a2, unsigned long *a3,
73 unsigned long *a4, unsigned long *a5, unsigned long *a6,
74 unsigned long *a7, char *buf, size_t size);
75
80typedef int (*sip_svc_plat_async_res_res_t)(const struct device *dev, struct arm_smccc_res *res,
81 char *buf, size_t *size, uint32_t *trans_id);
82
87typedef uint32_t (*sip_svc_plat_get_error_code_t)(const struct device *dev,
88 struct arm_smccc_res *res);
89
105
120__syscall void sip_supervisory_call(const struct device *dev, unsigned long function_id,
121 unsigned long arg0, unsigned long arg1, unsigned long arg2,
122 unsigned long arg3, unsigned long arg4, unsigned long arg5,
123 unsigned long arg6, struct arm_smccc_res *res);
124static inline void z_impl_sip_supervisory_call(const struct device *dev, unsigned long function_id,
125 unsigned long arg0, unsigned long arg1,
126 unsigned long arg2, unsigned long arg3,
127 unsigned long arg4, unsigned long arg5,
128 unsigned long arg6, struct arm_smccc_res *res)
129{
130 __ASSERT(dev, "dev shouldn't be NULL");
131 const struct svc_driver_api *api = DEV_API(dev);
132
133 __ASSERT(api->sip_supervisory_call, "sip_supervisory_call shouldn't be NULL");
134 __ASSERT(res, "response pointer shouldn't be NULL");
135
136 api->sip_supervisory_call(dev, function_id, arg0, arg1, arg2, arg3, arg4, arg5, arg6, res);
137}
138
149__syscall bool sip_svc_plat_func_id_valid(const struct device *dev, uint32_t command,
150 uint32_t func_id);
151static inline bool z_impl_sip_svc_plat_func_id_valid(const struct device *dev, uint32_t command,
152 uint32_t func_id)
153{
154 __ASSERT(dev, "dev shouldn't be NULL");
155 const struct svc_driver_api *api = DEV_API(dev);
156
157 __ASSERT(api->sip_svc_plat_func_id_valid,
158 "sip_svc_plat_func_id_valid func shouldn't be NULL");
159
160 return api->sip_svc_plat_func_id_valid(dev, command, func_id);
161}
162
172__syscall uint32_t sip_svc_plat_format_trans_id(const struct device *dev, uint32_t client_idx,
173 uint32_t trans_idx);
174static inline uint32_t z_impl_sip_svc_plat_format_trans_id(const struct device *dev,
175 uint32_t client_idx, uint32_t trans_idx)
176{
177 __ASSERT(dev, "dev shouldn't be NULL");
178 const struct svc_driver_api *api = DEV_API(dev);
179
180 __ASSERT(api->sip_svc_plat_format_trans_id,
181 "sip_svc_plat_format_trans_id func shouldn't be NULL");
182
183 return api->sip_svc_plat_format_trans_id(dev, client_idx, trans_idx);
184}
185
194__syscall uint32_t sip_svc_plat_get_trans_idx(const struct device *dev, uint32_t trans_id);
195static inline uint32_t z_impl_sip_svc_plat_get_trans_idx(const struct device *dev,
196 uint32_t trans_id)
197{
198 __ASSERT(dev, "dev shouldn't be NULL");
199 const struct svc_driver_api *api = DEV_API(dev);
200
201 __ASSERT(api->sip_svc_plat_get_trans_idx,
202 "sip_svc_plat_get_trans_idx func shouldn't be NULL");
203
204 return api->sip_svc_plat_get_trans_idx(dev, trans_id);
205}
206
214__syscall void sip_svc_plat_update_trans_id(const struct device *dev,
215 struct sip_svc_request *request, uint32_t trans_id);
216static inline void z_impl_sip_svc_plat_update_trans_id(const struct device *dev,
217 struct sip_svc_request *request,
218 uint32_t trans_id)
219{
220 __ASSERT(dev, "dev shouldn't be NULL");
221 const struct svc_driver_api *api = DEV_API(dev);
222
223 __ASSERT(api->sip_svc_plat_update_trans_id,
224 "sip_svc_plat_update_trans_id func shouldn't be NULL");
225 __ASSERT(request, "request shouldn't be NULL");
226
227 return api->sip_svc_plat_update_trans_id(dev, request, trans_id);
228}
229
239__syscall uint32_t sip_svc_plat_get_error_code(const struct device *dev, struct arm_smccc_res *res);
240static inline uint32_t z_impl_sip_svc_plat_get_error_code(const struct device *dev,
241 struct arm_smccc_res *res)
242{
243 __ASSERT(dev, "dev shouldn't be NULL");
244 const struct svc_driver_api *api = DEV_API(dev);
245
246 __ASSERT(api->sip_svc_plat_get_error_code,
247 "sip_svc_plat_get_error_code func shouldn't be NULL");
248 __ASSERT(res, "res shouldn't be NULL");
249
250 return api->sip_svc_plat_get_error_code(dev, res);
251}
252
270__syscall int sip_svc_plat_async_res_req(const struct device *dev, unsigned long *a0,
271 unsigned long *a1, unsigned long *a2, unsigned long *a3,
272 unsigned long *a4, unsigned long *a5, unsigned long *a6,
273 unsigned long *a7, char *buf, size_t size);
274static inline int z_impl_sip_svc_plat_async_res_req(const struct device *dev, unsigned long *a0,
275 unsigned long *a1, unsigned long *a2,
276 unsigned long *a3, unsigned long *a4,
277 unsigned long *a5, unsigned long *a6,
278 unsigned long *a7, char *buf, size_t size)
279{
280 __ASSERT(dev, "dev shouldn't be NULL");
281 const struct svc_driver_api *api = DEV_API(dev);
282
283 __ASSERT(api->sip_svc_plat_async_res_req,
284 "sip_svc_plat_async_res_req func shouldn't be NULL");
285 __ASSERT(a0, "a0 shouldn't be NULL");
286 __ASSERT(a1, "a1 shouldn't be NULL");
287 __ASSERT(a2, "a2 shouldn't be NULL");
288 __ASSERT(a3, "a3 shouldn't be NULL");
289 __ASSERT(a4, "a4 shouldn't be NULL");
290 __ASSERT(a5, "a5 shouldn't be NULL");
291 __ASSERT(a6, "a6 shouldn't be NULL");
292 __ASSERT(a7, "a7 shouldn't be NULL");
293 __ASSERT(((buf == NULL && size == 0) || (buf != NULL && size != 0)),
294 "buf and size should represent a buffer");
295 return api->sip_svc_plat_async_res_req(dev, a0, a1, a2, a3, a4, a5, a6, a7, buf, size);
296}
297
311__syscall int sip_svc_plat_async_res_res(const struct device *dev, struct arm_smccc_res *res,
312 char *buf, size_t *size, uint32_t *trans_id);
313static inline int z_impl_sip_svc_plat_async_res_res(const struct device *dev,
314 struct arm_smccc_res *res, char *buf,
315 size_t *size, uint32_t *trans_id)
316{
317 __ASSERT(dev, "dev shouldn't be NULL");
318 const struct svc_driver_api *api = DEV_API(dev);
319
320 __ASSERT(api->sip_svc_plat_async_res_res,
321 "sip_svc_plat_async_res_res func shouldn't be NULL");
322 __ASSERT(res, "res shouldn't be NULL");
323 __ASSERT(buf, "buf shouldn't be NULL");
324 __ASSERT(size, "size shouldn't be NULL");
325 __ASSERT(trans_id, "buf shouldn't be NULL");
326
327 return api->sip_svc_plat_async_res_res(dev, res, buf, size, trans_id);
328}
329
336__syscall void sip_svc_plat_free_async_memory(const struct device *dev,
337 struct sip_svc_request *request);
338static inline void z_impl_sip_svc_plat_free_async_memory(const struct device *dev,
339 struct sip_svc_request *request)
340{
341 __ASSERT(dev, "dev shouldn't be NULL");
342 const struct svc_driver_api *api = DEV_API(dev);
343
344 __ASSERT(api->sip_svc_plat_free_async_memory,
345 "sip_svc_plat_free_async_memory func shouldn't be NULL");
346 __ASSERT(request, "request shouldn't be NULL");
347
348 api->sip_svc_plat_free_async_memory(dev, request);
349}
350
351
352#include <zephyr/syscalls/sip_svc_driver.h>
353
354#endif /* ZEPHYR_INCLUDE_SIP_SVC_DRIVER_H_ */
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:28
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:51
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:44
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:80
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:87
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:57
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:71
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:64
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:37
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.
#define DEV_API(dev)
Definition sip_svc_driver.h:16
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:403
SiP Service communication protocol request format.
Definition sip_svc_proto.h:133
API structure for sip_svc driver.
Definition sip_svc_driver.h:94
sip_svc_plat_update_trans_id_t sip_svc_plat_update_trans_id
Definition sip_svc_driver.h:99
sip_svc_plat_async_res_res_t sip_svc_plat_async_res_res
Definition sip_svc_driver.h:102
sip_svc_plat_get_trans_idx_t sip_svc_plat_get_trans_idx
Definition sip_svc_driver.h:98
sip_svc_plat_free_async_memory_t sip_svc_plat_free_async_memory
Definition sip_svc_driver.h:100
sip_supervisory_call_t sip_supervisory_call
Definition sip_svc_driver.h:95
sip_svc_plat_format_trans_id_t sip_svc_plat_format_trans_id
Definition sip_svc_driver.h:97
sip_svc_plat_async_res_req_t sip_svc_plat_async_res_req
Definition sip_svc_driver.h:101
sip_svc_plat_func_id_valid_t sip_svc_plat_func_id_valid
Definition sip_svc_driver.h:96
sip_svc_plat_get_error_code_t sip_svc_plat_get_error_code
Definition sip_svc_driver.h:103