Zephyr API Documentation 4.4.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
16
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
27
28#define IVSHMEM_V2_PROTO_UNDEFINED 0x0000
29#define IVSHMEM_V2_PROTO_NET 0x0001
30
31typedef size_t (*ivshmem_get_mem_f)(const struct device *dev,
32 uintptr_t *memmap);
33
34typedef uint32_t (*ivshmem_get_id_f)(const struct device *dev);
35
36typedef uint16_t (*ivshmem_get_vectors_f)(const struct device *dev);
37
38typedef int (*ivshmem_int_peer_f)(const struct device *dev,
39 uint32_t peer_id, uint16_t vector);
40
41typedef int (*ivshmem_register_handler_f)(const struct device *dev,
42 struct k_poll_signal *signal,
43 uint16_t vector);
44
45#ifdef CONFIG_IVSHMEM_V2
46
47typedef size_t (*ivshmem_get_rw_mem_section_f)(const struct device *dev,
48 uintptr_t *memmap);
49
50typedef size_t (*ivshmem_get_output_mem_section_f)(const struct device *dev,
51 uint32_t peer_id,
52 uintptr_t *memmap);
53
54typedef uint32_t (*ivshmem_get_state_f)(const struct device *dev,
55 uint32_t peer_id);
56
57typedef int (*ivshmem_set_state_f)(const struct device *dev,
59
60typedef uint32_t (*ivshmem_get_max_peers_f)(const struct device *dev);
61
62typedef uint16_t (*ivshmem_get_protocol_f)(const struct device *dev);
63
64typedef int (*ivshmem_enable_interrupts_f)(const struct device *dev,
65 bool enable);
66
67#endif /* CONFIG_IVSHMEM_V2 */
68
69__subsystem struct ivshmem_driver_api {
70 ivshmem_get_mem_f get_mem;
71 ivshmem_get_id_f get_id;
72 ivshmem_get_vectors_f get_vectors;
73 ivshmem_int_peer_f int_peer;
74 ivshmem_register_handler_f register_handler;
75#ifdef CONFIG_IVSHMEM_V2
76 ivshmem_get_rw_mem_section_f get_rw_mem_section;
77 ivshmem_get_output_mem_section_f get_output_mem_section;
78 ivshmem_get_state_f get_state;
79 ivshmem_set_state_f set_state;
80 ivshmem_get_max_peers_f get_max_peers;
81 ivshmem_get_protocol_f get_protocol;
82 ivshmem_enable_interrupts_f enable_interrupts;
83#endif
84};
85
87
102__syscall size_t ivshmem_get_mem(const struct device *dev,
103 uintptr_t *memmap);
104
105static inline size_t z_impl_ivshmem_get_mem(const struct device *dev,
106 uintptr_t *memmap)
107{
108 return DEVICE_API_GET(ivshmem, dev)->get_mem(dev, memmap);
109}
110
118__syscall uint32_t ivshmem_get_id(const struct device *dev);
119
120static inline uint32_t z_impl_ivshmem_get_id(const struct device *dev)
121{
122 return DEVICE_API_GET(ivshmem, dev)->get_id(dev);
123}
124
132__syscall uint16_t ivshmem_get_vectors(const struct device *dev);
133
134static inline uint16_t z_impl_ivshmem_get_vectors(const struct device *dev)
135{
136 return DEVICE_API_GET(ivshmem, dev)->get_vectors(dev);
137}
138
148__syscall int ivshmem_int_peer(const struct device *dev,
149 uint32_t peer_id, uint16_t vector);
150
151static inline int z_impl_ivshmem_int_peer(const struct device *dev,
152 uint32_t peer_id, uint16_t vector)
153{
154 return DEVICE_API_GET(ivshmem, dev)->int_peer(dev, peer_id, vector);
155}
156
172__syscall int ivshmem_register_handler(const struct device *dev,
173 struct k_poll_signal *signal,
174 uint16_t vector);
175
176static inline int z_impl_ivshmem_register_handler(const struct device *dev,
177 struct k_poll_signal *signal,
178 uint16_t vector)
179{
180 return DEVICE_API_GET(ivshmem, dev)->register_handler(dev, signal, vector);
181}
182
183#if defined(CONFIG_IVSHMEM_V2) || defined(__DOXYGEN__)
194__syscall size_t ivshmem_get_rw_mem_section(const struct device *dev,
195 uintptr_t *memmap);
196
197static inline size_t z_impl_ivshmem_get_rw_mem_section(const struct device *dev,
198 uintptr_t *memmap)
199{
200 return DEVICE_API_GET(ivshmem, dev)->get_rw_mem_section(dev, memmap);
201}
202
214__syscall size_t ivshmem_get_output_mem_section(const struct device *dev,
215 uint32_t peer_id,
216 uintptr_t *memmap);
217
218static inline size_t z_impl_ivshmem_get_output_mem_section(const struct device *dev,
219 uint32_t peer_id,
220 uintptr_t *memmap)
221{
222 return DEVICE_API_GET(ivshmem, dev)->get_output_mem_section(dev, peer_id, memmap);
223}
224
235__syscall uint32_t ivshmem_get_state(const struct device *dev,
236 uint32_t peer_id);
237
238static inline uint32_t z_impl_ivshmem_get_state(const struct device *dev,
239 uint32_t peer_id)
240{
241 return DEVICE_API_GET(ivshmem, dev)->get_state(dev, peer_id);
242}
243
254__syscall int ivshmem_set_state(const struct device *dev,
256
257static inline int z_impl_ivshmem_set_state(const struct device *dev,
259{
260 return DEVICE_API_GET(ivshmem, dev)->set_state(dev, state);
261}
262
272__syscall uint32_t ivshmem_get_max_peers(const struct device *dev);
273
274static inline uint32_t z_impl_ivshmem_get_max_peers(const struct device *dev)
275{
276 return DEVICE_API_GET(ivshmem, dev)->get_max_peers(dev);
277}
278
288__syscall uint16_t ivshmem_get_protocol(const struct device *dev);
289
290static inline uint16_t z_impl_ivshmem_get_protocol(const struct device *dev)
291{
292 return DEVICE_API_GET(ivshmem, dev)->get_protocol(dev);
293}
294
305__syscall int ivshmem_enable_interrupts(const struct device *dev,
306 bool enable);
307
308static inline int z_impl_ivshmem_enable_interrupts(const struct device *dev,
309 bool enable)
310{
311 return DEVICE_API_GET(ivshmem, dev)->enable_interrupts(dev, enable);
312}
313
314#endif /* CONFIG_IVSHMEM_V2 */
315
316#ifdef __cplusplus
317}
318#endif
319
323
324#include <zephyr/syscalls/ivshmem.h>
325
326#endif /* ZEPHYR_INCLUDE_DRIVERS_VIRTUALIZATION_IVSHMEM_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
int ivshmem_set_state(const struct device *dev, uint32_t state)
Set our state (ivshmem-v2 only).
size_t ivshmem_get_output_mem_section(const struct device *dev, uint32_t peer_id, uintptr_t *memmap)
Get the ivshmem output section for a peer (ivshmem-v2 only).
int ivshmem_enable_interrupts(const struct device *dev, bool enable)
Set the interrupt enablement for our VM (ivshmem-v2 only).
int ivshmem_register_handler(const struct device *dev, struct k_poll_signal *signal, uint16_t vector)
Register a vector notification (interrupt) handler.
size_t ivshmem_get_rw_mem_section(const struct device *dev, uintptr_t *memmap)
Get the ivshmem read/write section (ivshmem-v2 only).
uint16_t ivshmem_get_protocol(const struct device *dev)
Get the protocol used by this ivshmem instance (ivshmem-v2 only).
uint32_t ivshmem_get_state(const struct device *dev, uint32_t peer_id)
Get the state value of a peer (ivshmem-v2 only).
uint32_t ivshmem_get_max_peers(const struct device *dev)
Get the maximum number of peers supported (ivshmem-v2 only).
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.
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
sighandler_t signal(int sig, sighandler_t handler)
__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:513
Poll signal object.
Definition kernel.h:6821