1 /* SPDX-License-Identifier: GPL-2.0-only */
9 #if ENV_RAMSTAGE && CONFIG(COOP_MULTITASKING)
13 uintptr_t stack_current
;
16 void (*entry
)(void *);
21 void threads_initialize(void);
22 /* Get the base of the thread stacks.
23 * Returns pointer to CONFIG_NUM_THREADS*CONFIG_STACK_SIZE contiguous bytes
24 * aligned to CONFIG_STACK_SIZE, or NULL.
26 void *arch_get_thread_stackbase(void);
27 /* Run func(arrg) on a new thread. Return 0 on successful start of thread, < 0
28 * when thread could not be started. Note that the thread will block the
29 * current state in the boot state machine until it is complete. */
30 int thread_run(void (*func
)(void *), void *arg
);
31 /* thread_run_until is the same as thread_run() except that it blocks state
32 * transitions from occurring in the (state, seq) pair of the boot state
34 int thread_run_until(void (*func
)(void *), void *arg
,
35 boot_state_t state
, boot_state_sequence_t seq
);
36 /* Return 0 on successful yield for the given amount of time, < 0 when thread
38 int thread_yield_microseconds(unsigned int microsecs
);
40 /* Allow and prevent thread cooperation on current running thread. By default
41 * all threads are marked to be cooperative. That means a thread can yield
42 * to another thread at a pre-determined switch point. Current there is
43 * only a single place where switching may occur: a call to udelay(). */
44 void thread_cooperate(void);
45 void thread_prevent_coop(void);
47 static inline void thread_init_cpu_info_non_bsp(struct cpu_info
*ci
)
52 /* Architecture specific thread functions. */
53 asmlinkage
void switch_to_thread(uintptr_t new_stack
, uintptr_t *saved_stack
);
54 /* Set up the stack frame for a new thread so that a switch_to_thread() call
55 * will enter the thread_entry() function with arg as a parameter. The
56 * saved_stack field in the struct thread needs to be updated accordingly. */
57 void arch_prepare_thread(struct thread
*t
,
58 asmlinkage
void (*thread_entry
)(void *), void *arg
);
60 static inline void threads_initialize(void) {}
61 static inline int thread_run(void (*func
)(void *), void *arg
) { return -1; }
62 static inline int thread_yield_microseconds(unsigned int microsecs
)
66 static inline void thread_cooperate(void) {}
67 static inline void thread_prevent_coop(void) {}
69 static inline void thread_init_cpu_info_non_bsp(struct cpu_info
*ci
) { }
72 #endif /* THREAD_H_ */