Chapter3: power2/3/5 & sleep test worked on k210/qemu based on timer.

This commit is contained in:
Yifan Wu 2020-11-29 10:31:15 +08:00
parent 4590f233b5
commit 63aaa9d0a1
17 changed files with 183 additions and 82 deletions

13
os/src/timer.rs Normal file
View file

@ -0,0 +1,13 @@
use riscv::register::time;
use crate::sbi::set_timer;
use crate::config::CPU_FREQ;
const TICKS_PER_SEC: usize = 100;
pub fn get_time() -> usize {
time::read()
}
pub fn set_next_trigger() {
set_timer(get_time() + CPU_FREQ / TICKS_PER_SEC);
}