pub trait ExternalDevice:
Send
+ Sync
+ 'static {
// Required methods
fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>;
fn io_write(&mut self, addr: u16, data: u16) -> bool;
fn io_reset(&mut self);
fn poll_interrupt(&mut self) -> Option<Interrupt>;
}Expand description
An external device, which can be accessed via memory-mapped IO or via interrupts.
Required Methods§
sourcefn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>
fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>
Reads the data at the given memory-mapped address.
If successful, this returns the value returned from that address.
If unsuccessful, this returns None.
sourcefn io_write(&mut self, addr: u16, data: u16) -> bool
fn io_write(&mut self, addr: u16, data: u16) -> bool
Writes the data to the given memory-mapped address.
This returns whether the write was successful or not.
sourcefn poll_interrupt(&mut self) -> Option<Interrupt>
fn poll_interrupt(&mut self) -> Option<Interrupt>
During each instruction cycle, this function is called once to see whether to trigger an interrupt.
Of course, in the real world, the devices would send an interrupt signal which would be detected, but that can’t really be done here.