From 2c158830bf9fa19ae2992fab83027d9e93acea21 Mon Sep 17 00:00:00 2001 From: zhangxinyu <840317537@qq.com> Date: Wed, 24 May 2023 18:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0sbi-rt=E5=BA=93,=20=E6=97=B6?= =?UTF-8?q?=E9=92=9F=E4=B8=AD=E6=96=AD=E8=AE=BE=E7=BD=AE=E8=BF=99=E9=87=8C?= =?UTF-8?q?,=E8=BF=99=E4=B8=AA=E4=B9=A6=E9=87=8C=E6=98=AF=E9=94=99?= =?UTF-8?q?=E7=9A=84=E4=B9=9F=E6=B2=A1=E5=86=99=E5=87=BA=E6=9D=A5sbi=5Fcal?= =?UTF-8?q?l=E5=B7=B2=E7=BB=8F=E4=B8=8D=E8=83=BD=E7=94=A8=E4=BA=86,=20?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=94=A8sbi-rt=E8=BF=99=E4=B8=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=E9=92=9F=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch3/os/Cargo.toml | 3 ++- ch3/os/src/sbi.rs | 2 +- ch3/os/src/trap/mod.rs | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ch3/os/Cargo.toml b/ch3/os/Cargo.toml index dd3234d..41c18f7 100644 --- a/ch3/os/Cargo.toml +++ b/ch3/os/Cargo.toml @@ -11,4 +11,5 @@ debug=true [dependencies] riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] } -lazy_static = { version = "1.4.0", features = ["spin_no_std"] } \ No newline at end of file +lazy_static = { version = "1.4.0", features = ["spin_no_std"] } +sbi-rt = { version = "0.0.2", features = ["legacy"] } \ No newline at end of file diff --git a/ch3/os/src/sbi.rs b/ch3/os/src/sbi.rs index f1cf584..6fc22ea 100644 --- a/ch3/os/src/sbi.rs +++ b/ch3/os/src/sbi.rs @@ -41,5 +41,5 @@ pub fn shutdown() -> ! { // 设置 mtimecmp 的值 pub fn set_timer(timer: usize) { - sbi_call(SBI_SET_TIMER, timer, 0, 0, 0); + sbi_rt::set_timer(timer as _); } \ No newline at end of file diff --git a/ch3/os/src/trap/mod.rs b/ch3/os/src/trap/mod.rs index 7eadd5c..15baee0 100644 --- a/ch3/os/src/trap/mod.rs +++ b/ch3/os/src/trap/mod.rs @@ -56,7 +56,6 @@ pub fn trap_handler(trap_context: &mut TrapContext) -> &mut TrapContext { exit_current_and_run_next(); } Trap::Interrupt(Interrupt::SupervisorTimer) => { - println!("Clock interrupt Clock interrupt Clock interrupt Clock interrupt"); // 发生时钟中断之后, 继续设置下一个时钟中断的发起时间 set_next_trigger(); // 暂停当前任务, 切换新的任务