#[repr(C)]pub struct TaskContext {
pub ra: usize,
pub sp: usize,
pub s: [usize; 10],
pub tp: usize,
pub pgdl: usize,
pub fpu: FpuState,
}Expand description
Saved hardware states of a task.
The context usually includes:
- Callee-saved registers
- Stack pointer register
- Thread pointer register (for thread-local storage, currently unsupported)
- 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: usizeReturn Address
sp: usizeStack Pointer
s: [usize; 10]loongArch need to save 10 static registers from $r22 to $r31
tp: usizeThread Pointer
pgdl: usizeAvailable on crate feature
uspace only.user page table root
fpu: FpuStateAvailable on crate feature
fp-simd only.Floating Point Unit states
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, pgdl: PhysAddr)
Available on crate feature uspace only.
pub fn set_page_table_root(&mut self, pgdl: PhysAddr)
uspace only.Changes the page table root in this context.
The hardware register for user page table root (pgdl for loongarch64)
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