Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ivshmem.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_VIRTUALIZATION_IVSHMEM_H_
8#define ZEPHYR_INCLUDE_DRIVERS_VIRTUALIZATION_IVSHMEM_H_
9
17#include <zephyr/types.h>
18#include <stddef.h>
19#include <zephyr/device.h>
20#include <zephyr/kernel.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define IVSHMEM_V2_PROTO_UNDEFINED 0x0000
27#define IVSHMEM_V2_PROTO_NET 0x0001
28
29typedef size_t (*ivshmem_get_mem_f)(const struct device *dev,
30 uintptr_t *memmap);
31
32typedef uint32_t (*ivshmem_get_id_f)(const struct device *dev);
33
34typedef uint16_t (*ivshmem_get_vectors_f)(const struct device *dev);
35
36typedef int (*ivshmem_int_peer_f)(const struct device *dev,
37 uint32_t peer_id, uint16_t vector);
38
39typedef int (*ivshmem_register_handler_f)(const struct device *dev,
40 struct k_poll_signal *signal,
41 uint16_t vector);
42
43#ifdef CONFIG_IVSHMEM_V2
44
45typedef size_t (*ivshmem_get_rw_mem_section_f)(const struct device *dev,
46 uintptr_t *memmap);
47
48typedef size_t (*ivshmem_get_output_mem_section_f)(const struct device *dev,
49 uint32_t peer_id,
50 uintptr_t *memmap);
51
52typedef uint32_t (*ivshmem_get_state_f)(const struct device *dev,
53 uint32_t peer_id);
54
55typedef int (*ivshmem_set_state_f)(const struct device *dev,
57
58typedef uint32_t (*ivshmem_get_max_peers_f)(const struct device *dev);
59
60typedef uint16_t (*ivshmem_get_protocol_f)(const struct device *dev);
61
62typedef int (*ivshmem_enable_interrupts_f)(const struct device *dev,
63 bool enable);
64
65#endif /* CONFIG_IVSHMEM_V2 */
66
67__subsystem struct ivshmem_driver_api {
73#ifdef CONFIG_IVSHMEM_V2
74 ivshmem_get_rw_mem_section_f get_rw_mem_section;
75 ivshmem_get_output_mem_section_f get_output_mem_section;
76 ivshmem_get_state_f get_state;
77 ivshmem_set_state_f set_state;
78 ivshmem_get_max_peers_f get_max_peers;
79 ivshmem_get_protocol_f get_protocol;
80 ivshmem_enable_interrupts_f enable_interrupts;
81#endif
82};
83
98__syscall size_t ivshmem_get_mem(const struct device *dev,
99 uintptr_t *memmap);
100
101static inline size_t z_impl_ivshmem_get_mem(const struct device *dev,
102 uintptr_t *memmap)
103{
104 const struct ivshmem_driver_api *api =
105 (const struct ivshmem_driver_api *)dev->api;
106
107 return api->get_mem(dev, memmap);
108}
109
117__syscall uint32_t ivshmem_get_id(const struct device *dev);
118
119static inline uint32_t z_impl_ivshmem_get_id(const struct device *dev)
120{
121 const struct ivshmem_driver_api *api =
122 (const struct ivshmem_driver_api *)dev->api;
123
124 return api->get_id(dev);
125}
126
134__syscall uint16_t ivshmem_get_vectors(const struct device *dev);
135
136static inline uint16_t z_impl_ivshmem_get_vectors(const struct device *dev)
137{
138 const struct ivshmem_driver_api *api =
139 (const struct ivshmem_driver_api *)dev->api;
140
141 return api->get_vectors(dev);
142}
143
153__syscall int ivshmem_int_peer(const struct device *dev,
154 uint32_t peer_id, uint16_t vector);
155
156static inline int z_impl_ivshmem_int_peer(const struct device *dev,
157 uint32_t peer_id, uint16_t vector)
158{
159 const struct ivshmem_driver_api *api =
160 (const struct ivshmem_driver_api *)dev->api;
161
162 return api->int_peer(dev, peer_id, vector);
163}
164
180__syscall int ivshmem_register_handler(const struct device *dev,
181 struct k_poll_signal *signal,
182 uint16_t vector);
183
184static inline int z_impl_ivshmem_register_handler(const struct device *dev,
185 struct k_poll_signal *signal,
186 uint16_t vector)
187{
188 const struct ivshmem_driver_api *api =
189 (const struct ivshmem_driver_api *)dev->api;
190
191 return api->register_handler(dev, signal, vector);
192}
193
194#ifdef CONFIG_IVSHMEM_V2
195
204__syscall size_t ivshmem_get_rw_mem_section(const struct device *dev,
205 uintptr_t *memmap);
206
207static inline size_t z_impl_ivshmem_get_rw_mem_section(const struct device *dev,
208 uintptr_t *memmap)
209{
210 const struct ivshmem_driver_api *api =
211 (const struct ivshmem_driver_api *)dev->api;
212
213 return api->get_rw_mem_section(dev, memmap);
214}
215
225__syscall size_t ivshmem_get_output_mem_section(const struct device *dev,
226 uint32_t peer_id,
227 uintptr_t *memmap);
228
229static inline size_t z_impl_ivshmem_get_output_mem_section(const struct device *dev,
230 uint32_t peer_id,
231 uintptr_t *memmap)
232{
233 const struct ivshmem_driver_api *api =
234 (const struct ivshmem_driver_api *)dev->api;
235
236 return api->get_output_mem_section(dev, peer_id, memmap);
237}
238
247__syscall uint32_t ivshmem_get_state(const struct device *dev,
248 uint32_t peer_id);
249
250static inline uint32_t z_impl_ivshmem_get_state(const struct device *dev,
251 uint32_t peer_id)
252{
253 const struct ivshmem_driver_api *api =
254 (const struct ivshmem_driver_api *)dev->api;
255
256 return api->get_state(dev, peer_id);
257}
258
267__syscall int ivshmem_set_state(const struct device *dev,
269
270static inline int z_impl_ivshmem_set_state(const struct device *dev,
272{
273 const struct ivshmem_driver_api *api =
274 (const struct ivshmem_driver_api *)dev->api;
275
276 return api->set_state(dev, state);
277}
278
286__syscall uint32_t ivshmem_get_max_peers(const struct device *dev);
287
288static inline uint32_t z_impl_ivshmem_get_max_peers(const struct device *dev)
289{
290 const struct ivshmem_driver_api *api =
291 (const struct ivshmem_driver_api *)dev->api;
292
293 return api->get_max_peers(dev);
294}
295
303__syscall uint16_t ivshmem_get_protocol(const struct device *dev);
304
305static inline uint16_t z_impl_ivshmem_get_protocol(const struct device *dev)
306{
307 const struct ivshmem_driver_api *api =
308 (const struct ivshmem_driver_api *)dev->api;
309
310 return api->get_protocol(dev);
311}
312
321__syscall int ivshmem_enable_interrupts(const struct device *dev,
322 bool enable);
323
324static inline int z_impl_ivshmem_enable_interrupts(const struct device *dev,
325 bool enable)
326{
327 const struct ivshmem_driver_api *api =
328 (const struct ivshmem_driver_api *)dev->api;
329
330 return api->enable_interrupts(dev, enable);
331}
332
333#endif /* CONFIG_IVSHMEM_V2 */
334
335#ifdef __cplusplus
336}
337#endif
338
343#include <syscalls/ivshmem.h>
344
345#endif /* ZEPHYR_INCLUDE_DRIVERS_VIRTUALIZATION_IVSHMEM_H_ */
int(* ivshmem_int_peer_f)(const struct device *dev, uint32_t peer_id, uint16_t vector)
Definition: ivshmem.h:36
uint16_t(* ivshmem_get_vectors_f)(const struct device *dev)
Definition: ivshmem.h:34
int(* ivshmem_register_handler_f)(const struct device *dev, struct k_poll_signal *signal, uint16_t vector)
Definition: ivshmem.h:39
int ivshmem_register_handler(const struct device *dev, struct k_poll_signal *signal, uint16_t vector)
Register a vector notification (interrupt) handler.
uint32_t(* ivshmem_get_id_f)(const struct device *dev)
Definition: ivshmem.h:32
uint32_t ivshmem_get_id(const struct device *dev)
Get our VM ID.
int ivshmem_int_peer(const struct device *dev, uint32_t peer_id, uint16_t vector)
Interrupt another VM.
size_t ivshmem_get_mem(const struct device *dev, uintptr_t *memmap)
Get the inter-VM shared memory.
size_t(* ivshmem_get_mem_f)(const struct device *dev, uintptr_t *memmap)
Definition: ivshmem.h:29
uint16_t ivshmem_get_vectors(const struct device *dev)
Get the number of interrupt vectors we can use.
Public kernel APIs.
state
Definition: parser_state.h:29
Size of off_t must be equal or less than size of size_t
Definition: retained_mem.h:28
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:399
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:405
Definition: ivshmem.h:67
ivshmem_register_handler_f register_handler
Definition: ivshmem.h:72
ivshmem_get_id_f get_id
Definition: ivshmem.h:69
ivshmem_int_peer_f int_peer
Definition: ivshmem.h:71
ivshmem_get_vectors_f get_vectors
Definition: ivshmem.h:70
ivshmem_get_mem_f get_mem
Definition: ivshmem.h:68
Definition: kernel.h:5641