Skip to main content

SpRegs

Struct SpRegs 

Source
pub struct SpRegs { /* private fields */ }
Expand description

The SP interface registers.

Implementations§

Source§

impl SpRegs

Source

pub const fn new() -> Self

Power-on state: halted, semaphore free.

The RSP comes out of reset halted and idles until the CPU clears the bit; n64-systemtest’s StartupTest reads SP_STATUS expecting exactly 0x1.

Source

pub const fn status(&self) -> u32

The SP_STATUS flag word, as read.

Source

pub const fn halted(&self) -> bool

Is the RSP halted?

Source

pub const fn broke(&self) -> bool

Has a BREAK executed since BROKE was last cleared? Distinct from Self::halted: a SET_HALT write halts without setting BROKE, so a consumer that wants “the microcode reached a break” must check this.

Source

pub const fn set_broke(&mut self, broke: bool)

Latch BROKE. Set by a BREAK and cleared only by a CLR_BROKE write: it remembers that a break happened, independently of run state.

Source

pub const fn set_halted(&mut self, halted: bool)

Halt or release the RSP from within the chip (a BREAK, or single-step).

Source

pub const fn pc(&self) -> u32

SP_PC.

Source

pub const fn set_pc(&mut self, pc: u32)

Set SP_PC, masked to the 12 bits IMEM has.

Source

pub const fn read(&mut self, index: u32) -> u32

Read a register by index. mi_sp is not touched here — see Self::write.

Source

pub const fn write(&mut self, index: u32, val: u32) -> Option<Dma>

Write a register by index.

Returns a Dma when the write started one — the Bus performs it, for the reason given on that type.

The SP interrupt line is not updated here. SP_STATUS can both raise and acknowledge it, so the caller reads Self::interrupt_change afterwards; returning it through the same channel as a DMA would conflate two independent effects of one write.

Source

pub const fn interrupt_change(val: u32) -> Option<bool>

What a SP_STATUS write did to the MI’s SP interrupt line.

Some(true) raises it, Some(false) acknowledges it, None leaves it alone. Separate from Self::write because the line lives in the MI, not here, and because one write can start a DMA and touch the line.

Source

pub const fn complete_dma(&mut self, sp_addr: u32, ram_addr: u32)

Record where a completed transfer left the address and length registers.

Hardware leaves the pointers past the data it moved, and the length field at 0xFF8 — it is decremented by 8 per word and ends at -8. COUNT resets to 0 and SKIP is preserved, which is why only the low field is rewritten here.

Trait Implementations§

Source§

impl Clone for SpRegs

Source§

fn clone(&self) -> SpRegs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpRegs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SpRegs

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SpRegs

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SpRegs

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for SpRegs

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,