1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
//! Implementations for the MIPS architecture.
use gdbstub::arch::Arch;
pub mod reg;
/// MIPS-specific breakpoint kinds.
///
/// Extracted from the GDB documentation at
/// [E.5.1.1 MIPS Breakpoint Kinds](https://sourceware.org/gdb/current/onlinedocs/gdb/MIPS-Breakpoint-Kinds.html#MIPS-Breakpoint-Kinds)
#[derive(Debug)]
pub enum MipsBreakpointKind {
/// 16-bit MIPS16 mode breakpoint.
Mips16,
/// 16-bit microMIPS mode breakpoint.
MicroMips16,
/// 32-bit standard MIPS mode breakpoint.
Mips32,
/// 32-bit microMIPS mode breakpoint.
MicroMips32,
}
impl gdbstub::arch::BreakpointKind for MipsBreakpointKind {
fn from_usize(kind: usize) -> Option<Self> {
let kind = match kind {
2 => MipsBreakpointKind::Mips16,
3 => MipsBreakpointKind::MicroMips16,
4 => MipsBreakpointKind::Mips32,
5 => MipsBreakpointKind::MicroMips32,
_ => return None,
};
Some(kind)
}
}
/// Implements `Arch` for 32-bit MIPS.
pub enum Mips {}
/// Implements `Arch` for 32-bit MIPS, with the DSP feature enabled.
pub enum MipsWithDsp {}
/// Implements `Arch` for 64-bit MIPS.
///
/// **NOTE:** Due to GDB client behavior, this arch does _not_ include a
/// built-in `target.xml` implementation. Consider manually implementing
/// [`TargetDescriptionXmlOverride`].
///
/// See [daniel5151/gdbstub#97](https://github.com/daniel5151/gdbstub/issues/97).
///
/// [`TargetDescriptionXmlOverride`]: gdbstub::target::ext::target_description_xml_override::TargetDescriptionXmlOverride
pub enum Mips64 {}
/// Implements `Arch` for 64-bit MIPS, with the DSP feature enabled.
///
/// **NOTE:** Due to GDB client behavior, this arch does _not_ include a
/// built-in `target.xml` implementation. Consider manually implementing
/// [`TargetDescriptionXmlOverride`].
///
/// See [daniel5151/gdbstub#97](https://github.com/daniel5151/gdbstub/issues/97).
///
/// [`TargetDescriptionXmlOverride`]: gdbstub::target::ext::target_description_xml_override::TargetDescriptionXmlOverride
pub enum Mips64WithDsp {}
impl Arch for Mips {
type Usize = u32;
type Registers = reg::MipsCoreRegs<u32>;
type RegId = reg::id::MipsRegId<u32>;
type BreakpointKind = MipsBreakpointKind;
fn target_description_xml() -> Option<&'static str> {
Some(r#"<target version="1.0"><architecture>mips</architecture></target>"#)
}
}
impl Arch for MipsWithDsp {
type Usize = u32;
type Registers = reg::MipsCoreRegsWithDsp<u32>;
type RegId = reg::id::MipsRegId<u32>;
type BreakpointKind = MipsBreakpointKind;
fn target_description_xml() -> Option<&'static str> {
Some(
r#"<target version="1.0"><architecture>mips</architecture><feature name="org.gnu.gdb.mips.dsp"></feature></target>"#,
)
}
}
#[allow(deprecated)]
impl Arch for Mips64 {
type Usize = u64;
type Registers = reg::MipsCoreRegs<u64>;
type RegId = reg::id::MipsRegId<u64>;
type BreakpointKind = MipsBreakpointKind;
fn target_description_xml() -> Option<&'static str> {
None
}
}
#[allow(deprecated)]
impl Arch for Mips64WithDsp {
type Usize = u64;
type Registers = reg::MipsCoreRegsWithDsp<u64>;
type RegId = reg::id::MipsRegId<u64>;
type BreakpointKind = MipsBreakpointKind;
fn target_description_xml() -> Option<&'static str> {
None
}
}