Clean up comments and visibility
This commit is contained in:
parent
bb279e6313
commit
6e6465942c
|
|
@ -6,44 +6,43 @@ use crate::task::TaskContextApi;
|
|||
|
||||
core::arch::global_asm!(include_str!("switch.S"));
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub(crate) struct TaskContext {
|
||||
pub regs: CalleeRegs,
|
||||
pub ra: usize,
|
||||
regs: CalleeRegs,
|
||||
ra: usize,
|
||||
}
|
||||
|
||||
impl TaskContext {
|
||||
/// Creates a new `TaskContext`.
|
||||
pub(crate) const fn new() -> Self {
|
||||
TaskContext {
|
||||
regs: CalleeRegs::new(),
|
||||
ra: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Callee-saved registers.
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct CalleeRegs {
|
||||
/// sp
|
||||
pub sp: usize,
|
||||
/// fp
|
||||
pub fp: usize,
|
||||
/// s0
|
||||
pub s0: usize,
|
||||
/// s1
|
||||
pub s1: usize,
|
||||
/// s2
|
||||
pub s2: usize,
|
||||
/// s3
|
||||
pub s3: usize,
|
||||
/// s4
|
||||
pub s4: usize,
|
||||
/// s5
|
||||
pub s5: usize,
|
||||
/// s6
|
||||
pub s6: usize,
|
||||
/// s7
|
||||
pub s7: usize,
|
||||
/// s8
|
||||
pub s8: usize,
|
||||
struct CalleeRegs {
|
||||
sp: usize,
|
||||
fp: usize,
|
||||
s0: usize,
|
||||
s1: usize,
|
||||
s2: usize,
|
||||
s3: usize,
|
||||
s4: usize,
|
||||
s5: usize,
|
||||
s6: usize,
|
||||
s7: usize,
|
||||
s8: usize,
|
||||
}
|
||||
|
||||
impl CalleeRegs {
|
||||
/// Creates new `CalleeRegs`
|
||||
pub const fn new() -> Self {
|
||||
/// Creates a new `CalleeRegs`.
|
||||
pub(self) const fn new() -> Self {
|
||||
CalleeRegs {
|
||||
sp: 0,
|
||||
fp: 0,
|
||||
|
|
@ -60,15 +59,6 @@ impl CalleeRegs {
|
|||
}
|
||||
}
|
||||
|
||||
impl TaskContext {
|
||||
pub const fn new() -> Self {
|
||||
TaskContext {
|
||||
regs: CalleeRegs::new(),
|
||||
ra: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TaskContextApi for TaskContext {
|
||||
fn set_instruction_pointer(&mut self, ip: usize) {
|
||||
self.ra = ip;
|
||||
|
|
|
|||
|
|
@ -6,48 +6,45 @@ use crate::task::TaskContextApi;
|
|||
|
||||
core::arch::global_asm!(include_str!("switch.S"));
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub(crate) struct TaskContext {
|
||||
pub regs: CalleeRegs,
|
||||
pub pc: usize,
|
||||
regs: CalleeRegs,
|
||||
ra: usize,
|
||||
}
|
||||
|
||||
impl TaskContext {
|
||||
/// Creates a new `TaskContext`.
|
||||
pub(crate) const fn new() -> Self {
|
||||
TaskContext {
|
||||
regs: CalleeRegs::new(),
|
||||
ra: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Callee-saved registers.
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct CalleeRegs {
|
||||
/// sp
|
||||
pub sp: u64,
|
||||
/// s0
|
||||
pub s0: u64,
|
||||
/// s1
|
||||
pub s1: u64,
|
||||
/// s2
|
||||
pub s2: u64,
|
||||
/// s3
|
||||
pub s3: u64,
|
||||
/// s4
|
||||
pub s4: u64,
|
||||
/// s5
|
||||
pub s5: u64,
|
||||
/// s6
|
||||
pub s6: u64,
|
||||
/// s7
|
||||
pub s7: u64,
|
||||
/// s8
|
||||
pub s8: u64,
|
||||
/// s9
|
||||
pub s9: u64,
|
||||
/// s10
|
||||
pub s10: u64,
|
||||
/// s11
|
||||
pub s11: u64,
|
||||
struct CalleeRegs {
|
||||
sp: u64,
|
||||
s0: u64,
|
||||
s1: u64,
|
||||
s2: u64,
|
||||
s3: u64,
|
||||
s4: u64,
|
||||
s5: u64,
|
||||
s6: u64,
|
||||
s7: u64,
|
||||
s8: u64,
|
||||
s9: u64,
|
||||
s10: u64,
|
||||
s11: u64,
|
||||
}
|
||||
|
||||
impl CalleeRegs {
|
||||
/// Creates new `CalleeRegs`
|
||||
pub const fn new() -> Self {
|
||||
/// Creates a new `CalleeRegs`.
|
||||
pub(self) const fn new() -> Self {
|
||||
CalleeRegs {
|
||||
sp: 0,
|
||||
s0: 0,
|
||||
|
|
@ -66,18 +63,9 @@ impl CalleeRegs {
|
|||
}
|
||||
}
|
||||
|
||||
impl TaskContext {
|
||||
pub const fn new() -> Self {
|
||||
TaskContext {
|
||||
regs: CalleeRegs::new(),
|
||||
pc: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TaskContextApi for TaskContext {
|
||||
fn set_instruction_pointer(&mut self, ip: usize) {
|
||||
self.pc = ip;
|
||||
self.ra = ip;
|
||||
}
|
||||
|
||||
fn set_stack_pointer(&mut self, sp: usize) {
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ use crate::task::TaskContextApi;
|
|||
|
||||
core::arch::global_asm!(include_str!("switch.S"));
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub(crate) struct TaskContext {
|
||||
pub regs: CalleeRegs,
|
||||
pub rip: usize,
|
||||
pub fsbase: usize,
|
||||
regs: CalleeRegs,
|
||||
rip: usize,
|
||||
fsbase: usize,
|
||||
}
|
||||
|
||||
impl TaskContext {
|
||||
pub const fn new() -> Self {
|
||||
pub(crate) const fn new() -> Self {
|
||||
Self {
|
||||
regs: CalleeRegs::new(),
|
||||
rip: 0,
|
||||
|
|
@ -25,28 +25,21 @@ impl TaskContext {
|
|||
}
|
||||
|
||||
/// Callee-saved registers.
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct CalleeRegs {
|
||||
/// RSP
|
||||
pub rsp: u64,
|
||||
/// RBX
|
||||
pub rbx: u64,
|
||||
/// RBP
|
||||
pub rbp: u64,
|
||||
/// R12
|
||||
pub r12: u64,
|
||||
/// R13
|
||||
pub r13: u64,
|
||||
/// R14
|
||||
pub r14: u64,
|
||||
/// R15
|
||||
pub r15: u64,
|
||||
struct CalleeRegs {
|
||||
rsp: u64,
|
||||
rbx: u64,
|
||||
rbp: u64,
|
||||
r12: u64,
|
||||
r13: u64,
|
||||
r14: u64,
|
||||
r15: u64,
|
||||
}
|
||||
|
||||
impl CalleeRegs {
|
||||
/// Creates new `CalleeRegs`
|
||||
pub const fn new() -> Self {
|
||||
pub(self) const fn new() -> Self {
|
||||
CalleeRegs {
|
||||
rsp: 0,
|
||||
rbx: 0,
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ impl TaskOptions {
|
|||
|
||||
let kstack = KernelStack::new_with_guard_page()?;
|
||||
|
||||
let mut ctx = TaskContext::default();
|
||||
let mut ctx = TaskContext::new();
|
||||
ctx.set_instruction_pointer(kernel_task_entry as usize);
|
||||
// We should reserve space for the return address in the stack, otherwise
|
||||
// we will write across the page boundary due to the implementation of
|
||||
|
|
|
|||
Loading…
Reference in New Issue