1 /*
2  * Copyright (c) 2022 Thomas Stranger
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/internal/syscall_handler.h>
8 #include <zephyr/drivers/w1.h>
9 
z_vrfy_w1_reset_bus(const struct device * dev)10 static inline int z_vrfy_w1_reset_bus(const struct device *dev)
11 {
12 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, reset_bus));
13 
14 	return z_impl_w1_reset_bus((const struct device *)dev);
15 }
16 #include <zephyr/syscalls/w1_reset_bus_mrsh.c>
17 
z_vrfy_w1_read_bit(const struct device * dev)18 static inline int z_vrfy_w1_read_bit(const struct device *dev)
19 {
20 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, read_bit));
21 
22 	return z_impl_w1_read_bit((const struct device *)dev);
23 }
24 #include <zephyr/syscalls/w1_read_bit_mrsh.c>
25 
z_vrfy_w1_write_bit(const struct device * dev,bool bit)26 static inline int z_vrfy_w1_write_bit(const struct device *dev, bool bit)
27 {
28 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, write_bit));
29 
30 	return z_impl_w1_write_bit((const struct device *)dev, bit);
31 }
32 #include <zephyr/syscalls/w1_write_bit_mrsh.c>
33 
z_vrfy_w1_read_byte(const struct device * dev)34 static inline int z_vrfy_w1_read_byte(const struct device *dev)
35 {
36 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, read_byte));
37 
38 	return z_impl_w1_read_byte((const struct device *)dev);
39 }
40 #include <zephyr/syscalls/w1_read_byte_mrsh.c>
41 
z_vrfy_w1_write_byte(const struct device * dev,uint8_t byte)42 static inline int z_vrfy_w1_write_byte(const struct device *dev, uint8_t byte)
43 {
44 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, write_byte));
45 
46 	return z_impl_w1_write_byte((const struct device *)dev, (uint8_t)byte);
47 }
48 #include <zephyr/syscalls/w1_write_byte_mrsh.c>
49 
z_vrfy_w1_read_block(const struct device * dev,uint8_t * buffer,size_t len)50 static inline int z_vrfy_w1_read_block(const struct device *dev,
51 				       uint8_t *buffer, size_t len)
52 {
53 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
54 	K_OOPS(K_SYSCALL_MEMORY_WRITE(buffer, len));
55 
56 	return z_impl_w1_read_block((const struct device *)dev,
57 				    (uint8_t *)buffer, (size_t)len);
58 }
59 #include <zephyr/syscalls/w1_read_block_mrsh.c>
60 
z_vrfy_w1_write_block(const struct device * dev,const uint8_t * buffer,size_t len)61 static inline int z_vrfy_w1_write_block(const struct device *dev,
62 					const uint8_t *buffer, size_t len)
63 {
64 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
65 	K_OOPS(K_SYSCALL_MEMORY_READ(buffer, len));
66 
67 	return z_impl_w1_write_block((const struct device *)dev,
68 				     (const uint8_t *)buffer, (size_t)len);
69 }
70 #include <zephyr/syscalls/w1_write_block_mrsh.c>
71 
z_vrfy_w1_change_bus_lock(const struct device * dev,bool lock)72 static inline int z_vrfy_w1_change_bus_lock(const struct device *dev, bool lock)
73 {
74 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
75 
76 	return z_impl_w1_change_bus_lock((const struct device *)dev, lock);
77 }
78 #include <zephyr/syscalls/w1_change_bus_lock_mrsh.c>
79 
z_vrfy_w1_configure(const struct device * dev,enum w1_settings_type type,uint32_t value)80 static inline int z_vrfy_w1_configure(const struct device *dev,
81 				      enum w1_settings_type type, uint32_t value)
82 {
83 	K_OOPS(K_SYSCALL_DRIVER_W1(dev, configure));
84 
85 	return z_impl_w1_configure(dev, type, value);
86 }
87 #include <zephyr/syscalls/w1_configure_mrsh.c>
88 
z_vrfy_w1_get_slave_count(const struct device * dev)89 static inline size_t z_vrfy_w1_get_slave_count(const struct device *dev)
90 {
91 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
92 
93 	return z_impl_w1_get_slave_count((const struct device *)dev);
94 }
95 #include <zephyr/syscalls/w1_get_slave_count_mrsh.c>
96 
97 #if CONFIG_W1_NET
z_vrfy_w1_search_bus(const struct device * dev,uint8_t command,uint8_t family,w1_search_callback_t callback,void * user_data)98 static inline int z_vrfy_w1_search_bus(const struct device *dev,
99 				       uint8_t command, uint8_t family,
100 				       w1_search_callback_t callback,
101 				       void *user_data)
102 {
103 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
104 
105 	K_OOPS(K_SYSCALL_VERIFY_MSG(callback == 0,
106 				    "callbacks may not be set from user mode"));
107 	/* user_data is not dereferenced, no need to check parameter */
108 
109 	return z_impl_w1_search_bus((const struct device *)dev,
110 				    (uint8_t)command, (uint8_t)family,
111 				    (w1_search_callback_t)callback,
112 				    (void *)user_data);
113 }
114 
115 #include <zephyr/syscalls/w1_search_bus_mrsh.c>
116 #endif /* CONFIG_W1_NET */
117