1 /*
2  * Copyright (c) 2022 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/sys/slist.h>
8 #include <zephyr/internal/syscall_handler.h>
9 #include <zephyr/drivers/smbus.h>
10 
z_vrfy_smbus_configure(const struct device * dev,uint32_t dev_config)11 static inline int z_vrfy_smbus_configure(const struct device *dev,
12 					 uint32_t dev_config)
13 {
14 	K_OOPS(K_SYSCALL_DRIVER_SMBUS(dev, configure));
15 
16 	return z_impl_smbus_configure(dev, dev_config);
17 }
18 #include <syscalls/smbus_configure_mrsh.c>
19 
z_vrfy_smbus_get_config(const struct device * dev,uint32_t * dev_config)20 static inline int z_vrfy_smbus_get_config(const struct device *dev,
21 					  uint32_t *dev_config)
22 {
23 	K_OOPS(K_SYSCALL_DRIVER_SMBUS(dev, get_config));
24 	K_OOPS(K_SYSCALL_MEMORY_WRITE(dev_config, sizeof(uint32_t)));
25 
26 	return z_impl_smbus_get_config(dev, dev_config);
27 }
28 #include <syscalls/smbus_get_config_mrsh.c>
29 
z_vrfy_smbus_quick(const struct device * dev,uint16_t addr,enum smbus_direction rw)30 static inline int z_vrfy_smbus_quick(const struct device *dev, uint16_t addr,
31 				     enum smbus_direction rw)
32 {
33 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
34 
35 	return z_impl_smbus_quick(dev, addr, rw);
36 }
37 #include <syscalls/smbus_quick_mrsh.c>
38 
z_vrfy_smbus_byte_write(const struct device * dev,uint16_t addr,uint8_t byte)39 static inline int z_vrfy_smbus_byte_write(const struct device *dev,
40 					  uint16_t addr, uint8_t byte)
41 {
42 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
43 
44 	return z_impl_smbus_byte_write(dev, addr, byte);
45 }
46 #include <syscalls/smbus_byte_write_mrsh.c>
47 
z_vrfy_smbus_byte_read(const struct device * dev,uint16_t addr,uint8_t * byte)48 static inline int z_vrfy_smbus_byte_read(const struct device *dev,
49 					 uint16_t addr, uint8_t *byte)
50 {
51 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
52 	K_OOPS(K_SYSCALL_MEMORY_WRITE(byte, sizeof(uint8_t)));
53 
54 	return z_impl_smbus_byte_read(dev, addr, byte);
55 }
56 #include <syscalls/smbus_byte_read_mrsh.c>
57 
z_vrfy_smbus_byte_data_write(const struct device * dev,uint16_t addr,uint8_t cmd,uint8_t byte)58 static inline int z_vrfy_smbus_byte_data_write(const struct device *dev,
59 					       uint16_t addr, uint8_t cmd,
60 					       uint8_t byte)
61 {
62 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
63 
64 	return z_impl_smbus_byte_data_write(dev, addr, cmd, byte);
65 }
66 #include <syscalls/smbus_byte_data_write_mrsh.c>
67 
z_vrfy_smbus_byte_data_read(const struct device * dev,uint16_t addr,uint8_t cmd,uint8_t * byte)68 static inline int z_vrfy_smbus_byte_data_read(const struct device *dev,
69 					       uint16_t addr, uint8_t cmd,
70 					       uint8_t *byte)
71 {
72 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
73 	K_OOPS(K_SYSCALL_MEMORY_WRITE(byte, sizeof(uint8_t)));
74 
75 	return z_impl_smbus_byte_data_read(dev, addr, cmd, byte);
76 }
77 #include <syscalls/smbus_byte_data_read_mrsh.c>
78 
z_vrfy_smbus_word_data_write(const struct device * dev,uint16_t addr,uint8_t cmd,uint16_t word)79 static inline int z_vrfy_smbus_word_data_write(const struct device *dev,
80 					       uint16_t addr, uint8_t cmd,
81 					       uint16_t word)
82 {
83 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
84 
85 	return z_impl_smbus_word_data_write(dev, addr, cmd, word);
86 }
87 #include <syscalls/smbus_word_data_write_mrsh.c>
88 
z_vrfy_smbus_word_data_read(const struct device * dev,uint16_t addr,uint8_t cmd,uint16_t * word)89 static inline int z_vrfy_smbus_word_data_read(const struct device *dev,
90 					      uint16_t addr, uint8_t cmd,
91 					      uint16_t *word)
92 {
93 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
94 	K_OOPS(K_SYSCALL_MEMORY_WRITE(word, sizeof(uint16_t)));
95 
96 	return z_impl_smbus_word_data_read(dev, addr, cmd, word);
97 }
98 #include <syscalls/smbus_word_data_read_mrsh.c>
99 
z_vrfy_smbus_pcall(const struct device * dev,uint16_t addr,uint8_t cmd,uint16_t send_word,uint16_t * recv_word)100 static inline int z_vrfy_smbus_pcall(const struct device *dev,
101 				     uint16_t addr, uint8_t cmd,
102 				     uint16_t send_word, uint16_t *recv_word)
103 {
104 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
105 	K_OOPS(K_SYSCALL_MEMORY_WRITE(recv_word, sizeof(uint16_t)));
106 
107 	return z_impl_smbus_pcall(dev, addr, cmd, send_word, recv_word);
108 }
109 #include <syscalls/smbus_pcall_mrsh.c>
110 
z_vrfy_smbus_block_write(const struct device * dev,uint16_t addr,uint8_t cmd,uint8_t count,uint8_t * buf)111 static inline int z_vrfy_smbus_block_write(const struct device *dev,
112 					   uint16_t addr, uint8_t cmd,
113 					   uint8_t count, uint8_t *buf)
114 {
115 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
116 	K_OOPS(K_SYSCALL_MEMORY_READ(buf, count));
117 
118 	return z_impl_smbus_block_write(dev, addr, cmd, count, buf);
119 }
120 #include <syscalls/smbus_block_write_mrsh.c>
121 
z_vrfy_smbus_block_read(const struct device * dev,uint16_t addr,uint8_t cmd,uint8_t * count,uint8_t * buf)122 static inline int z_vrfy_smbus_block_read(const struct device *dev,
123 					  uint16_t addr, uint8_t cmd,
124 					  uint8_t *count, uint8_t *buf)
125 {
126 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
127 	K_OOPS(K_SYSCALL_MEMORY_WRITE(count, sizeof(uint8_t)));
128 
129 	return z_impl_smbus_block_read(dev, addr, cmd, count, buf);
130 }
131 #include <syscalls/smbus_block_read_mrsh.c>
132 
z_vrfy_smbus_block_pcall(const struct device * dev,uint16_t addr,uint8_t cmd,uint8_t snd_count,uint8_t * snd_buf,uint8_t * rcv_count,uint8_t * rcv_buf)133 static inline int z_vrfy_smbus_block_pcall(const struct device *dev,
134 					   uint16_t addr, uint8_t cmd,
135 					   uint8_t snd_count, uint8_t *snd_buf,
136 					   uint8_t *rcv_count, uint8_t *rcv_buf)
137 {
138 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
139 	K_OOPS(K_SYSCALL_MEMORY_READ(snd_buf, snd_count));
140 	K_OOPS(K_SYSCALL_MEMORY_WRITE(rcv_count, sizeof(uint8_t)));
141 
142 	return z_impl_smbus_block_pcall(dev, addr, cmd, snd_count, snd_buf,
143 					rcv_count, rcv_buf);
144 }
145 #include <syscalls/smbus_block_pcall_mrsh.c>
146 
z_vrfy_smbus_smbalert_remove_cb(const struct device * dev,struct smbus_callback * cb)147 static inline int z_vrfy_smbus_smbalert_remove_cb(const struct device *dev,
148 						  struct smbus_callback *cb)
149 {
150 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
151 
152 	return z_impl_smbus_smbalert_remove_cb(dev, cb);
153 }
154 #include <syscalls/smbus_smbalert_remove_cb_mrsh.c>
155 
z_vrfy_smbus_host_notify_remove_cb(const struct device * dev,struct smbus_callback * cb)156 static inline int z_vrfy_smbus_host_notify_remove_cb(const struct device *dev,
157 						     struct smbus_callback *cb)
158 {
159 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
160 
161 	return z_impl_smbus_host_notify_remove_cb(dev, cb);
162 }
163 #include <syscalls/smbus_host_notify_remove_cb_mrsh.c>
164