#[repr(C)]pub struct TaskContext {}Expand description
Saved hardware states of a task.
The context usually includes:
- Callee-saved registers
- Stack pointer register
- Thread pointer register (for kernel-space thread-local storage)
- FP/SIMD registers
On context switch, current task saves its context from CPU to memory, and the next task restores its context from memory to CPU.
Fields§
§ra: usize§sp: usize§s0: usize§s1: usize§s2: usize§s3: usize§s4: usize§s5: usize§s6: usize§s7: usize§s8: usize§s9: usize§s10: usize§s11: usize§tp: usizeThread Pointer
satp: PhysAddrAvailable on crate feature
uspace only.The satp register value, i.e., the page table root.
fp_state: FpStateAvailable on crate feature
fp-simd only.Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub fn init(&mut self, entry: usize, kstack_top: VirtAddr, tls_area: VirtAddr)
pub fn init(&mut self, entry: usize, kstack_top: VirtAddr, tls_area: VirtAddr)
Initializes the context for a new task, with the given entry point and kernel stack.
Sourcepub fn set_page_table_root(&mut self, satp: PhysAddr)
Available on crate feature uspace only.
pub fn set_page_table_root(&mut self, satp: PhysAddr)
uspace only.Changes the page table root in this context.
The hardware register for page table root (satp for riscv64) will be
updated to the next task’s after Self::switch_to.
Trait Implementations§
Source§impl Debug for TaskContext
impl Debug for TaskContext
Source§impl Default for TaskContext
impl Default for TaskContext
Source§fn default() -> TaskContext
fn default() -> TaskContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TaskContext
impl RefUnwindSafe for TaskContext
impl Send for TaskContext
impl Sync for TaskContext
impl Unpin for TaskContext
impl UnsafeUnpin for TaskContext
impl UnwindSafe for TaskContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more