Skip to content

Commit 7a52aa8

Browse files
committed
fix ch3
1 parent 349b20f commit 7a52aa8

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

os/src/boards/qemu.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Constants used in rCore for qemu
2+
3+
pub const CLOCK_FREQ: usize = 12500000;

os/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#![feature(panic_info_message)]
2323

2424
use core::arch::global_asm;
25+
26+
#[path = "boards/qemu.rs"]
27+
mod board;
28+
2529
#[macro_use]
2630
mod console;
2731
mod config;

os/src/sbi.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ pub fn console_putchar(c: usize) {
66
sbi_rt::legacy::console_putchar(c);
77
}
88

9-
/// use sbi call to getchar from console (qemu uart handler)
10-
#[allow(unused)]
11-
pub fn console_getchar() -> usize {
12-
#[allow(deprecated)]
13-
sbi_rt::legacy::console_getchar()
9+
/// use sbi call to set timer
10+
pub fn set_timer(timer: usize) {
11+
sbi_rt::set_timer(timer as _);
1412
}
1513

1614
/// use sbi call to shutdown the kernel

os/src/task/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod task;
1717

1818
use crate::config::MAX_APP_NUM;
1919
use crate::loader::{get_num_app, init_app_cx};
20+
use crate::sbi::shutdown;
2021
use crate::sync::UPSafeCell;
2122
use lazy_static::*;
2223
use switch::__switch;
@@ -134,8 +135,7 @@ impl TaskManager {
134135
// go back to user mode
135136
} else {
136137
println!("All applications completed!");
137-
use crate::board::QEMUExit;
138-
crate::board::QEMU_EXIT_HANDLE.exit_success();
138+
shutdown(false);
139139
}
140140
}
141141
}

0 commit comments

Comments
 (0)