Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sbi-rt = { version = "0.0.2", features = ["legacy"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86 = "0.52"
x86_64 = "0.14"
x86_64 = "=0.14.10"
multiboot = "0.8.0"
x2apic = "0.4"
raw-cpuid = "11.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/timer/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Time {
}

pub fn set_next_timer() {
CNTP_TVAL_EL0.set(CNTFRQ_EL0.get() / 1000);
CNTP_TVAL_EL0.set(CNTFRQ_EL0.get() / 100);
}

pub fn init() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/timer/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub(crate) fn init_early() {
log::info!("ticks 50us: {}", ticks10ms / 10 / 20);
// lapic.set_timer_initial(ticks10ms * 0x100);
// Set 500us ticks
lapic.set_timer_initial(ticks10ms / 20);
lapic.set_timer_initial(ticks10ms * 100);
debug!("count: {}", lapic.timer_current());
// set_oneshot_timer(2000);
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/trap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum TrapType {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EscapeReason {
NoReason,
Exception(usize),
IRQ,
Timer,
SysCall,
Expand All @@ -34,6 +35,11 @@ impl Into<EscapeReason> for TrapType {
fn into(self) -> EscapeReason {
match self {
TrapType::SysCall => EscapeReason::SysCall,
TrapType::Timer => EscapeReason::Timer,
TrapType::StorePageFault(e)|
TrapType::LoadPageFault(e)|
TrapType::InstructionPageFault(e)|
TrapType::IllegalInstruction(e)=>EscapeReason::Exception(e),
_ => EscapeReason::NoReason,
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/components/trap/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bitflags! {

// 内核中断回调
#[no_mangle]
fn kernel_callback(context: &mut TrapFrame) {
fn kernel_callback(context: &mut TrapFrame) -> TrapType {
let trap_type = match context.vector as u8 {
PAGE_FAULT_VECTOR => {
let pflags = PageFaultFlags::from_bits_truncate(context.rflags as _);
Expand Down Expand Up @@ -103,6 +103,7 @@ fn kernel_callback(context: &mut TrapFrame) {
}
};
unsafe { crate::components::trap::_interrupt_for_arch(context, trap_type, 0) };
trap_type
}

#[naked]
Expand Down Expand Up @@ -347,7 +348,7 @@ unsafe extern "C" fn syscall_entry() {
mov ecx, 0xC0000100
rdmsr
mov [rsp + 15*8+4], edx
mov [rsp + 15*8], eax # push fabase
mov [rsp + 15*8], eax # push fsbase

mov ecx, 0xC0000102
rdmsr
Expand Down Expand Up @@ -404,10 +405,7 @@ pub fn run_user_task(context: &mut TrapFrame) -> EscapeReason {
unsafe { crate::components::trap::_interrupt_for_arch(context, TrapType::SysCall, 0) };
EscapeReason::SysCall
}
_ => {
kernel_callback(context);
EscapeReason::NoReason
}
_ => kernel_callback(context).into()
}
}

Expand Down