refactor process implementation

This commit is contained in:
Jianfeng Jiang
2022-12-15 14:53:43 +08:00
parent 6651a642d3
commit 7e6591aab2
14 changed files with 182 additions and 128 deletions

View File

@ -38,6 +38,21 @@ pub struct CpuContext {
/// trap information, this field is all zero when it is syscall
pub trap_information: TrapInformation,
}
impl CpuContext {
pub fn set_rax(&mut self, rax: u64) {
self.gp_regs.rax = rax;
}
pub fn set_rsp(&mut self, rsp: u64) {
self.gp_regs.rsp = rsp;
}
pub fn set_rip(&mut self, rip: u64) {
self.gp_regs.rip = rip;
}
}
#[derive(Clone, Default, Copy, Debug)]
#[repr(C)]
pub struct TrapInformation {

View File

@ -1,6 +1,5 @@
use super::{page_table::PageTable, *};
use crate::prelude::*;
use crate::vm::VmIo;
use crate::{
config::PAGE_SIZE,
mm::address::is_aligned,

View File

@ -5,7 +5,8 @@ mod scheduler;
#[allow(clippy::module_inception)]
mod task;
pub(crate) use self::processor::{get_idle_task_cx_ptr, schedule};
pub(crate) use self::processor::get_idle_task_cx_ptr;
pub use self::processor::schedule;
pub use self::scheduler::{set_scheduler, Scheduler};
pub(crate) use self::task::context_switch;
pub(crate) use self::task::TaskContext;

View File

@ -222,7 +222,7 @@ impl Task {
Ok(Arc::new(result))
}
pub fn send_to_scheduler(self: &Arc<Self>) {
pub fn run(self: &Arc<Self>) {
switch_to_task(self.clone());
}