1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved. 2 // 3 // SPDX-License-Identifier: BSD-3-Clause 4 5 // The functions in this file deal only with the C execution context; i.e. 6 // everything that is directly visible to the compiler. 7 // 8 // This typically includes the stack pointer, frame pointer, general-purpose 9 // registers, condition flags, and program counter. It may also include floating 10 // point and/or vector registers, where required by the architecture. 11 // 12 // This does not include control registers for guest VMs, the MMU, etc., which 13 // are switched by other modules' handlers for the context switch events. 14 15 // The default size and minimum alignment for a thread's kernel stack. 16 extern const size_t thread_stack_min_align; 17 extern const size_t thread_stack_alloc_align; 18 extern const size_t thread_stack_size_default; 19 20 // Map the kernel stack of a new thread. 21 error_t 22 thread_arch_map_stack(thread_t *thread); 23 24 // Unmap the kernel stack of a thread. 25 void 26 thread_arch_unmap_stack(thread_t *thread); 27 28 // Set up the execution context for a new thread. 29 void 30 thread_arch_init_context(thread_t *thread); 31 32 // Switch from the execution context of the current thread to some other thread. 33 // 34 // This function does not return until it is called again by some other thread, 35 // specifying this thread as an argument. At that point, it returns a pointer to 36 // the thread it switched from, which need not be the same as the thread that 37 // the original call switched to. 38 // 39 // The tick counter is the time at which the specified thread was scheduled; 40 // it is passed through to the new thread's context switch handlers to avoid a 41 // double read of the timer which can cause gaps in the time accounting and 42 // might be expensive on some platforms. On return, it is updated to be the 43 // value passed through by the previous thread. 44 thread_t * 45 thread_arch_switch_thread(thread_t *next_thread, ticks_t *schedtime); 46 47 // Set the current thread, assuming there was no previous current thread. 48 // 49 // This function is called at the end of the CPU power-on sequence. 50 noreturn void 51 thread_arch_set_thread(thread_t *next_thread) REQUIRE_PREEMPT_DISABLED; 52