Skip to content

Commit

Permalink
drivers: watchdog: add system calls
Browse files Browse the repository at this point in the history
wdt_install_timeout() was skipped as it installs an ISR-context
callback handler function. The rest are simple wrappers.

Added myself as the maintainer of the syscall handlers. WDT
subsystem appears to not currently have an owner.

Fixes: zephyrproject-rtos#21432

Signed-off-by: Andrew Boie <[email protected]>
Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
Andrew Boie committed Jan 7, 2020
1 parent 2073058 commit 40e31c7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ arch/arm/include/cortex_m/cmse.h @ioannisg
/drivers/usb/ @jfischer-phytec-iot @finikorg
/drivers/usb/device/usb_dc_stm32.c @ydamigos @loicpoulain
/drivers/i2c/i2c_ll_stm32* @ldts @ydamigos
/drivers/watchdog/wdt_handlers.c @andrewboie
/drivers/wifi/ @jukkar @tbursztyka @pfalcon
/drivers/wifi/eswifi/ @loicpoulain
/dts/arm/st/ @erwango
Expand Down
1 change: 1 addition & 0 deletions drivers/watchdog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ zephyr_sources_ifdef(CONFIG_WDT_ESP32 wdt_esp32.c)
zephyr_sources_ifdef(CONFIG_WDT_SAM0 wdt_sam0.c)
zephyr_sources_ifdef(CONFIG_WDT_NRFX wdt_nrfx.c)
zephyr_sources_ifdef(CONFIG_WDT_MCUX_WDOG wdt_mcux_wdog.c)
zephyr_sources_ifdef(CONFIG_USERSPACE wdt_handlers.c)
26 changes: 26 additions & 0 deletions drivers/watchdog/wdt_handlers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <watchdog.h>
#include <syscall_handler.h>

Z_SYSCALL_HANDLER(wdt_setup, dev, options)
{
Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, setup));
return z_impl_wdt_setup((struct device *)dev, options);
}

Z_SYSCALL_HANDLER(wdt_disable, dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, disable));
return z_impl_wdt_disable((struct device *)dev);
}

Z_SYSCALL_HANDLER(wdt_feed, dev, channel_id)
{
Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, feed));
return z_impl_wdt_feed((struct device *)dev, channel_id);
}
14 changes: 11 additions & 3 deletions include/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ struct wdt_driver_api {
* @retval -ENOTSUP If any of the set options is not supported.
* @retval -EBUSY If watchdog instance has been already setup.
*/
static inline int wdt_setup(struct device *dev, u8_t options)
__syscall int wdt_setup(struct device *dev, u8_t options);

static inline int z_impl_wdt_setup(struct device *dev, u8_t options)
{
const struct wdt_driver_api *api =
(const struct wdt_driver_api *)dev->driver_api;
Expand All @@ -212,7 +214,9 @@ static inline int wdt_setup(struct device *dev, u8_t options)
* @retval -EFAULT If watchdog instance is not enabled.
* @retval -EPERM If watchdog can not be disabled directly by application code.
*/
static inline int wdt_disable(struct device *dev)
__syscall int wdt_disable(struct device *dev);

static inline int z_impl_wdt_disable(struct device *dev)
{
const struct wdt_driver_api *api =
(const struct wdt_driver_api *)dev->driver_api;
Expand Down Expand Up @@ -260,7 +264,9 @@ static inline int wdt_install_timeout(struct device *dev,
* @retval 0 If successful.
* @retval -EINVAL If there is no installed timeout for supplied channel.
*/
static inline int wdt_feed(struct device *dev, int channel_id)
__syscall int wdt_feed(struct device *dev, int channel_id);

static inline int z_impl_wdt_feed(struct device *dev, int channel_id)
{
const struct wdt_driver_api *api =
(const struct wdt_driver_api *)dev->driver_api;
Expand All @@ -276,4 +282,6 @@ static inline int wdt_feed(struct device *dev, int channel_id)
* @}
*/

#include <syscalls/watchdog.h>

#endif /* _ZEPHYR_WATCHDOG_H__ */
1 change: 1 addition & 0 deletions scripts/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"spi_driver_api",
"uart_driver_api",
"can_driver_api",
"wdt_driver_api",
]


Expand Down

0 comments on commit 40e31c7

Please sign in to comment.