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
8use super::TaskContext;
9use core::arch::global_asm;
10
11global_asm!(include_str!("switch.S"));
12
13unsafe extern "C" {
14 /// Switch to the context of `next_task_cx_ptr`, saving the current context
15 /// in `current_task_cx_ptr`.
16 pub unsafe fn __switch(
17 current_task_cx_ptr: *mut TaskContext,
18 next_task_cx_ptr: *const TaskContext,
19 );
20}