userspace: rename _is_user_context -> k_is_user_context

This functions is being called across the tree, no reason why it should
not be a public API.

The current usage violates a few MISRA rules.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2021-03-27 12:03:18 -04:00
commit 0ec3774bde
18 changed files with 26 additions and 26 deletions

View file

@ -36,7 +36,7 @@ extern "C" {
*/
#define ARCH_EXCEPT(reason_p) do { \
if (_is_user_context()) { \
if (k_is_user_context()) { \
arch_syscall_invoke1(reason_p, \
K_SYSCALL_USER_FAULT); \
} else { \

View file

@ -262,7 +262,7 @@ static inline char z_log_minimal_level_to_char(int level)
#define __LOG(_level, _id, _filter, ...) \
do { \
if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \
bool is_user_context = _is_user_context(); \
bool is_user_context = k_is_user_context(); \
\
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
Z_LOG_TO_PRINTK(_level, __VA_ARGS__); \
@ -316,7 +316,7 @@ static inline char z_log_minimal_level_to_char(int level)
#define __LOG_HEXDUMP(_level, _id, _filter, _data, _length, _str) \
do { \
if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \
bool is_user_context = _is_user_context(); \
bool is_user_context = k_is_user_context(); \
\
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
Z_LOG_TO_PRINTK(_level, "%s", _str); \
@ -723,7 +723,7 @@ __syscall void z_log_hexdump_from_user(uint32_t src_level_val,
#define __LOG_VA(_level, _id, _filter, _str, _valist, _argnum, _strdup_action) \
do { \
if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \
bool is_user_context = _is_user_context(); \
bool is_user_context = k_is_user_context(); \
\
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
z_log_minimal_printk(_str, _valist); \

View file

@ -110,7 +110,7 @@ static ALWAYS_INLINE bool z_syscall_trap(void)
*
* @return true if the CPU is currently running with user permissions
*/
static inline bool _is_user_context(void)
static inline bool k_is_user_context(void)
{
#ifdef CONFIG_USERSPACE
return arch_is_user_context();

View file

@ -37,7 +37,7 @@ __weak void assert_post_action(const char *file, unsigned int line)
/* User threads aren't allowed to induce kernel panics; generate
* an oops instead.
*/
if (_is_user_context()) {
if (k_is_user_context()) {
k_oops();
}
#endif

View file

@ -120,7 +120,7 @@ static int char_out(int c, void *ctx_p)
#ifdef CONFIG_USERSPACE
void vprintk(const char *fmt, va_list ap)
{
if (_is_user_context()) {
if (k_is_user_context()) {
struct buf_out_context ctx = { 0 };
cbvprintf(buf_char_out, &ctx, fmt, ap);

View file

@ -278,7 +278,7 @@ static void external_log_system_showcase(void)
static void log_demo_thread(void *p1, void *p2, void *p3)
{
bool usermode = _is_user_context();
bool usermode = k_is_user_context();
k_sleep(K_MSEC(100));

View file

@ -338,7 +338,7 @@ void log_printk(const char *fmt, va_list ap)
}
};
if (_is_user_context()) {
if (k_is_user_context()) {
uint8_t str[CONFIG_LOG_PRINTK_MAX_STRING_LENGTH + 1];
vsnprintk(str, sizeof(str), fmt, ap);
@ -391,7 +391,7 @@ uint32_t log_count_args(const char *fmt)
void log_generic(struct log_msg_ids src_level, const char *fmt, va_list ap,
enum log_strdup_action strdup_action)
{
if (_is_user_context()) {
if (k_is_user_context()) {
log_generic_from_user(src_level, fmt, ap);
} else if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
(!IS_ENABLED(CONFIG_LOG_FRONTEND))) {
@ -895,7 +895,7 @@ char *log_strdup(const char *str)
int err;
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) ||
is_rodata(str) || _is_user_context()) {
is_rodata(str) || k_is_user_context()) {
return (char *)str;
}

View file

@ -156,7 +156,7 @@ static int cmd_device_list(const struct shell *shell,
}
shell_fprintf(shell, SHELL_NORMAL, " (%s)\n", state);
if (!_is_user_context()) {
if (!k_is_user_context()) {
struct cmd_device_list_visitor_context ctx = {
.shell = shell,
.buf = buf,

View file

@ -101,7 +101,7 @@ static inline void get_start_time_cyc(void)
* TC_START() in their code. But the caller thread cannot be
* in userspace.
*/
if (!_is_user_context()) {
if (!k_is_user_context()) {
tc_start_time = k_cycle_get_32();
}
}

View file

@ -137,7 +137,7 @@ void assert_post_action(const char *file, unsigned int line)
/* User threads aren't allowed to induce kernel panics; generate
* an oops instead.
*/
if (_is_user_context()) {
if (k_is_user_context()) {
k_oops();
}
#endif

View file

@ -144,7 +144,7 @@ void test_errno(void)
k_tid_t tid;
uint32_t perm = K_INHERIT_PERMS;
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}

View file

@ -1104,7 +1104,7 @@ void test_kobject_free_error(void)
{
uint32_t perm = K_INHERIT_PERMS;
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}

View file

@ -97,7 +97,7 @@ static void test_is_usermode(void)
/* Confirm that we are in fact running in user mode. */
clear_fault();
zassert_true(_is_user_context(), "thread left in kernel mode");
zassert_true(k_is_user_context(), "thread left in kernel mode");
}
/**
@ -547,7 +547,7 @@ static void test_access_after_revoke(void)
static void umode_enter_func(void)
{
zassert_true(_is_user_context(),
zassert_true(k_is_user_context(),
"Thread did not enter user mode");
}

View file

@ -95,7 +95,7 @@ static int create_negative_test_thread(int choice)
int ret;
uint32_t perm = K_INHERIT_PERMS;
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}

View file

@ -52,7 +52,7 @@ void assert_post_action(const char *file, unsigned int line)
/* User threads aren't allowed to induce kernel panics; generate
* an oops instead.
*/
if (_is_user_context()) {
if (k_is_user_context()) {
k_oops();
}
#endif

View file

@ -62,7 +62,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3)
break;
case THREAD_CREATE_NEWTHREAD_NULL:
ztest_set_fault_valid(true);
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}
@ -73,7 +73,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3)
break;
case THREAD_CREATE_STACK_NULL:
ztest_set_fault_valid(true);
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}
@ -84,7 +84,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3)
break;
case THREAD_CTEATE_STACK_SIZE_OVERFLOW:
ztest_set_fault_valid(true);
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}
k_thread_create(&test_tdata, test_stack, -1,
@ -108,7 +108,7 @@ static void create_negative_test_thread(int choice)
int ret;
uint32_t perm = K_INHERIT_PERMS;
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}

View file

@ -195,7 +195,7 @@ static int check_values(void *p1, void *p2, void *p3)
#if defined(CONFIG_USERSPACE)
TC_PRINT("Test communication in user mode thread\n");
zassert_true(_is_user_context(), "thread left in kernel mode");
zassert_true(k_is_user_context(), "thread left in kernel mode");
#endif
/* Load to local variables to avoid using volatile in assert */

View file

@ -201,7 +201,7 @@ static int run_trigger_thread(int i)
case_type = i;
if (_is_user_context()) {
if (k_is_user_context()) {
perm = perm | K_USER;
}