1 /*
2 * Copyright (c) 2020 BayLibre, SAS
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/kernel.h>
8 #include <stdio.h>
9 #define USER_STACKSIZE 2048
10
11 struct k_thread user_thread;
12 K_THREAD_STACK_DEFINE(user_stack, USER_STACKSIZE);
13
user_function(void * p1,void * p2,void * p3)14 static void user_function(void *p1, void *p2, void *p3)
15 {
16 printf("Hello World from %s (%s)\n",
17 k_is_user_context() ? "UserSpace!" : "privileged mode.",
18 CONFIG_BOARD);
19 __ASSERT(k_is_user_context(), "User mode execution was expected");
20 }
21
22
main(void)23 int main(void)
24 {
25 k_thread_create(&user_thread, user_stack, USER_STACKSIZE,
26 user_function, NULL, NULL, NULL,
27 -1, K_USER, K_MSEC(0));
28 return 0;
29 }
30