Skip to main content

os/task/
switch.rs

1//! Rust wrapper around `__switch`.
2//!
3//! Switching to a different task's context happens here. The actual
4//! implementation must not be in Rust and (essentially) has to be in assembly
5//! language (Do you know why?), so this module really is just a wrapper around
6//! `switch.S`.
7
8core::arch::global_asm!(include_str!("switch.S"));
9use super::TaskContext;
10
11unsafe extern "C" {
12    /// Switch to the context of `next_task_cx_ptr`, saving the current context
13    /// in `current_task_cx_ptr`.
14    pub unsafe fn __switch(
15        current_task_cx_ptr: *mut TaskContext,
16        next_task_cx_ptr: *const TaskContext,
17    );
18}