Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

CdHw

Trait CdHw 

Source
pub trait CdHw {
    const TRACE: bool = false;

    // Required methods
    fn issue(&mut self, command: u8, params: &[u8]) -> bool;
    fn interrupt_code(&mut self) -> u8;
    fn error_response(&mut self) -> (u8, u8);
    fn discard_response(&mut self);
    fn acknowledge(&mut self, bits: u8);
    fn silence_output(&mut self);
    fn drop_data_request(&mut self);
    unsafe fn pop_sector(
        &mut self,
        destination: *mut u32,
        store_words: usize,
    ) -> bool;
    fn set_source_enabled(&mut self, enabled: bool);
    fn vblank_count(&mut self) -> u32;

    // Provided methods
    fn clock(&mut self) -> u16 { ... }
    fn trace(&mut self, _word: u32) { ... }
}
Expand description

Controller steps and system services the state machine needs.

Nothing here blocks beyond a short bounded poll: every method is called from the CD interrupt handler or from a foreground section that has the CD source masked.

Provided Associated Constants§

Source

const TRACE: bool = false

Whether to record controller events through trace. Constant per implementation so the unused event words fold away.

Required Methods§

Source

fn issue(&mut self, command: u8, params: &[u8]) -> bool

Send one drive command and arm the controller to interrupt for its responses. Returns false when the parameter FIFO never had room (the command is not sent).

The order is: mask the controller’s interrupt output, acknowledge every pending flag and the CPU-side pending bit, discard any response bytes, empty the parameter FIFO, push the parameters, write the command byte, then enable the controller’s interrupt output. Silicon is picky about it (the SDK’s polled reader does the same).

Source

fn interrupt_code(&mut self) -> u8

The controller’s current interrupt flag (0 none, 1 data ready, 2 complete, 3 acknowledge, 5 error).

Source

fn error_response(&mut self) -> (u8, u8)

The first two response bytes of a drive error: status and error code.

Source

fn discard_response(&mut self)

Pop and discard the response FIFO.

Source

fn acknowledge(&mut self, bits: u8)

Acknowledge interrupt flag bits on the controller and the CPU-side pending bit. acknowledge(0) only clears the CPU-side bit.

Source

fn silence_output(&mut self)

Mask the controller’s interrupt output, so nothing more is raised until the next issue.

Source

fn drop_data_request(&mut self)

Drop a data request left armed by the previous transfer. Called before the first command of a transfer that did not start from a recovery pause.

Source

unsafe fn pop_sector( &mut self, destination: *mut u32, store_words: usize, ) -> bool

Pop one sector’s 2048 bytes from the data FIFO as 512 little-endian words, storing the first store_words of them at destination. The rest are popped and dropped (the FIFO has to be emptied either way). Arms the data request and waits a bounded time for the FIFO to fill; false if it never does.

§Safety

destination must be valid for store_words word writes (it is not used when store_words is 0).

Source

fn set_source_enabled(&mut self, enabled: bool)

Let the CD interrupt source reach the CPU (or not).

This only moves the mask. It must not acknowledge the CPU-side pending bit: the foreground closes the source around every call, and an interrupt that arrived meanwhile has to fire when the source opens. Stale flags are cleared by acknowledge and by issue.

Source

fn vblank_count(&mut self) -> u32

Monotonic VBlank count, the clock the no-progress timeout runs on.

Provided Methods§

Source

fn clock(&mut self) -> u16

A free-running timestamp for measuring the handler, wrapping at 16 bits. Implementations that do not measure return a constant.

Source

fn trace(&mut self, _word: u32)

Record one trace word (only called when TRACE is set).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl CdHw for Mmio

Source§

const TRACE: bool = true