添加sbi-rt库, 时钟中断设置这里,这个书里是错的也没写出来sbi_call已经不能用了, 需要用sbi-rt这个设置时钟中断

ch3
zhangxinyu 2 years ago
parent 1f093dd193
commit 2c158830bf

@ -12,3 +12,4 @@ debug=true
[dependencies] [dependencies]
riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] } riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
lazy_static = { version = "1.4.0", features = ["spin_no_std"] } lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
sbi-rt = { version = "0.0.2", features = ["legacy"] }

@ -41,5 +41,5 @@ pub fn shutdown() -> ! {
// 设置 mtimecmp 的值 // 设置 mtimecmp 的值
pub fn set_timer(timer: usize) { pub fn set_timer(timer: usize) {
sbi_call(SBI_SET_TIMER, timer, 0, 0, 0); sbi_rt::set_timer(timer as _);
} }

@ -56,7 +56,6 @@ pub fn trap_handler(trap_context: &mut TrapContext) -> &mut TrapContext {
exit_current_and_run_next(); exit_current_and_run_next();
} }
Trap::Interrupt(Interrupt::SupervisorTimer) => { Trap::Interrupt(Interrupt::SupervisorTimer) => {
println!("Clock interrupt Clock interrupt Clock interrupt Clock interrupt");
// 发生时钟中断之后, 继续设置下一个时钟中断的发起时间 // 发生时钟中断之后, 继续设置下一个时钟中断的发起时间
set_next_trigger(); set_next_trigger();
// 暂停当前任务, 切换新的任务 // 暂停当前任务, 切换新的任务

Loading…
Cancel
Save