1 /*
2 * Copyright (c) 2017 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/drivers/gpio.h>
8 #include <zephyr/internal/syscall_handler.h>
9
z_vrfy_gpio_pin_configure(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)10 static inline int z_vrfy_gpio_pin_configure(const struct device *port,
11 gpio_pin_t pin,
12 gpio_flags_t flags)
13 {
14 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, pin_configure));
15 return z_impl_gpio_pin_configure((const struct device *)port,
16 pin,
17 flags);
18 }
19 #include <syscalls/gpio_pin_configure_mrsh.c>
20
21 #ifdef CONFIG_GPIO_GET_CONFIG
z_vrfy_gpio_pin_get_config(const struct device * port,gpio_pin_t pin,gpio_flags_t * flags)22 static inline int z_vrfy_gpio_pin_get_config(const struct device *port,
23 gpio_pin_t pin,
24 gpio_flags_t *flags)
25 {
26 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, pin_get_config));
27 K_OOPS(K_SYSCALL_MEMORY_WRITE(flags, sizeof(gpio_flags_t)));
28
29 return z_impl_gpio_pin_get_config(port, pin, flags);
30 }
31 #include <syscalls/gpio_pin_get_config_mrsh.c>
32 #endif
33
z_vrfy_gpio_port_get_raw(const struct device * port,gpio_port_value_t * value)34 static inline int z_vrfy_gpio_port_get_raw(const struct device *port,
35 gpio_port_value_t *value)
36 {
37 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, port_get_raw));
38 K_OOPS(K_SYSCALL_MEMORY_WRITE(value, sizeof(gpio_port_value_t)));
39 return z_impl_gpio_port_get_raw((const struct device *)port,
40 (gpio_port_value_t *)value);
41 }
42 #include <syscalls/gpio_port_get_raw_mrsh.c>
43
z_vrfy_gpio_port_set_masked_raw(const struct device * port,gpio_port_pins_t mask,gpio_port_value_t value)44 static inline int z_vrfy_gpio_port_set_masked_raw(const struct device *port,
45 gpio_port_pins_t mask,
46 gpio_port_value_t value)
47 {
48 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, port_set_masked_raw));
49 return z_impl_gpio_port_set_masked_raw((const struct device *)port,
50 mask,
51 value);
52 }
53 #include <syscalls/gpio_port_set_masked_raw_mrsh.c>
54
z_vrfy_gpio_port_set_bits_raw(const struct device * port,gpio_port_pins_t pins)55 static inline int z_vrfy_gpio_port_set_bits_raw(const struct device *port,
56 gpio_port_pins_t pins)
57 {
58 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, port_set_bits_raw));
59 return z_impl_gpio_port_set_bits_raw((const struct device *)port,
60 pins);
61 }
62 #include <syscalls/gpio_port_set_bits_raw_mrsh.c>
63
z_vrfy_gpio_port_clear_bits_raw(const struct device * port,gpio_port_pins_t pins)64 static inline int z_vrfy_gpio_port_clear_bits_raw(const struct device *port,
65 gpio_port_pins_t pins)
66 {
67 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, port_clear_bits_raw));
68 return z_impl_gpio_port_clear_bits_raw((const struct device *)port,
69 pins);
70 }
71 #include <syscalls/gpio_port_clear_bits_raw_mrsh.c>
72
z_vrfy_gpio_port_toggle_bits(const struct device * port,gpio_port_pins_t pins)73 static inline int z_vrfy_gpio_port_toggle_bits(const struct device *port,
74 gpio_port_pins_t pins)
75 {
76 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, port_toggle_bits));
77 return z_impl_gpio_port_toggle_bits((const struct device *)port, pins);
78 }
79 #include <syscalls/gpio_port_toggle_bits_mrsh.c>
80
z_vrfy_gpio_pin_interrupt_configure(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)81 static inline int z_vrfy_gpio_pin_interrupt_configure(const struct device *port,
82 gpio_pin_t pin,
83 gpio_flags_t flags)
84 {
85 K_OOPS(K_SYSCALL_DRIVER_GPIO(port, pin_interrupt_configure));
86 return z_impl_gpio_pin_interrupt_configure((const struct device *)port,
87 pin,
88 flags);
89 }
90 #include <syscalls/gpio_pin_interrupt_configure_mrsh.c>
91
z_vrfy_gpio_get_pending_int(const struct device * dev)92 static inline int z_vrfy_gpio_get_pending_int(const struct device *dev)
93 {
94 K_OOPS(K_SYSCALL_DRIVER_GPIO(dev, get_pending_int));
95
96 return z_impl_gpio_get_pending_int((const struct device *)dev);
97 }
98 #include <syscalls/gpio_get_pending_int_mrsh.c>
99
100 #ifdef CONFIG_GPIO_GET_DIRECTION
z_vrfy_gpio_port_get_direction(const struct device * dev,gpio_port_pins_t map,gpio_port_pins_t * inputs,gpio_port_pins_t * outputs)101 static inline int z_vrfy_gpio_port_get_direction(const struct device *dev, gpio_port_pins_t map,
102 gpio_port_pins_t *inputs,
103 gpio_port_pins_t *outputs)
104 {
105 K_OOPS(K_SYSCALL_DRIVER_GPIO(dev, port_get_direction));
106
107 if (inputs != NULL) {
108 K_OOPS(K_SYSCALL_MEMORY_WRITE(inputs, sizeof(gpio_port_pins_t)));
109 }
110
111 if (outputs != NULL) {
112 K_OOPS(K_SYSCALL_MEMORY_WRITE(outputs, sizeof(gpio_port_pins_t)));
113 }
114
115 return z_impl_gpio_port_get_direction(dev, map, inputs, outputs);
116 }
117 #include <syscalls/gpio_port_get_direction_mrsh.c>
118 #endif /* CONFIG_GPIO_GET_DIRECTION */
119