123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- #ifndef ZEPHYR_KERNEL_INCLUDE_KERNEL_STRUCTS_H_
- #define ZEPHYR_KERNEL_INCLUDE_KERNEL_STRUCTS_H_
- #if !defined(_ASMLANGUAGE)
- #include <sys/atomic.h>
- #include <zephyr/types.h>
- #include <kernel/sched_priq.h>
- #include <sys/dlist.h>
- #include <sys/util.h>
- #include <sys/sys_heap.h>
- #include <arch/structs.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define _THREAD_DUMMY (BIT(0))
- #define _THREAD_PENDING (BIT(1))
- #define _THREAD_PRESTART (BIT(2))
- #define _THREAD_DEAD (BIT(3))
- #define _THREAD_SUSPENDED (BIT(4))
- #define _THREAD_ABORTING (BIT(5))
- #define _THREAD_QUEUED (BIT(7))
- #ifdef CONFIG_STACK_SENTINEL
- #define STACK_SENTINEL 0xF0F0F0F0
- #endif
- #define _NON_PREEMPT_THRESHOLD 0x0080U
- #define _PREEMPT_THRESHOLD (_NON_PREEMPT_THRESHOLD - 1U)
- #if !defined(_ASMLANGUAGE)
- struct _ready_q {
- #ifndef CONFIG_SMP
-
- struct k_thread *cache;
- #endif
- #if defined(CONFIG_SCHED_DUMB)
- sys_dlist_t runq;
- #elif defined(CONFIG_SCHED_SCALABLE)
- struct _priq_rb runq;
- #elif defined(CONFIG_SCHED_MULTIQ)
- struct _priq_mq runq;
- #endif
- };
- typedef struct _ready_q _ready_q_t;
- struct _cpu {
-
- uint32_t nested;
-
- char *irq_stack;
-
- struct k_thread *current;
-
- struct k_thread *idle_thread;
- #if (CONFIG_NUM_METAIRQ_PRIORITIES > 0) && (CONFIG_NUM_COOP_PRIORITIES > 0)
-
- struct k_thread *metairq_preempted;
- #endif
- #ifdef CONFIG_TIMESLICING
-
- int slice_ticks;
- #endif
- uint8_t id;
- #ifdef CONFIG_SMP
-
- uint8_t swap_ok;
- #endif
-
- struct _cpu_arch arch;
- };
- typedef struct _cpu _cpu_t;
- struct z_kernel {
- struct _cpu cpus[CONFIG_MP_NUM_CPUS];
- #ifdef CONFIG_PM
- int32_t idle;
- #endif
-
- struct _ready_q ready_q;
- #ifdef CONFIG_FPU_SHARING
-
-
- struct k_thread *current_fp;
- #endif
- #if defined(CONFIG_THREAD_MONITOR)
- struct k_thread *threads;
- #endif
- };
- typedef struct z_kernel _kernel_t;
- extern struct z_kernel _kernel;
- #ifdef CONFIG_SMP
- bool z_smp_cpu_mobile(void);
- #define _current_cpu ({ __ASSERT_NO_MSG(!z_smp_cpu_mobile()); \
- arch_curr_cpu(); })
- #define _current z_current_get()
- #else
- #define _current_cpu (&_kernel.cpus[0])
- #define _current _kernel.cpus[0].current
- #endif
- #ifdef CONFIG_WAITQ_SCALABLE
- typedef struct {
- struct _priq_rb waitq;
- } _wait_q_t;
- extern bool z_priq_rb_lessthan(struct rbnode *a, struct rbnode *b);
- #define Z_WAIT_Q_INIT(wait_q) { { { .lessthan_fn = z_priq_rb_lessthan } } }
- #else
- typedef struct {
- sys_dlist_t waitq;
- } _wait_q_t;
- #define Z_WAIT_Q_INIT(wait_q) { SYS_DLIST_STATIC_INIT(&(wait_q)->waitq) }
- #endif
- struct _timeout;
- typedef void (*_timeout_func_t)(struct _timeout *t);
- struct _timeout {
- sys_dnode_t node;
- _timeout_func_t fn;
- #ifdef CONFIG_TIMEOUT_64BIT
-
- int64_t dticks;
- #else
- int32_t dticks;
- #endif
- };
- #ifdef __cplusplus
- }
- #endif
- #endif
- #endif
|