1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/drivers/virtualization/ivshmem.h>
8 #include <zephyr/syscall_handler.h>
9 #include <string.h>
10 
z_vrfy_ivshmem_get_mem(const struct device * dev,uintptr_t * memmap)11 static inline size_t z_vrfy_ivshmem_get_mem(const struct device *dev,
12 					    uintptr_t *memmap)
13 {
14 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_mem));
15 	Z_OOPS(Z_SYSCALL_MEMORY_WRITE(memmap, sizeof(uintptr_t)));
16 
17 	return z_impl_ivshmem_get_mem(dev, memmap);
18 }
19 #include <syscalls/ivshmem_get_mem_mrsh.c>
20 
z_vrfy_ivshmem_get_id(const struct device * dev)21 static inline uint32_t z_vrfy_ivshmem_get_id(const struct device *dev)
22 {
23 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_id));
24 
25 	return z_impl_ivshmem_get_id(dev);
26 }
27 #include <syscalls/ivshmem_get_id_mrsh.c>
28 
z_vrfy_ivshmem_get_vectors(const struct device * dev)29 static inline uint16_t z_vrfy_ivshmem_get_vectors(const struct device *dev)
30 {
31 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_vectors));
32 
33 	return z_impl_ivshmem_get_vectors(dev);
34 }
35 #include <syscalls/ivshmem_get_vectors_mrsh.c>
36 
z_vrfy_ivshmem_int_peer(const struct device * dev,uint32_t peer_id,uint16_t vector)37 static inline int z_vrfy_ivshmem_int_peer(const struct device *dev,
38 					  uint32_t peer_id, uint16_t vector)
39 {
40 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, int_peer));
41 
42 	return z_impl_ivshmem_int_peer(dev, peer_id, vector);
43 }
44 #include <syscalls/ivshmem_int_peer_mrsh.c>
45 
z_vrfy_ivshmem_register_handler(const struct device * dev,struct k_poll_signal * signal,uint16_t vector)46 static inline int z_vrfy_ivshmem_register_handler(const struct device *dev,
47 						  struct k_poll_signal *signal,
48 						  uint16_t vector)
49 {
50 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, register_handler));
51 	Z_OOPS(Z_SYSCALL_OBJ(signal, K_OBJ_POLL_SIGNAL));
52 
53 	return z_impl_ivshmem_register_handler(dev, signal, vector);
54 }
55 #include <syscalls/ivshmem_register_handler_mrsh.c>
56 
57 #ifdef CONFIG_IVSHMEM_V2
58 
z_vrfy_ivshmem_get_rw_mem_section(const struct device * dev,uintptr_t * memmap)59 static inline size_t z_vrfy_ivshmem_get_rw_mem_section(const struct device *dev,
60 						       uintptr_t *memmap)
61 {
62 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_rw_mem_section));
63 	Z_OOPS(Z_SYSCALL_MEMORY_WRITE(memmap, sizeof(uintptr_t)));
64 
65 	return z_impl_ivshmem_get_rw_mem_section(dev, memmap);
66 }
67 #include <syscalls/ivshmem_get_rw_mem_section_mrsh.c>
68 
z_vrfy_ivshmem_get_output_mem_section(const struct device * dev,uint32_t peer_id,uintptr_t * memmap)69 static inline size_t z_vrfy_ivshmem_get_output_mem_section(const struct device *dev,
70 							   uint32_t peer_id,
71 							   uintptr_t *memmap)
72 {
73 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_output_mem_section));
74 	Z_OOPS(Z_SYSCALL_MEMORY_WRITE(memmap, sizeof(uintptr_t)));
75 
76 	return z_impl_ivshmem_get_output_mem_section(dev, peer_id, memmap);
77 }
78 #include <syscalls/ivshmem_get_output_mem_section_mrsh.c>
79 
z_vrfy_ivshmem_get_state(const struct device * dev,uint32_t peer_id)80 static inline uint32_t z_vrfy_ivshmem_get_state(const struct device *dev,
81 						uint32_t peer_id)
82 {
83 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_state));
84 
85 	return z_impl_ivshmem_get_state(dev, peer_id);
86 }
87 #include <syscalls/ivshmem_get_state_mrsh.c>
88 
z_vrfy_ivshmem_set_state(const struct device * dev,uint32_t state)89 static inline int z_vrfy_ivshmem_set_state(const struct device *dev,
90 					   uint32_t state)
91 {
92 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, set_state));
93 
94 	return z_impl_ivshmem_set_state(dev, state);
95 }
96 #include <syscalls/ivshmem_set_state_mrsh.c>
97 
z_vrfy_ivshmem_get_max_peers(const struct device * dev)98 static inline uint32_t z_vrfy_ivshmem_get_max_peers(const struct device *dev)
99 {
100 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_max_peers));
101 
102 	return z_impl_ivshmem_get_max_peers(dev);
103 }
104 #include <syscalls/ivshmem_get_max_peers_mrsh.c>
105 
z_vrfy_ivshmem_get_protocol(const struct device * dev)106 static inline uint16_t z_vrfy_ivshmem_get_protocol(const struct device *dev)
107 {
108 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, get_protocol));
109 
110 	return z_impl_ivshmem_get_protocol(dev);
111 }
112 #include <syscalls/ivshmem_get_protocol_mrsh.c>
113 
z_vrfy_ivshmem_enable_interrupts(const struct device * dev,bool enable)114 static inline int z_vrfy_ivshmem_enable_interrupts(const struct device *dev,
115 						   bool enable)
116 {
117 	Z_OOPS(Z_SYSCALL_DRIVER_IVSHMEM(dev, enable_interrupts));
118 
119 	return z_impl_ivshmem_enable_interrupts(dev, enable);
120 }
121 #include <syscalls/ivshmem_enable_interrupts_mrsh.c>
122 
123 #endif /* CONFIG_IVSHMEM_V2 */
124