[][src]Trait spectrusty::bus::BusDevice

pub trait BusDevice: Debug {
    type Timestamp: Sized;
    type NextDevice: BusDevice;
    pub fn next_device_mut(&mut self) -> &mut Self::NextDevice;
pub fn next_device_ref(&self) -> &Self::NextDevice;
pub fn into_next_device(self) -> Self::NextDevice; pub fn reset(&mut self, timestamp: Self::Timestamp) { ... }
pub fn update_timestamp(&mut self, timestamp: Self::Timestamp) { ... }
pub fn next_frame(&mut self, eof_timestamp: Self::Timestamp) { ... }
pub fn read_io(
        &mut self,
        port: u16,
        timestamp: Self::Timestamp
    ) -> Option<(u8, Option<NonZeroU16>)> { ... }
pub fn write_io(
        &mut self,
        port: u16,
        data: u8,
        timestamp: Self::Timestamp
    ) -> Option<u16> { ... }
pub fn type_id(&self) -> TypeId
    where
        Self: 'static
, { ... } }

An interface for emulating devices that communicate with the emulated CPU via I/O requests.

This trait allows attaching many, different devices to form a so-called "daisy chain".

Implementations of this trait should be provided as an associated type of ControlUnit::BusDevice.

Associated Types

type Timestamp: Sized[src]

A type used as a time-stamp.

type NextDevice: BusDevice[src]

A type of the next device in a daisy chain.

Loading content...

Required methods

pub fn next_device_mut(&mut self) -> &mut Self::NextDevice[src]

Returns a mutable reference to the next device.

pub fn next_device_ref(&self) -> &Self::NextDevice[src]

Returns a reference to the next device.

pub fn into_next_device(self) -> Self::NextDevice[src]

Destructs self and returns the instance of the next bus device.

Loading content...

Provided methods

pub fn reset(&mut self, timestamp: Self::Timestamp)[src]

Resets the device and all devices in this chain.

This method is called from ControlUnit::reset.

Default implementation forwards this call to the next device.

NOTE: Implementations should always forward this call down the chain after optionally applying it to self.

pub fn update_timestamp(&mut self, timestamp: Self::Timestamp)[src]

This method should be called near the end of each frame.

Default implementation forwards this call to the next device.

NOTE: Implementations should always forward this call down the chain after optionally applying it to self.

pub fn next_frame(&mut self, eof_timestamp: Self::Timestamp)[src]

This method should be called just before the T-state counter of the control unit is wrapped when preparing for the next frame.

It allows the devices that are tracking time to adjust stored timestamps accordingly by subtracting the total number of T-states per frame from the stored ones. The eof_timestamp argument indicates the total number of T-states in a single frame.

Optionally enables implementations to perform an end-of-frame action.

Default implementation forwards this call to the next device.

NOTE: Implementations should always forward this call down the chain after optionally applying it to self.

pub fn read_io(
    &mut self,
    port: u16,
    timestamp: Self::Timestamp
) -> Option<(u8, Option<NonZeroU16>)>
[src]

This method is called by the control unit during an I/O read cycle.

Default implementation forwards this call to the next device.

Returns an optional tuple with the (data, insert wait states).

NOTE: Implementations should only need to forward this call if it does not apply to this device or if not all bits are modified by the implementing device. In the latter case the result from the forwarded call should be logically ANDed with the result of reading from this device and if the upstream result is None the result should be returned with all unused bits set to 1.

pub fn write_io(
    &mut self,
    port: u16,
    data: u8,
    timestamp: Self::Timestamp
) -> Option<u16>
[src]

This method is called by the control unit during an I/O write cycle.

Returns Some(insert wait states) if the device has blocked writing through it.

Default implementation forwards this call to the next device.

NOTE: Implementations should only forward this call to the next device if it does not apply to this device or if the device doesn't block writing. If the device blocks writing to downstream devices and the port matches, this method must return true. Otherwise this method should return the forwarded result.

pub fn type_id(&self) -> TypeId where
    Self: 'static, 
[src]

Gets the TypeId of self.

A required part for the ability to downcast dynamic BusDevice instances.

Safety

The default implementation of this method must not be overwritten by the specializations. Consider this method as final.

Loading content...

Implementations on Foreign Types

impl<D> BusDevice for Box<D, Global> where
    D: BusDevice
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = <D as BusDevice>::NextDevice

Loading content...

Implementors

impl<D> BusDevice for DynamicBus<D> where
    D: BusDevice,
    <D as BusDevice>::Timestamp: Debug,
    <D as BusDevice>::Timestamp: Copy
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<D> BusDevice for DebugBusDevice<D> where
    D: BusDevice,
    <D as BusDevice>::Timestamp: Debug
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

pub fn write_io(
    &mut self,
    port: u16,
    data: u8,
    timestamp: <DebugBusDevice<D> as BusDevice>::Timestamp
) -> Option<u16>
[src]

Called by the control unit on IO::write_io.

impl<D> BusDevice for MultiJoystickBusDevice<D> where
    D: BusDevice
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<D, N> BusDevice for OptionalBusDevice<D, N> where
    D: BusDevice,
    N: BusDevice<Timestamp = <D as BusDevice>::Timestamp>,
    <D as BusDevice>::Timestamp: Copy
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = N

impl<P, A, B, D> BusDevice for Ay3_891xBusDevice<P, A, B, D> where
    B: AyIoPort<Timestamp = <D as BusDevice>::Timestamp> + Debug,
    D: BusDevice,
    A: AyIoPort<Timestamp = <D as BusDevice>::Timestamp> + Debug,
    P: AyPortDecode,
    <D as BusDevice>::Timestamp: Debug,
    <D as BusDevice>::Timestamp: Copy
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<P, D> BusDevice for Plus3CentronicsBusDevice<P, D> where
    D: BusDevice,
    P: ParallelPortDevice<Timestamp = <D as BusDevice>::Timestamp> + Debug,
    <D as BusDevice>::Timestamp: Copy
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<P, J, D> BusDevice for JoystickBusDevice<P, J, D> where
    D: BusDevice,
    P: PortAddress,
    J: JoystickDevice
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<P, M, D> BusDevice for MouseBusDevice<P, M, D> where
    M: MouseDevice,
    D: BusDevice,
    P: PortAddress
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<P, S, D> BusDevice for ZxPrinterBusDevice<P, S, D> where
    D: BusDevice,
    P: PortAddress,
    S: Spooler,
    <D as BusDevice>::Timestamp: TimestampOps
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<R, W, N, D> BusDevice for ZxInterface1BusDevice<R, W, N, D> where
    D: BusDevice,
    R: Read + Debug,
    N: ZxNetSocket + Debug,
    W: Write + Debug,
    <D as BusDevice>::Timestamp: TimestampOps
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<S, D> BusDevice for DynamicSerdeBus<S, D> where
    D: BusDevice,
    <D as BusDevice>::Timestamp: Copy,
    <D as BusDevice>::Timestamp: Debug
[src]

type Timestamp = <D as BusDevice>::Timestamp

type NextDevice = D

impl<T> BusDevice for NullDevice<T>[src]

type Timestamp = T

type NextDevice = NullDevice<T>

Loading content...