Skip to main content

Dma

Struct Dma 

Source
pub struct Dma {
    pub channels: [Channel; 8],
    pub gp_enable: u8,
    pub hdma_enable: u8,
}
Expand description

The 8-channel DMA controller plus the MDMAEN/HDMAEN enables.

Fields§

§channels: [Channel; 8]

The 8 channels.

§gp_enable: u8

$420B MDMAEN — GP-DMA enable mask (write triggers the run).

§hdma_enable: u8

$420C HDMAEN — HDMA enable mask.

Implementations§

Source§

impl Dma

Source

pub fn new() -> Self

Construct a power-on DMA controller (all channels open, no transfers pending).

Source

pub fn write_reg(&mut self, ch: usize, reg: u8, val: u8)

Write a DMA channel register $43nA (or the $420B/$420C enables, handled by the bus). reg is the low byte ($00-$0A); ch is the channel index 0-7.

Source

pub fn save_state(&self, w: &mut SaveWriter)

Write all 8 channels + the MDMAEN/HDMAEN enables into a "DMA0" section.

Source

pub fn load_state( &mut self, r: &mut SaveReader<'_>, ) -> Result<(), SaveStateError>

The inverse of Self::save_state.

§Errors

SaveStateError on truncated/corrupt input or a section with unconsumed trailing bytes.

Source

pub const fn read_reg(&self, ch: usize, reg: u8) -> u8

Read a DMA channel register $43nA.

Source

pub fn run_gp(&mut self, mask: u8, bus: &mut impl DmaBus) -> u32

Run all GP-DMA channels selected by mask ($420B write) to completion. The CPU is considered halted for the whole run; the returned value is the master-clock cost (the scheduler advances the clock by it). Ported from ares Channel::dmaRun.

Source

pub fn service_hdma_line( &mut self, line: u16, vh: u16, bus: &mut impl DmaBus, ) -> u32

Service one scanline’s HDMA lifecycle: at V=0 reset the bookkeeping and load the tables, on each visible line (1..=vh) run one transfer, otherwise nothing. Returns the master-clock cost. Shared by the per-master-tick path (Bus::advance_master) and the in-GP-DMA interleave (Dma::run_gp via Self::service_hdma_during_gp) so HDMA stays scanline-accurate even while a GP-DMA is advancing the clock across line boundaries.

Source

pub fn hdma_reset(&mut self)

Reset every channel’s HDMA bookkeeping at the start of a frame (V=0). ares hdmaReset.

Source

pub fn hdma_setup(&mut self, bus: &mut impl DmaBus) -> u32

Per-frame HDMA setup: load each enabled channel’s table pointer + first line entry. Returns the master-clock cost. ares hdmaSetup + Channel::hdmaSetup/hdmaReload.

Source

pub fn hdma_run(&mut self, bus: &mut impl DmaBus) -> u32

Run one visible-scanline’s HDMA for all active channels (ares hdmaRunhdmaTransfer + hdmaAdvance). Returns the master-clock cost (the per-line budget).

Trait Implementations§

Source§

impl Clone for Dma

Source§

fn clone(&self) -> Dma

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 Dma

Source§

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

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

impl Default for Dma

Source§

fn default() -> Dma

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

Auto Trait Implementations§

§

impl Freeze for Dma

§

impl RefUnwindSafe for Dma

§

impl Send for Dma

§

impl Sync for Dma

§

impl Unpin for Dma

§

impl UnsafeUnpin for Dma

§

impl UnwindSafe for Dma

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> Same for T

Source§

type Output = T

Should always be Self
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.