kernel: add K_USER flag and _is_thread_user()

Indicates that the thread is configured to run in user mode.
Delete stub function in userspace.c

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-08-30 14:17:44 -07:00 committed by Andrew Boie
commit 5cfa5dc8db
3 changed files with 19 additions and 7 deletions

View file

@ -427,6 +427,11 @@ extern void k_call_stacks_analyze(void);
#define K_FP_REGS (1 << 1)
#endif
/* This thread has dropped from supervisor mode to user mode and consequently
* has additional restrictions
*/
#define K_USER (1 << 2)
#ifdef CONFIG_X86
/* x86 Bitmask definitions for threads user options */

View file

@ -516,4 +516,17 @@ static inline struct k_thread *_unpend_first_thread(_wait_q_t *wait_q)
return thread;
}
#ifdef CONFIG_USERSPACE
/**
* Indicate whether the currently running thread has been configured to be
* a user thread.
*
* @return nonzero if the current thread is a user thread, regardless of what
* mode the CPU is currently in
*/
static inline int _is_thread_user(void)
{
return _current->base.user_options & K_USER;
}
#endif /* CONFIG_USERSPACE */
#endif /* _ksched__h_ */

View file

@ -10,6 +10,7 @@
#include <misc/printk.h>
#include <kernel_structs.h>
#include <sys_io.h>
#include <ksched.h>
/**
* Kernel object validation function
@ -84,13 +85,6 @@ static int test_thread_perms(struct _k_object *ko)
return 1;
}
static int _is_thread_user(void)
{
/* STUB */
return 0;
}
void k_object_grant_access(void *object, struct k_thread *thread)
{
struct _k_object *ko = _k_object_find(object);