1 /*
2 * Copyright 2023 Google LLC
3 * Copyright 2023 Microsoft Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include <zephyr/internal/syscall_handler.h>
9 #include <zephyr/drivers/fuel_gauge.h>
10
z_vrfy_fuel_gauge_get_prop(const struct device * dev,fuel_gauge_prop_t prop,union fuel_gauge_prop_val * val)11 static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev, fuel_gauge_prop_t prop,
12 union fuel_gauge_prop_val *val)
13 {
14 union fuel_gauge_prop_val k_val;
15
16 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
17
18 K_OOPS(k_usermode_from_copy(&k_val, val, sizeof(union fuel_gauge_prop_val)));
19
20 int ret = z_impl_fuel_gauge_get_prop(dev, prop, &k_val);
21
22 K_OOPS(k_usermode_to_copy(val, &k_val, sizeof(union fuel_gauge_prop_val)));
23
24 return ret;
25 }
26
27 #include <zephyr/syscalls/fuel_gauge_get_prop_mrsh.c>
28
z_vrfy_fuel_gauge_get_props(const struct device * dev,const fuel_gauge_prop_t * props,union fuel_gauge_prop_val * vals,size_t len)29 static inline int z_vrfy_fuel_gauge_get_props(const struct device *dev,
30 const fuel_gauge_prop_t *props,
31 union fuel_gauge_prop_val *vals, size_t len)
32 {
33 union fuel_gauge_prop_val k_vals[len];
34 fuel_gauge_prop_t k_props[len];
35
36 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
37
38 K_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
39 K_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
40
41 int ret = z_impl_fuel_gauge_get_props(dev, k_props, k_vals, len);
42
43 K_OOPS(k_usermode_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val)));
44
45 return ret;
46 }
47
48 #include <zephyr/syscalls/fuel_gauge_get_props_mrsh.c>
49
z_vrfy_fuel_gauge_set_prop(const struct device * dev,fuel_gauge_prop_t prop,union fuel_gauge_prop_val val)50 static inline int z_vrfy_fuel_gauge_set_prop(const struct device *dev, fuel_gauge_prop_t prop,
51 union fuel_gauge_prop_val val)
52 {
53 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
54
55 int ret = z_impl_fuel_gauge_set_prop(dev, prop, val);
56
57 return ret;
58 }
59
60 #include <zephyr/syscalls/fuel_gauge_set_prop_mrsh.c>
61
z_vrfy_fuel_gauge_set_props(const struct device * dev,const fuel_gauge_prop_t * props,const union fuel_gauge_prop_val * vals,size_t len)62 static inline int z_vrfy_fuel_gauge_set_props(const struct device *dev,
63 const fuel_gauge_prop_t *props,
64 const union fuel_gauge_prop_val *vals, size_t len)
65 {
66 union fuel_gauge_prop_val k_vals[len];
67 fuel_gauge_prop_t k_props[len];
68
69 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
70
71 K_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
72 K_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
73
74 int ret = z_impl_fuel_gauge_set_props(dev, k_props, k_vals, len);
75
76 return ret;
77 }
78
79 #include <zephyr/syscalls/fuel_gauge_set_props_mrsh.c>
80
z_vrfy_fuel_gauge_get_buffer_prop(const struct device * dev,fuel_gauge_prop_t prop,void * dst,size_t dst_len)81 static inline int z_vrfy_fuel_gauge_get_buffer_prop(const struct device *dev,
82 fuel_gauge_prop_t prop, void *dst,
83 size_t dst_len)
84 {
85 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_buffer_property));
86
87 K_OOPS(K_SYSCALL_MEMORY_WRITE(dst, dst_len));
88
89 int ret = z_impl_fuel_gauge_get_buffer_prop(dev, prop, dst, dst_len);
90
91 return ret;
92 }
93
94 #include <zephyr/syscalls/fuel_gauge_get_buffer_prop_mrsh.c>
95
z_vrfy_fuel_gauge_battery_cutoff(const struct device * dev)96 static inline int z_vrfy_fuel_gauge_battery_cutoff(const struct device *dev)
97 {
98 K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, battery_cutoff));
99
100 return z_impl_fuel_gauge_battery_cutoff(dev);
101 }
102
103 #include <zephyr/syscalls/fuel_gauge_battery_cutoff_mrsh.c>
104