From 24151b92118cd3a43ed15d6ee1f6eb3d18426ef4 Mon Sep 17 00:00:00 2001 From: Yifan Wu Date: Sat, 30 Jan 2021 14:16:48 +0800 Subject: [PATCH] Fix CLOCK_FREQ. --- os/src/config.rs | 2 +- os/src/timer.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os/src/config.rs b/os/src/config.rs index 8d543ff9..8350d205 100644 --- a/os/src/config.rs +++ b/os/src/config.rs @@ -12,4 +12,4 @@ pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE; pub const CLOCK_FREQ: usize = 403000000 / 62; #[cfg(feature = "board_qemu")] -pub const CPU_FREQ: usize = 12500000; \ No newline at end of file +pub const CLOCK_FREQ: usize = 12500000; \ No newline at end of file diff --git a/os/src/timer.rs b/os/src/timer.rs index 612d51af..92d50e3a 100644 --- a/os/src/timer.rs +++ b/os/src/timer.rs @@ -1,6 +1,6 @@ use riscv::register::time; use crate::sbi::set_timer; -use crate::config::CPU_FREQ; +use crate::config::CLOCK_FREQ; const TICKS_PER_SEC: usize = 100; const MSEC_PER_SEC: usize = 1000; @@ -10,9 +10,9 @@ pub fn get_time() -> 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() { - set_timer(get_time() + CPU_FREQ / TICKS_PER_SEC); + set_timer(get_time() + CLOCK_FREQ / TICKS_PER_SEC); } \ No newline at end of file