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§
Required Methods§
Sourcefn issue(&mut self, command: u8, params: &[u8]) -> bool
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).
Sourcefn interrupt_code(&mut self) -> u8
fn interrupt_code(&mut self) -> u8
The controller’s current interrupt flag (0 none, 1 data ready, 2 complete, 3 acknowledge, 5 error).
Sourcefn error_response(&mut self) -> (u8, u8)
fn error_response(&mut self) -> (u8, u8)
The first two response bytes of a drive error: status and error code.
Sourcefn discard_response(&mut self)
fn discard_response(&mut self)
Pop and discard the response FIFO.
Sourcefn acknowledge(&mut self, bits: u8)
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.
Sourcefn silence_output(&mut self)
fn silence_output(&mut self)
Mask the controller’s interrupt output, so nothing more is raised
until the next issue.
Sourcefn drop_data_request(&mut self)
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.
Sourceunsafe fn pop_sector(
&mut self,
destination: *mut u32,
store_words: usize,
) -> bool
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).
Sourcefn set_source_enabled(&mut self, enabled: bool)
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.
Sourcefn vblank_count(&mut self) -> u32
fn vblank_count(&mut self) -> u32
Monotonic VBlank count, the clock the no-progress timeout runs on.
Provided Methods§
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.