riscv-etrace 0.5.2

Decoder and tracer for RISC-V efficient instruction tracing
Documentation
// Copyright (C) 2025 FZI Forschungszentrum Informatik
// SPDX-License-Identifier: Apache-2.0
//! Types not specific to [decoder][crate::decoder] or [tracer][crate::tracer]

pub mod branch;
pub mod trap;

/// RISC-V priviledge levels
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum Privilege {
    User,
    Supervisor,
    Machine,
}

impl Default for Privilege {
    fn default() -> Self {
        Self::User
    }
}

impl TryFrom<u8> for Privilege {
    type Error = u8;

    fn try_from(num: u8) -> Result<Self, Self::Error> {
        match num {
            0b00 => Ok(Self::User),
            0b01 => Ok(Self::Supervisor),
            0b11 => Ok(Self::Machine),
            err => Err(err),
        }
    }
}