2022-12-30 06:05:40 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2023 Google LLC
|
2023-05-18 04:51:16 +08:00
|
|
|
* Copyright 2023 Microsoft Corporation
|
2022-12-30 06:05:40 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2023-09-27 06:46:01 +08:00
|
|
|
#include <zephyr/internal/syscall_handler.h>
|
2022-12-30 06:05:40 +08:00
|
|
|
#include <zephyr/drivers/fuel_gauge.h>
|
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev, fuel_gauge_prop_t prop,
|
|
|
|
union fuel_gauge_prop_val *val)
|
2023-09-20 01:40:10 +08:00
|
|
|
{
|
2023-09-23 02:17:27 +08:00
|
|
|
union fuel_gauge_prop_val k_val;
|
2023-09-20 01:40:10 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
|
2023-09-20 01:40:10 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_from_copy(&k_val, val, sizeof(union fuel_gauge_prop_val)));
|
2023-09-20 01:40:10 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
int ret = z_impl_fuel_gauge_get_prop(dev, prop, &k_val);
|
2023-09-20 01:40:10 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_to_copy(val, &k_val, sizeof(union fuel_gauge_prop_val)));
|
2023-09-20 01:40:10 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_get_prop_mrsh.c>
|
2023-09-20 01:40:10 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
static inline int z_vrfy_fuel_gauge_get_props(const struct device *dev, fuel_gauge_prop_t *props,
|
|
|
|
union fuel_gauge_prop_val *vals, size_t len)
|
2022-12-30 06:05:40 +08:00
|
|
|
{
|
2023-09-23 02:17:27 +08:00
|
|
|
union fuel_gauge_prop_val k_vals[len];
|
|
|
|
fuel_gauge_prop_t k_props[len];
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
|
|
|
|
K_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
int ret = z_impl_fuel_gauge_get_props(dev, k_props, k_vals, len);
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val)));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_get_props_mrsh.c>
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
static inline int z_vrfy_fuel_gauge_set_prop(const struct device *dev, fuel_gauge_prop_t prop,
|
|
|
|
union fuel_gauge_prop_val val)
|
2023-09-21 06:16:41 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
|
2023-09-21 06:16:41 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
int ret = z_impl_fuel_gauge_set_prop(dev, prop, val);
|
2023-09-21 06:16:41 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_set_prop_mrsh.c>
|
2023-09-21 06:16:41 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
static inline int z_vrfy_fuel_gauge_set_props(const struct device *dev, fuel_gauge_prop_t *props,
|
|
|
|
union fuel_gauge_prop_val *vals, size_t len)
|
2022-12-30 06:05:40 +08:00
|
|
|
{
|
2023-09-23 02:17:27 +08:00
|
|
|
union fuel_gauge_prop_val k_vals[len];
|
|
|
|
fuel_gauge_prop_t k_props[len];
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
|
|
|
|
K_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
int ret = z_impl_fuel_gauge_set_props(dev, k_props, k_vals, len);
|
2022-12-30 06:05:40 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
/* We only copy back vals because props will never be modified */
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(k_usermode_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val)));
|
2022-12-30 06:05:40 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_set_props_mrsh.c>
|
2023-05-18 04:51:16 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_fuel_gauge_get_buffer_prop(const struct device *dev,
|
2023-09-23 02:17:27 +08:00
|
|
|
fuel_gauge_prop_t prop, void *dst,
|
|
|
|
size_t dst_len)
|
2023-05-18 04:51:16 +08:00
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_buffer_property));
|
2023-05-18 04:51:16 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(dst, dst_len));
|
2023-05-18 04:51:16 +08:00
|
|
|
|
2023-09-23 02:17:27 +08:00
|
|
|
int ret = z_impl_fuel_gauge_get_buffer_prop(dev, prop, dst, dst_len);
|
2023-05-18 04:51:16 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_get_buffer_prop_mrsh.c>
|
2023-08-17 04:39:38 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_fuel_gauge_battery_cutoff(const struct device *dev)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_FUEL_GAUGE(dev, battery_cutoff));
|
2023-08-17 04:39:38 +08:00
|
|
|
|
|
|
|
return z_impl_fuel_gauge_battery_cutoff(dev);
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/fuel_gauge_battery_cutoff_mrsh.c>
|