drivers: counter: add syscall handlers

counter_set_alarm() registers a callback and has been skipped.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-10-25 11:59:13 -07:00 committed by Andrew Boie
commit 678314b7b2
3 changed files with 34 additions and 4 deletions

View file

@ -4,3 +4,4 @@ obj-$(CONFIG_COUNTER_TMR_CMSDK_APB) += counter_tmr_cmsdk_apb.o
obj-$(CONFIG_TIMER_TMR_CMSDK_APB) += timer_tmr_cmsdk_apb.o obj-$(CONFIG_TIMER_TMR_CMSDK_APB) += timer_tmr_cmsdk_apb.o
obj-$(CONFIG_COUNTER_DTMR_CMSDK_APB) += counter_dtmr_cmsdk_apb.o obj-$(CONFIG_COUNTER_DTMR_CMSDK_APB) += counter_dtmr_cmsdk_apb.o
obj-$(CONFIG_TIMER_DTMR_CMSDK_APB) += timer_dtmr_cmsdk_apb.o obj-$(CONFIG_TIMER_DTMR_CMSDK_APB) += timer_dtmr_cmsdk_apb.o
obj-$(CONFIG_USERSPACE) += counter_handlers.o

View file

@ -0,0 +1,19 @@
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <syscall_handler.h>
#include <counter.h>
/* For those APIs that just take one argument which is a counter driver
* instance and return an integral value
*/
#define COUNTER_HANDLER(name) \
_SYSCALL_HANDLER1_SIMPLE(name, K_OBJ_DRIVER_COUNTER, struct device *)
COUNTER_HANDLER(counter_get_pending_int);
COUNTER_HANDLER(counter_read);
COUNTER_HANDLER(counter_stop);
COUNTER_HANDLER(counter_start);

View file

@ -57,7 +57,9 @@ struct counter_driver_api {
* @retval 0 If successful. * @retval 0 If successful.
* @retval Negative errno code if failure. * @retval Negative errno code if failure.
*/ */
static inline int counter_start(struct device *dev) __syscall int counter_start(struct device *dev);
static inline int _impl_counter_start(struct device *dev)
{ {
const struct counter_driver_api *api = dev->driver_api; const struct counter_driver_api *api = dev->driver_api;
@ -72,7 +74,9 @@ static inline int counter_start(struct device *dev)
* @retval -ENODEV if the device doesn't support stopping the * @retval -ENODEV if the device doesn't support stopping the
* counter. * counter.
*/ */
static inline int counter_stop(struct device *dev) __syscall int counter_stop(struct device *dev);
static inline int _impl_counter_stop(struct device *dev)
{ {
const struct counter_driver_api *api = dev->driver_api; const struct counter_driver_api *api = dev->driver_api;
@ -85,7 +89,9 @@ static inline int counter_stop(struct device *dev)
* *
* @return 32-bit value * @return 32-bit value
*/ */
static inline u32_t counter_read(struct device *dev) __syscall u32_t counter_read(struct device *dev);
static inline u32_t _impl_counter_read(struct device *dev)
{ {
const struct counter_driver_api *api = dev->driver_api; const struct counter_driver_api *api = dev->driver_api;
@ -129,7 +135,9 @@ static inline int counter_set_alarm(struct device *dev,
* @retval 1 if the counter interrupt is pending. * @retval 1 if the counter interrupt is pending.
* @retval 0 if no counter interrupt is pending. * @retval 0 if no counter interrupt is pending.
*/ */
static inline int counter_get_pending_int(struct device *dev) __syscall int counter_get_pending_int(struct device *dev);
static inline int _impl_counter_get_pending_int(struct device *dev)
{ {
struct counter_driver_api *api; struct counter_driver_api *api;
@ -145,4 +153,6 @@ static inline int counter_get_pending_int(struct device *dev)
* @} * @}
*/ */
#include <syscalls/counter.h>
#endif /* __COUNTER_H__ */ #endif /* __COUNTER_H__ */