cu29-clock 1.1.0

Copper Robot Clock implementation. It is a monotonic high precision clock for real time applications. It has a mock feature for testing time dependent behaviors. It is part of the Copper project but can be used independently.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Source: ARM generic timer virtual count register (`CNTVCT_EL0`).
// Guarantee: monotonic fixed-frequency counter when firmware/OS enables EL0
// access. The counter is system-level rather than a per-thread wall clock.
pub fn initialize() {}

#[inline(always)]
pub fn read_raw_counter() -> u64 {
    let mut counter: u64;
    // SAFETY: Reading the virtual counter register is a side-effect-free CPU instruction.
    unsafe {
        core::arch::asm!("mrs {}, cntvct_el0", out(reg) counter);
    }
    counter
}