use core::num::NonZeroUsize;
use gdbstub::arch::RegId;
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub enum ArmCoreRegId {
Gpr(u8),
Sp,
Lr,
Pc,
Fpr(u8),
Fps,
Cpsr,
}
impl RegId for ArmCoreRegId {
fn from_raw_id(id: usize) -> Option<(Self, Option<NonZeroUsize>)> {
let reg = match id {
0..=12 => Self::Gpr(id as u8),
13 => Self::Sp,
14 => Self::Lr,
15 => Self::Pc,
16..=23 => Self::Fpr((id as u8) - 16),
24 => Self::Fps,
25 => Self::Cpsr,
_ => return None,
};
Some((reg, Some(NonZeroUsize::new(4)?)))
}
}