Files
RedBear-OS/src/arch/aarch64/time.rs
T
2025-05-13 15:30:45 +08:00

12 lines
349 B
Rust

use crate::time::NANOS_PER_SEC;
pub fn monotonic_absolute() -> u128 {
//TODO: aarch64 generic timer counter
let ticks: usize;
unsafe { core::arch::asm!("mrs {}, cntpct_el0", out(reg) ticks) };
let freq: usize;
unsafe { core::arch::asm!("mrs {}, cntfrq_el0", out(reg) freq) };
ticks as u128 * NANOS_PER_SEC / freq as u128
}