From 95bdfb5c334f6538403178b37404dd512e45da77 Mon Sep 17 00:00:00 2001 From: Laczen JMS Date: Thu, 24 Aug 2023 22:05:38 +0200 Subject: [PATCH] bbram: add support from user threads Provide the necessary handlers to support bbram access from userthreads solves #61868. Signed-off-by: Laczen JMS --- drivers/bbram/CMakeLists.txt | 1 + drivers/bbram/bbram_handlers.c | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 drivers/bbram/bbram_handlers.c diff --git a/drivers/bbram/CMakeLists.txt b/drivers/bbram/CMakeLists.txt index 98eecf4037..538384e9d1 100644 --- a/drivers/bbram/CMakeLists.txt +++ b/drivers/bbram/CMakeLists.txt @@ -5,6 +5,7 @@ zephyr_library() zephyr_library_sources_ifdef(CONFIG_BBRAM_SHELL bbram_shell.c) +zephyr_library_sources_ifdef(CONFIG_USERSPACE bbram_handlers.c) zephyr_library_sources_ifdef(CONFIG_BBRAM_NPCX bbram_npcx.c) zephyr_library_sources_ifdef(CONFIG_BBRAM_IT8XXX2 bbram_it8xxx2.c) zephyr_library_sources_ifdef(CONFIG_BBRAM_EMUL bbram_emul.c) diff --git a/drivers/bbram/bbram_handlers.c b/drivers/bbram/bbram_handlers.c new file mode 100644 index 0000000000..1bc20dcd35 --- /dev/null +++ b/drivers/bbram/bbram_handlers.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023, Laczen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +static inline int z_vrfy_bbram_check_invalid(const struct device *dev) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + return z_impl_bbram_check_invalid(dev); +} +#include + +static inline int z_vrfy_bbram_check_standby_power(const struct device *dev) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + return z_impl_bbram_check_standby_power(dev); +} +#include + +static inline int z_vrfy_bbram_check_power(const struct device *dev) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + return z_impl_bbram_check_power(dev); +} +#include + +static inline int z_vrfy_bbram_get_size(const struct device *dev, size_t *size) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + Z_OOPS(Z_SYSCALL_MEMORY_WRITE(size, sizeof(size_t))); + return z_impl_bbram_get_size(dev, size); +} +#include + +static inline int z_vrfy_bbram_read(const struct device *dev, size_t offset, + size_t size, uint8_t *data) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, size)); + return z_impl_bbram_read(dev, offset, size, data); +} +#include + +static inline int z_vrfy_bbram_write(const struct device *dev, size_t offset, + size_t size, const uint8_t *data) +{ + Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_BBRAM)); + Z_OOPS(Z_SYSCALL_MEMORY_READ(data, size)); + return z_impl_bbram_write(dev, offset, size, data); +} +#include