Adds syscall for sleep and print and makes process work in user mode
This commit is contained in:
@@ -20,15 +20,15 @@ pub enum ProcessState {
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct ExecutionContext {
|
||||
pub ra: *const usize,
|
||||
pub sp: *const usize,
|
||||
pub gp: usize,
|
||||
pub tp: usize,
|
||||
pub a: [usize; 8],
|
||||
pub t: [usize; 7],
|
||||
pub s: [usize; 12],
|
||||
pub mepc: *const usize,
|
||||
pub mstatus: usize,
|
||||
pub ra: *const u64,
|
||||
pub sp: *const u64,
|
||||
pub gp: u64,
|
||||
pub tp: u64,
|
||||
pub a: [u64; 8],
|
||||
pub t: [u64; 7],
|
||||
pub s: [u64; 12],
|
||||
pub mepc: *const u64,
|
||||
pub mstatus: u64,
|
||||
}
|
||||
|
||||
pub struct Process {
|
||||
@@ -37,8 +37,7 @@ pub struct Process {
|
||||
pub state: ProcessState,
|
||||
pub wake_time: Duration,
|
||||
pub ctx: ExecutionContext,
|
||||
pub entry_point: Option<extern "C" fn()>,
|
||||
pub stack: [usize; STACK_SIZE],
|
||||
pub stack: [u64; STACK_SIZE],
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for Process {
|
||||
@@ -49,7 +48,6 @@ impl core::fmt::Debug for Process {
|
||||
.field("state", &self.state)
|
||||
.field("wake_time", &self.wake_time)
|
||||
.field("ctx", &self.ctx)
|
||||
.field("entry_point", &self.entry_point)
|
||||
.field("stack", &format!("[_; {}]", STACK_SIZE))
|
||||
.finish()
|
||||
}
|
||||
@@ -71,10 +69,9 @@ pub fn create_processus<T: Into<String>>(code: extern "C" fn(), name: T) -> i64
|
||||
PROCESS_TABLE[next_pid].pid = next_pid as i64;
|
||||
PROCESS_TABLE[next_pid].name = name.into();
|
||||
PROCESS_TABLE[next_pid].state = ProcessState::Activable;
|
||||
PROCESS_TABLE[next_pid].entry_point = Some(code);
|
||||
PROCESS_TABLE[next_pid].ctx.a[0] = code as usize;
|
||||
PROCESS_TABLE[next_pid].ctx.a[0] = code as usize as u64;
|
||||
PROCESS_TABLE[next_pid].ctx.mepc = processus_launcher as *const _;
|
||||
PROCESS_TABLE[next_pid].ctx.mstatus = 1 << 11;
|
||||
PROCESS_TABLE[next_pid].ctx.mstatus = 1 << 1 | 1 << 5;
|
||||
PROCESS_TABLE[next_pid].ctx.sp = &raw const PROCESS_TABLE[next_pid].stack[STACK_SIZE - 1];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user