1 /*
2  * Copyright (c) 2017 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CORE_H_
7 #define ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CORE_H_
8 
9 #include <zephyr/kernel.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 
16 typedef struct {
17 	k_thread_entry_t entry_point;
18 	void *arg1;
19 	void *arg2;
20 	void *arg3;
21 
22 	int thread_idx;
23 
24 #if defined(CONFIG_ARCH_HAS_THREAD_ABORT)
25 	/* The kernel may indicate that a thread has been aborted several */
26 	/* times */
27 	int aborted;
28 #endif
29 
30 	/*
31 	 * Note: If more elements are added to this structure, remember to
32 	 * update ARCH_POSIX_RECOMMENDED_STACK_SIZE in the configuration.
33 	 *
34 	 * Currently there are 4 pointers + 2 ints, on a 32-bit native posix
35 	 * implementation this will result in 24 bytes ( 4*4 + 2*4).
36 	 * For a 64-bit implementation the recommended stack size will be
37 	 * 40 bytes ( 4*8 + 2*4 ).
38 	 */
39 } posix_thread_status_t;
40 
41 
42 void posix_irq_check_idle_exit(void);
43 void posix_arch_init(void);
44 void posix_arch_clean_up(void);
45 void posix_swap(int next_allowed_thread_nbr, int this_th_nbr);
46 void posix_main_thread_start(int next_allowed_thread_nbr);
47 int posix_new_thread(void *payload);
48 void posix_abort_thread(int thread_idx);
49 int posix_arch_get_unique_thread_id(int thread_idx);
50 int posix_arch_thread_name_set(int thread_idx, const char *str);
51 
52 #ifndef POSIX_ARCH_DEBUG_PRINTS
53 #define POSIX_ARCH_DEBUG_PRINTS 0
54 #endif
55 
56 #if POSIX_ARCH_DEBUG_PRINTS
57 #define PC_DEBUG(fmt, ...) posix_print_trace("POSIX arch core:" fmt, __VA_ARGS__)
58 #else
59 #define PC_DEBUG(...)
60 #endif
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* ZEPHYR_ARCH_POSIX_INCLUDE_POSIX_CORE_H_ */
67