diff --git a/kernel/alert.c b/kernel/alert.c index 1b9f82c0ef1..4dc3d24de02 100644 --- a/kernel/alert.c +++ b/kernel/alert.c @@ -97,7 +97,7 @@ u32_t _handler_k_alert_send(u32_t alert, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(alert, K_OBJ_ALERT, 0, ssf); + _SYSCALL_OBJ(alert, K_OBJ_ALERT, ssf); _impl_k_alert_send((struct k_alert *)alert); return 0; @@ -115,7 +115,7 @@ u32_t _handler_k_alert_recv(u32_t alert, u32_t timeout, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(alert, K_OBJ_ALERT, 0, ssf); + _SYSCALL_OBJ(alert, K_OBJ_ALERT, ssf); return _impl_k_alert_recv((struct k_alert *)alert, timeout); } #endif diff --git a/kernel/msg_q.c b/kernel/msg_q.c index dda1c0f38d9..da324ec9508 100644 --- a/kernel/msg_q.c +++ b/kernel/msg_q.c @@ -69,8 +69,8 @@ u32_t _handler_k_msgq_init(u32_t q, u32_t buffer, u32_t msg_size, { _SYSCALL_ARG4; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 1, ssf); - _SYSCALL_MEMORY(buffer, msg_size * max_msgs, 1, ssf); + _SYSCALL_OBJ_INIT(q, K_OBJ_MSGQ, ssf); + _SYSCALL_MEMORY_WRITE(buffer, msg_size * max_msgs, ssf); _impl_k_msgq_init((struct k_msgq *)q, (char *)buffer, msg_size, max_msgs); @@ -133,8 +133,8 @@ u32_t _handler_k_msgq_put(u32_t msgq_p, u32_t data, u32_t timeout, struct k_msgq *q = (struct k_msgq *)msgq_p; _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 0, ssf); - _SYSCALL_MEMORY(data, q->msg_size, 0, ssf); + _SYSCALL_OBJ(q, K_OBJ_MSGQ, ssf); + _SYSCALL_MEMORY_READ(data, q->msg_size, ssf); return _impl_k_msgq_put(q, (void *)data, timeout); } @@ -201,8 +201,8 @@ u32_t _handler_k_msgq_get(u32_t msgq_p, u32_t data, u32_t timeout, struct k_msgq *q = (struct k_msgq *)msgq_p; _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 0, ssf); - _SYSCALL_MEMORY(data, q->msg_size, 1, ssf); + _SYSCALL_OBJ(q, K_OBJ_MSGQ, ssf); + _SYSCALL_MEMORY_WRITE(data, q->msg_size, ssf); return _impl_k_msgq_get(q, (void *)data, timeout); } @@ -232,7 +232,7 @@ u32_t _handler_k_msgq_purge(u32_t q, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 0, ssf); + _SYSCALL_OBJ(q, K_OBJ_MSGQ, ssf); _impl_k_msgq_purge((struct k_msgq *)q); return 0; @@ -243,7 +243,7 @@ u32_t _handler_k_msgq_num_free_get(u32_t q, u32_t arg2, u32_t arg3, u32_t arg4, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 0, ssf); + _SYSCALL_OBJ(q, K_OBJ_MSGQ, ssf); return _impl_k_msgq_num_free_get((struct k_msgq *)q); } @@ -253,7 +253,7 @@ u32_t _handler_k_msgq_num_used_get(u32_t q, u32_t arg2, u32_t arg3, u32_t arg4, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(q, K_OBJ_MSGQ, 0, ssf); + _SYSCALL_OBJ(q, K_OBJ_MSGQ, ssf); return _impl_k_msgq_num_used_get((struct k_msgq *)q); } diff --git a/kernel/mutex.c b/kernel/mutex.c index 88e1bfd793f..45d25abfd9b 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -87,7 +87,7 @@ u32_t _handler_k_mutex_init(u32_t mutex, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(mutex, K_OBJ_MUTEX, 1, ssf); + _SYSCALL_OBJ_INIT(mutex, K_OBJ_MUTEX, ssf); _impl_k_mutex_init((struct k_mutex *)mutex); return 0; @@ -208,7 +208,7 @@ u32_t _handler_k_mutex_lock(u32_t mutex, u32_t timeout, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(mutex, K_OBJ_MUTEX, 0, ssf); + _SYSCALL_OBJ(mutex, K_OBJ_MUTEX, ssf); return _impl_k_mutex_lock((struct k_mutex *)mutex, (s32_t)timeout); } #endif @@ -272,7 +272,7 @@ u32_t _handler_k_mutex_unlock(u32_t mutex, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(mutex, K_OBJ_MUTEX, 0, ssf); + _SYSCALL_OBJ(mutex, K_OBJ_MUTEX, ssf); _impl_k_mutex_unlock((struct k_mutex *)mutex); return 0; } diff --git a/kernel/pipes.c b/kernel/pipes.c index 2fa44ad3b34..13da5f2575f 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -146,8 +146,8 @@ u32_t _handler_k_pipe_init(u32_t pipe, u32_t buffer, u32_t size, { _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(pipe, K_OBJ_PIPE, 1, ssf); - _SYSCALL_MEMORY(buffer, size, 1, ssf); + _SYSCALL_OBJ_INIT(pipe, K_OBJ_PIPE, ssf); + _SYSCALL_MEMORY_WRITE(buffer, size, ssf); _impl_k_pipe_init((struct k_pipe *)pipe, (unsigned char *)buffer, size); @@ -694,9 +694,9 @@ u32_t _handler_k_pipe_get(u32_t pipe, u32_t data, u32_t bytes_to_read, size_t *bytes_read = (size_t *)bytes_read_p; size_t min_xfer = (size_t)min_xfer_p; - _SYSCALL_IS_OBJ(pipe, K_OBJ_PIPE, 0, ssf); - _SYSCALL_MEMORY(bytes_read, sizeof(*bytes_read), 1, ssf); - _SYSCALL_MEMORY((void *)data, bytes_to_read, 1, ssf); + _SYSCALL_OBJ(pipe, K_OBJ_PIPE, ssf); + _SYSCALL_MEMORY_WRITE(bytes_read, sizeof(*bytes_read), ssf); + _SYSCALL_MEMORY_WRITE((void *)data, bytes_to_read, ssf); _SYSCALL_VERIFY(min_xfer <= bytes_to_read, ssf); return _impl_k_pipe_get((struct k_pipe *)pipe, (void *)data, @@ -724,9 +724,9 @@ u32_t _handler_k_pipe_put(u32_t pipe, u32_t data, u32_t bytes_to_write, size_t *bytes_written = (size_t *)bytes_written_p; size_t min_xfer = (size_t)min_xfer_p; - _SYSCALL_IS_OBJ(pipe, K_OBJ_PIPE, 0, ssf); - _SYSCALL_MEMORY(bytes_written, sizeof(*bytes_written), 1, ssf); - _SYSCALL_MEMORY((void *)data, bytes_to_write, 0, ssf); + _SYSCALL_OBJ(pipe, K_OBJ_PIPE, ssf); + _SYSCALL_MEMORY_WRITE(bytes_written, sizeof(*bytes_written), ssf); + _SYSCALL_MEMORY_READ((void *)data, bytes_to_write, ssf); _SYSCALL_VERIFY(min_xfer <= bytes_to_write, ssf); return _impl_k_pipe_put((struct k_pipe *)pipe, (void *)data, diff --git a/kernel/sched.c b/kernel/sched.c index fdb0cef7405..aed2e164e22 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -273,7 +273,7 @@ u32_t _handler_k_thread_priority_get(u32_t arg1, u32_t arg2, u32_t arg3, _SYSCALL_ARG1; thread = (struct k_thread *)arg1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); return (u32_t)_impl_k_thread_priority_get(thread); } #endif @@ -301,8 +301,9 @@ u32_t _handler_k_thread_priority_set(u32_t thread, u32_t prio, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); - _SYSCALL_VERIFY(_VALID_PRIO(prio, NULL), ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); + _SYSCALL_VERIFY_MSG(_VALID_PRIO(prio, NULL), ssf, + "invalid thread priority %d", (int)prio); _impl_k_thread_priority_set((k_tid_t)thread, prio); return 0; } @@ -399,7 +400,8 @@ u32_t _handler_k_sleep(u32_t arg1, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_VERIFY(arg1 != K_FOREVER, ssf); + _SYSCALL_VERIFY_MSG(arg1 != K_FOREVER, ssf, + "sleeping forever not allowed"); _impl_k_sleep(arg1); return 0; @@ -436,7 +438,7 @@ u32_t _handler_k_wakeup(u32_t thread, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); _impl_k_wakeup((k_tid_t)thread); return 0; } diff --git a/kernel/sem.c b/kernel/sem.c index d62b545cb51..1f9652e3d8f 100644 --- a/kernel/sem.c +++ b/kernel/sem.c @@ -76,7 +76,7 @@ u32_t _handler_k_sem_init(u32_t sem_ptr, u32_t initial_count, u32_t limit, { _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(sem_ptr, K_OBJ_SEM, 1, ssf); + _SYSCALL_OBJ_INIT(sem_ptr, K_OBJ_SEM, ssf); _SYSCALL_VERIFY(limit != 0, ssf); _impl_k_sem_init((struct k_sem *)sem_ptr, initial_count, limit); return 0; @@ -161,7 +161,7 @@ u32_t _handler_k_sem_give(u32_t sem_ptr, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(sem_ptr, K_OBJ_SEM, 0, ssf); + _SYSCALL_OBJ(sem_ptr, K_OBJ_SEM, ssf); _impl_k_sem_give((struct k_sem *)sem_ptr); return 0; @@ -196,7 +196,7 @@ u32_t _handler_k_sem_take(u32_t sem_ptr, u32_t timeout, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(sem_ptr, K_OBJ_SEM, 0, ssf); + _SYSCALL_OBJ(sem_ptr, K_OBJ_SEM, ssf); return _impl_k_sem_take((struct k_sem *)sem_ptr, timeout); } @@ -205,7 +205,7 @@ u32_t _handler_k_sem_reset(u32_t sem_ptr, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(sem_ptr, K_OBJ_SEM, 0, ssf); + _SYSCALL_OBJ(sem_ptr, K_OBJ_SEM, ssf); _impl_k_sem_reset((struct k_sem *)sem_ptr); return 0; @@ -216,7 +216,7 @@ u32_t _handler_k_sem_count_get(u32_t sem_ptr, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(sem_ptr, K_OBJ_SEM, 0, ssf); + _SYSCALL_OBJ(sem_ptr, K_OBJ_SEM, ssf); return _impl_k_sem_count_get((struct k_sem *)sem_ptr); } #endif /* CONFIG_USERSPACE */ diff --git a/kernel/stack.c b/kernel/stack.c index ea7c9373283..99708fb7e26 100644 --- a/kernel/stack.c +++ b/kernel/stack.c @@ -63,8 +63,8 @@ u32_t _handler_k_stack_init(u32_t stack, u32_t buffer, u32_t num_entries_p, /* FIXME why is 'num_entries' signed?? */ _SYSCALL_VERIFY(num_entries > 0, ssf); - _SYSCALL_IS_OBJ(stack, K_OBJ_STACK, 1, ssf); - _SYSCALL_MEMORY(buffer, num_entries * sizeof(u32_t), 1, ssf); + _SYSCALL_OBJ_INIT(stack, K_OBJ_STACK, ssf); + _SYSCALL_MEMORY_WRITE(buffer, num_entries * sizeof(u32_t), ssf); _impl_k_stack_init((struct k_stack *)stack, (u32_t *)buffer, num_entries); @@ -109,8 +109,8 @@ u32_t _handler_k_stack_push(u32_t stack_p, u32_t data, u32_t arg3, struct k_stack *stack = (struct k_stack *)stack_p; _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(stack, K_OBJ_STACK, 0, ssf); - _SYSCALL_VERIFY(stack->next != stack->top, ssf); + _SYSCALL_OBJ(stack, K_OBJ_STACK, ssf); + _SYSCALL_VERIFY_MSG(stack->next != stack->top, ssf, "stack is full"); _impl_k_stack_push(stack, data); return 0; @@ -151,8 +151,8 @@ u32_t _handler_k_stack_pop(u32_t stack, u32_t data, u32_t timeout, { _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(stack, K_OBJ_STACK, 0, ssf); - _SYSCALL_MEMORY(data, sizeof(u32_t), 1, ssf); + _SYSCALL_OBJ(stack, K_OBJ_STACK, ssf); + _SYSCALL_MEMORY_WRITE(data, sizeof(u32_t), ssf); return _impl_k_stack_pop((struct k_stack *)stack, (u32_t *)data, timeout); diff --git a/kernel/thread.c b/kernel/thread.c index a933fc7a849..d804281fc6b 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -264,7 +264,7 @@ u32_t _handler_k_thread_start(u32_t thread, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); _impl_k_thread_start((struct k_thread *)thread); return 0; } @@ -352,7 +352,7 @@ u32_t _handler_k_thread_cancel(u32_t thread, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); return _impl_k_thread_cancel((struct k_thread *)thread); } #endif @@ -433,7 +433,7 @@ u32_t _handler_k_thread_suspend(u32_t thread, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); _impl_k_thread_suspend((k_tid_t)thread); return 0; } @@ -463,7 +463,7 @@ u32_t _handler_k_thread_resume(u32_t thread, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); _impl_k_thread_resume((k_tid_t)thread); return 0; } diff --git a/kernel/thread_abort.c b/kernel/thread_abort.c index 97170e3c6aa..8c61b6d106d 100644 --- a/kernel/thread_abort.c +++ b/kernel/thread_abort.c @@ -51,8 +51,9 @@ u32_t _handler_k_thread_abort(u32_t thread_p, u32_t arg2, u32_t arg3, u32_t arg4, u32_t arg5, u32_t arg6, void *ssf) { struct k_thread *thread = (struct k_thread *)thread_p; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); - _SYSCALL_VERIFY(!(thread->base.user_options & K_ESSENTIAL), ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); + _SYSCALL_VERIFY_MSG(!(thread->base.user_options & K_ESSENTIAL), ssf, + "aborting essential thread %p", thread); _impl_k_thread_abort((struct k_thread *)thread); return 0; diff --git a/kernel/timer.c b/kernel/timer.c index f04cce14c6e..a5bf51b3cde 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -143,7 +143,7 @@ u32_t _handler_k_timer_start(u32_t timer, u32_t duration_p, u32_t period_p, _SYSCALL_VERIFY(duration >= 0 && period >= 0 && (duration != 0 || period != 0), ssf); - _SYSCALL_IS_OBJ(timer, K_OBJ_TIMER, 0, ssf); + _SYSCALL_OBJ(timer, K_OBJ_TIMER, ssf); _impl_k_timer_start((struct k_timer *)timer, duration, period); return 0; } @@ -184,7 +184,7 @@ u32_t _handler_k_timer_stop(u32_t timer, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(timer, K_OBJ_TIMER, 0, ssf); + _SYSCALL_OBJ(timer, K_OBJ_TIMER, ssf); _impl_k_timer_stop((struct k_timer *)timer); return 0; } @@ -208,7 +208,7 @@ u32_t _handler_k_timer_status_get(u32_t timer, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(timer, K_OBJ_TIMER, 0, ssf); + _SYSCALL_OBJ(timer, K_OBJ_TIMER, ssf); return _impl_k_timer_status_get((struct k_timer *)timer); } #endif @@ -249,7 +249,7 @@ u32_t _handler_k_timer_status_sync(u32_t timer, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(timer, K_OBJ_TIMER, 0, ssf); + _SYSCALL_OBJ(timer, K_OBJ_TIMER, ssf); return _impl_k_timer_status_sync((struct k_timer *)timer); } #endif diff --git a/kernel/userspace_handler.c b/kernel/userspace_handler.c index 8e4542b4c17..0dbd8601327 100644 --- a/kernel/userspace_handler.c +++ b/kernel/userspace_handler.c @@ -18,7 +18,7 @@ u32_t _handler_k_object_access_grant(u32_t object, u32_t thread, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf); + _SYSCALL_OBJ(thread, K_OBJ_THREAD, ssf); _impl_k_object_access_grant((void *)object, (struct k_thread *)thread); return 0; } diff --git a/subsys/driver_handlers/sensor.c b/subsys/driver_handlers/sensor.c index e6f4fc2e412..97a7cea132f 100644 --- a/subsys/driver_handlers/sensor.c +++ b/subsys/driver_handlers/sensor.c @@ -12,8 +12,8 @@ u32_t _handler_sensor_attr_set(u32_t dev, u32_t chan, u32_t attr, { _SYSCALL_ARG4; - _SYSCALL_IS_OBJ(dev, K_OBJ_DRIVER_SENSOR, 0, ssf); - _SYSCALL_MEMORY(val, sizeof(struct sensor_value), 0, ssf); + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_SENSOR, ssf); + _SYSCALL_MEMORY_READ(val, sizeof(struct sensor_value), ssf); return _impl_sensor_attr_set((struct device *)dev, chan, attr, (const struct sensor_value *)val); } @@ -24,7 +24,7 @@ u32_t _handler_sensor_sample_fetch(u32_t dev, u32_t arg2, u32_t arg3, { _SYSCALL_ARG1; - _SYSCALL_IS_OBJ(dev, K_OBJ_DRIVER_SENSOR, 0, ssf); + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_SENSOR, ssf); return _impl_sensor_sample_fetch((struct device *)dev); } @@ -35,7 +35,7 @@ u32_t _handler_sensor_sample_fetch_chan(u32_t dev, u32_t type, u32_t arg3, { _SYSCALL_ARG2; - _SYSCALL_IS_OBJ(dev, K_OBJ_DRIVER_SENSOR, 0, ssf); + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_SENSOR, ssf); return _impl_sensor_sample_fetch_chan((struct device *)dev, type); } @@ -45,8 +45,8 @@ u32_t _handler_sensor_channel_get(u32_t dev, u32_t chan, u32_t val, { _SYSCALL_ARG3; - _SYSCALL_IS_OBJ(dev, K_OBJ_DRIVER_SENSOR, 0, ssf); - _SYSCALL_MEMORY(val, sizeof(struct sensor_value), 1, ssf); + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_SENSOR, ssf); + _SYSCALL_MEMORY_WRITE(val, sizeof(struct sensor_value), ssf); return _impl_sensor_channel_get((struct device *)dev, chan, (struct sensor_value *)val); }