1 /*
2  * Copyright (c) 2017 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/drivers/sensor.h>
8 #include <zephyr/internal/syscall_handler.h>
9 
z_vrfy_sensor_attr_set(const struct device * dev,enum sensor_channel chan,enum sensor_attribute attr,const struct sensor_value * val)10 static inline int z_vrfy_sensor_attr_set(const struct device *dev,
11 					 enum sensor_channel chan,
12 					 enum sensor_attribute attr,
13 					 const struct sensor_value *val)
14 {
15 	K_OOPS(K_SYSCALL_DRIVER_SENSOR(dev, attr_set));
16 	K_OOPS(K_SYSCALL_MEMORY_READ(val, sizeof(struct sensor_value)));
17 	return z_impl_sensor_attr_set((const struct device *)dev, chan, attr,
18 				      (const struct sensor_value *)val);
19 }
20 #include <zephyr/syscalls/sensor_attr_set_mrsh.c>
21 
z_vrfy_sensor_attr_get(const struct device * dev,enum sensor_channel chan,enum sensor_attribute attr,struct sensor_value * val)22 static inline int z_vrfy_sensor_attr_get(const struct device *dev,
23 					 enum sensor_channel chan,
24 					 enum sensor_attribute attr,
25 					 struct sensor_value *val)
26 {
27 	K_OOPS(K_SYSCALL_DRIVER_SENSOR(dev, attr_get));
28 	K_OOPS(K_SYSCALL_MEMORY_WRITE(val, sizeof(struct sensor_value)));
29 	return z_impl_sensor_attr_get((const struct device *)dev, chan, attr,
30 				      (struct sensor_value *)val);
31 }
32 #include <zephyr/syscalls/sensor_attr_get_mrsh.c>
33 
z_vrfy_sensor_sample_fetch(const struct device * dev)34 static inline int z_vrfy_sensor_sample_fetch(const struct device *dev)
35 {
36 	K_OOPS(K_SYSCALL_DRIVER_SENSOR(dev, sample_fetch));
37 	return z_impl_sensor_sample_fetch((const struct device *)dev);
38 }
39 #include <zephyr/syscalls/sensor_sample_fetch_mrsh.c>
40 
z_vrfy_sensor_sample_fetch_chan(const struct device * dev,enum sensor_channel type)41 static inline int z_vrfy_sensor_sample_fetch_chan(const struct device *dev,
42 						  enum sensor_channel type)
43 {
44 	K_OOPS(K_SYSCALL_DRIVER_SENSOR(dev, sample_fetch));
45 	return z_impl_sensor_sample_fetch_chan((const struct device *)dev,
46 					       type);
47 }
48 #include <zephyr/syscalls/sensor_sample_fetch_chan_mrsh.c>
49 
z_vrfy_sensor_channel_get(const struct device * dev,enum sensor_channel chan,struct sensor_value * val)50 static inline int z_vrfy_sensor_channel_get(const struct device *dev,
51 					    enum sensor_channel chan,
52 					    struct sensor_value *val)
53 {
54 	K_OOPS(K_SYSCALL_DRIVER_SENSOR(dev, channel_get));
55 	K_OOPS(K_SYSCALL_MEMORY_WRITE(val, sizeof(struct sensor_value)));
56 	return z_impl_sensor_channel_get((const struct device *)dev, chan,
57 					 (struct sensor_value *)val);
58 }
59 #include <zephyr/syscalls/sensor_channel_get_mrsh.c>
60 
61 #ifdef CONFIG_SENSOR_ASYNC_API
z_vrfy_sensor_get_decoder(const struct device * dev,const struct sensor_decoder_api ** decoder)62 static inline int z_vrfy_sensor_get_decoder(const struct device *dev,
63 					    const struct sensor_decoder_api **decoder)
64 {
65 	K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SENSOR));
66 	K_OOPS(K_SYSCALL_MEMORY_READ(decoder, sizeof(struct sensor_decoder_api)));
67 	return z_impl_sensor_get_decoder(dev, decoder);
68 }
69 #include <zephyr/syscalls/sensor_get_decoder_mrsh.c>
70 
z_vrfy_sensor_reconfigure_read_iodev(struct rtio_iodev * iodev,const struct device * sensor,const struct sensor_chan_spec * channels,size_t num_channels)71 static inline int z_vrfy_sensor_reconfigure_read_iodev(struct rtio_iodev *iodev,
72 						       const struct device *sensor,
73 						       const struct sensor_chan_spec *channels,
74 						       size_t num_channels)
75 {
76 	K_OOPS(K_SYSCALL_OBJ(iodev, K_OBJ_RTIO_IODEV));
77 	K_OOPS(K_SYSCALL_OBJ(sensor, K_OBJ_DRIVER_SENSOR));
78 	K_OOPS(K_SYSCALL_MEMORY_READ(channels, sizeof(enum sensor_channel) * num_channels));
79 	return z_impl_sensor_reconfigure_read_iodev(iodev, sensor, channels, num_channels);
80 }
81 #include <zephyr/syscalls/sensor_reconfigure_read_iodev_mrsh.c>
82 #endif
83