hardware 0.0.9

A no_std bare-metal hardware abstraction layer — all port I/O, memory and swap allocations are guarded at runtime. Do not consider this dependency stable before x.1.x
Documentation
use core::sync::atomic::{AtomicUsize, Ordering};

static TSC_MMIO: AtomicUsize = AtomicUsize::new(0);

pub fn set_tsc_mmio(addr: usize) {
    TSC_MMIO.store(addr, Ordering::Release);
}

pub fn read_tsc() -> u64 {
    let addr = TSC_MMIO.load(Ordering::Acquire);
    if addr != 0 {
        unsafe { core::ptr::read_volatile(addr as *const u64) }
    } else {
        native_rdtsc()
    }
}

fn native_rdtsc() -> u64 {
    0
}