Fix CLOCK_FREQ.

This commit is contained in:
Yifan Wu 2021-01-30 14:21:40 +08:00
parent 375b787434
commit 588ea619ab
2 changed files with 4 additions and 4 deletions

View file

@ -12,4 +12,4 @@ pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE;
pub const CLOCK_FREQ: usize = 403000000 / 62; pub const CLOCK_FREQ: usize = 403000000 / 62;
#[cfg(feature = "board_qemu")] #[cfg(feature = "board_qemu")]
pub const CPU_FREQ: usize = 12500000; pub const CLOCK_FREQ: usize = 12500000;

View file

@ -1,6 +1,6 @@
use riscv::register::time; use riscv::register::time;
use crate::sbi::set_timer; use crate::sbi::set_timer;
use crate::config::CPU_FREQ; use crate::config::CLOCK_FREQ;
const TICKS_PER_SEC: usize = 100; const TICKS_PER_SEC: usize = 100;
const MSEC_PER_SEC: usize = 1000; const MSEC_PER_SEC: usize = 1000;
@ -10,9 +10,9 @@ pub fn get_time() -> usize {
} }
pub fn get_time_ms() -> usize { pub fn get_time_ms() -> usize {
time::read() / (CPU_FREQ / MSEC_PER_SEC) time::read() / (CLOCK_FREQ / MSEC_PER_SEC)
} }
pub fn set_next_trigger() { pub fn set_next_trigger() {
set_timer(get_time() + CPU_FREQ / TICKS_PER_SEC); set_timer(get_time() + CLOCK_FREQ / TICKS_PER_SEC);
} }