This commit is contained in:
Yifan Wu 2023-03-29 20:24:30 +08:00
parent 78d0a70221
commit 2f9711a3f1
4 changed files with 12 additions and 7 deletions

3
os/src/boards/qemu.rs Normal file
View file

@ -0,0 +1,3 @@
//! Constants used in rCore for qemu
pub const CLOCK_FREQ: usize = 12500000;

View file

@ -22,6 +22,10 @@
#![feature(panic_info_message)] #![feature(panic_info_message)]
use core::arch::global_asm; use core::arch::global_asm;
#[path = "boards/qemu.rs"]
mod board;
#[macro_use] #[macro_use]
mod console; mod console;
mod config; mod config;

View file

@ -6,11 +6,9 @@ pub fn console_putchar(c: usize) {
sbi_rt::legacy::console_putchar(c); sbi_rt::legacy::console_putchar(c);
} }
/// use sbi call to getchar from console (qemu uart handler) /// use sbi call to set timer
#[allow(unused)] pub fn set_timer(timer: usize) {
pub fn console_getchar() -> usize { sbi_rt::set_timer(timer as _);
#[allow(deprecated)]
sbi_rt::legacy::console_getchar()
} }
/// use sbi call to shutdown the kernel /// use sbi call to shutdown the kernel

View file

@ -17,6 +17,7 @@ mod task;
use crate::config::MAX_APP_NUM; use crate::config::MAX_APP_NUM;
use crate::loader::{get_num_app, init_app_cx}; use crate::loader::{get_num_app, init_app_cx};
use crate::sbi::shutdown;
use crate::sync::UPSafeCell; use crate::sync::UPSafeCell;
use lazy_static::*; use lazy_static::*;
use switch::__switch; use switch::__switch;
@ -134,8 +135,7 @@ impl TaskManager {
// go back to user mode // go back to user mode
} else { } else {
println!("All applications completed!"); println!("All applications completed!");
use crate::board::QEMUExit; shutdown(false);
crate::board::QEMU_EXIT_HANDLE.exit_success();
} }
} }
} }