syscalls: remove policy from handler checks The various macros to do checks in system call handlers all implictly would generate a kernel oops if a check failed. This is undesirable for a few reasons: * System call handlers that acquire resources in the handler have no good recourse for cleanup if a check fails. * In some cases we may want to propagate a return value back to the caller instead of just killing the calling thread, even though the base API doesn't do these checks. These macros now all return a value, if nonzero is returned the check failed. K_OOPS() now wraps these calls to generate a kernel oops. At the moment, the policy for all APIs has not changed. They still all oops upon a failed check/ The macros now use the Z_ notation for private APIs. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
diff --git a/kernel/timer.c b/kernel/timer.c index ea1ac6b..6b4a573 100644 --- a/kernel/timer.c +++ b/kernel/timer.c
@@ -133,16 +133,16 @@ } #ifdef CONFIG_USERSPACE -_SYSCALL_HANDLER(k_timer_start, timer, duration_p, period_p) +Z_SYSCALL_HANDLER(k_timer_start, timer, duration_p, period_p) { s32_t duration, period; duration = (s32_t)duration_p; period = (s32_t)period_p; - _SYSCALL_VERIFY(duration >= 0 && period >= 0 && - (duration != 0 || period != 0)); - _SYSCALL_OBJ(timer, K_OBJ_TIMER); + Z_OOPS(Z_SYSCALL_VERIFY(duration >= 0 && period >= 0 && + (duration != 0 || period != 0))); + Z_OOPS(Z_SYSCALL_OBJ(timer, K_OBJ_TIMER)); _impl_k_timer_start((struct k_timer *)timer, duration, period); return 0; } @@ -178,7 +178,7 @@ } #ifdef CONFIG_USERSPACE -_SYSCALL_HANDLER1_SIMPLE_VOID(k_timer_stop, K_OBJ_TIMER, struct k_timer *); +Z_SYSCALL_HANDLER1_SIMPLE_VOID(k_timer_stop, K_OBJ_TIMER, struct k_timer *); #endif u32_t _impl_k_timer_status_get(struct k_timer *timer) @@ -193,7 +193,7 @@ } #ifdef CONFIG_USERSPACE -_SYSCALL_HANDLER1_SIMPLE(k_timer_status_get, K_OBJ_TIMER, struct k_timer *); +Z_SYSCALL_HANDLER1_SIMPLE(k_timer_status_get, K_OBJ_TIMER, struct k_timer *); #endif u32_t _impl_k_timer_status_sync(struct k_timer *timer) @@ -225,7 +225,7 @@ } #ifdef CONFIG_USERSPACE -_SYSCALL_HANDLER1_SIMPLE(k_timer_status_sync, K_OBJ_TIMER, struct k_timer *); +Z_SYSCALL_HANDLER1_SIMPLE(k_timer_status_sync, K_OBJ_TIMER, struct k_timer *); #endif s32_t _timeout_remaining_get(struct _timeout *timeout) @@ -256,12 +256,12 @@ } #ifdef CONFIG_USERSPACE -_SYSCALL_HANDLER1_SIMPLE(k_timer_remaining_get, K_OBJ_TIMER, struct k_timer *); -_SYSCALL_HANDLER1_SIMPLE(k_timer_user_data_get, K_OBJ_TIMER, struct k_timer *); +Z_SYSCALL_HANDLER1_SIMPLE(k_timer_remaining_get, K_OBJ_TIMER, struct k_timer *); +Z_SYSCALL_HANDLER1_SIMPLE(k_timer_user_data_get, K_OBJ_TIMER, struct k_timer *); -_SYSCALL_HANDLER(k_timer_user_data_set, timer, user_data) +Z_SYSCALL_HANDLER(k_timer_user_data_set, timer, user_data) { - _SYSCALL_OBJ(timer, K_OBJ_TIMER); + Z_OOPS(Z_SYSCALL_OBJ(timer, K_OBJ_TIMER)); _impl_k_timer_user_data_set((struct k_timer *)timer, (void *)user_data); return 0; }