diff --git a/kernel/include/syscall_handler.h b/kernel/include/syscall_handler.h index ce8526efe54..831b9c59ae8 100644 --- a/kernel/include/syscall_handler.h +++ b/kernel/include/syscall_handler.h @@ -105,6 +105,16 @@ extern void _thread_perms_clear(struct _k_object *ko, struct k_thread *thread); */ extern void _thread_perms_all_set(struct _k_object *ko); +/** + * Clear initialization state of a kernel object + * + * Intended for thread objects upon thread exit, or for other kernel objects + * that were released back to an object pool. + * + * @param object Address of the kernel object + */ +void _k_object_uninit(void *obj); + /** * @brief Runtime expression check for system call arguments * diff --git a/kernel/userspace.c b/kernel/userspace.c index 8f97957dd16..3b3abf2bad2 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -260,6 +260,19 @@ void _k_object_init(void *object) ko->flags |= K_OBJ_FLAG_INITIALIZED; } +void _k_object_uninit(void *object) +{ + struct _k_object *ko; + + /* See comments in _k_object_init() */ + ko = _k_object_find(object); + if (!ko) { + return; + } + + ko->flags &= ~K_OBJ_FLAG_INITIALIZED; +} + static u32_t _handler_bad_syscall(u32_t bad_id, u32_t arg2, u32_t arg3, u32_t arg4, u32_t arg5, u32_t arg6, void *ssf) {