fix: use u128 for nanos in timer

This commit is contained in:
Mark Poliakov 2021-12-05 21:13:13 +02:00
parent 2985f1429e
commit 94450e6537

View File

@ -50,9 +50,11 @@ impl IntSource for GenericTimer {
impl TimestampSource for GenericTimer { impl TimestampSource for GenericTimer {
fn timestamp(&self) -> Result<Duration, Errno> { fn timestamp(&self) -> Result<Duration, Errno> {
let cnt = CNTPCT_EL0.get() * 1_000_000_000; let cnt = (CNTPCT_EL0.get() as u128) * 1_000_000_000u128;
let frq = CNTFRQ_EL0.get(); let frq = CNTFRQ_EL0.get() as u128;
Ok(Duration::from_nanos(cnt / frq)) let secs = ((cnt / frq) / 1_000_000_000) as u64;
let nanos = ((cnt / frq) % 1_000_000_000) as u32;
Ok(Duration::new(secs, nanos))
} }
} }