kernel: add k_thread_access_grant()
This is a runtime counterpart to K_THREAD_ACCESS_GRANT(). This function takes a thread and a NULL-terminated list of kernel objects and runs k_object_access_grant() on each of them. This function doesn't require any special permissions and doesn't need to become a system call. __attribute__((sentinel)) added to warn users if they omit the required NULL termination. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
877f82e847
commit
e12857aabf
2 changed files with 35 additions and 0 deletions
|
@ -615,6 +615,22 @@ extern FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry,
|
||||||
void *p1, void *p2,
|
void *p1, void *p2,
|
||||||
void *p3);
|
void *p3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Grant a thread access to a NULL-terminated set of kernel objects
|
||||||
|
*
|
||||||
|
* This is a convenience function. For the provided thread, grant access to
|
||||||
|
* the remaining arguments, which must be pointers to kernel objects.
|
||||||
|
* The final argument must be a NULL.
|
||||||
|
*
|
||||||
|
* The thread object must be initialized (i.e. running). The objects don't
|
||||||
|
* need to be.
|
||||||
|
*
|
||||||
|
* @param thread Thread to grant access to objects
|
||||||
|
* @param ... NULL-terminated list of kernel object pointers
|
||||||
|
*/
|
||||||
|
extern void __attribute__((sentinel))
|
||||||
|
k_thread_access_grant(struct k_thread *thread, ...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Put the current thread to sleep.
|
* @brief Put the current thread to sleep.
|
||||||
*
|
*
|
||||||
|
|
|
@ -692,6 +692,25 @@ void _k_thread_group_leave(u32_t groups, struct k_thread *thread)
|
||||||
thread_data->init_groups &= groups;
|
thread_data->init_groups &= groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void k_thread_access_grant(struct k_thread *thread, ...)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_USERSPACE
|
||||||
|
va_list args;
|
||||||
|
va_start(args, thread);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
void *object = va_arg(args, void *);
|
||||||
|
if (object == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
k_object_access_grant(object, thread);
|
||||||
|
}
|
||||||
|
va_end(args);
|
||||||
|
#else
|
||||||
|
ARG_UNUSED(thread);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry,
|
FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry,
|
||||||
void *p1, void *p2, void *p3)
|
void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue