use riscv::register::{mcycle, mhpmcounter3, mhpmcounter4, minstret};
pub struct MCYCLE;
impl MCYCLE {
#[inline]
pub fn value(&self) -> u64 {
mcycle::read64()
}
}
pub struct MINSTRET;
impl MINSTRET {
#[inline]
pub fn value(&self) -> u64 {
minstret::read64()
}
}
pub struct MHPMCOUNTER3;
impl MHPMCOUNTER3 {
#[inline]
pub fn value(&self) -> u64 {
mhpmcounter3::read64()
}
}
pub struct MHPMCOUNTER4;
impl MHPMCOUNTER4 {
#[inline]
pub fn value(&self) -> u64 {
mhpmcounter4::read64()
}
}
pub struct PerformanceCounters {
pub mcycle: MCYCLE,
pub minstret: MINSTRET,
pub mhpmcounter3: MHPMCOUNTER3,
pub mhpmcounter4: MHPMCOUNTER4,
}
impl PerformanceCounters {
pub(crate) fn new() -> Self {
Self {
mcycle: MCYCLE,
minstret: MINSTRET,
mhpmcounter3: MHPMCOUNTER3,
mhpmcounter4: MHPMCOUNTER4,
}
}
}