Class: Zemu::Config::BusDevice

Inherits:
Zemu::ConfigObject show all
Defined in:
lib/zemu/config.rb

Overview

Bus Device.

Represents a device connected to the I/O or memory buses, or both.

Direct Known Subclasses

BlockDrive, Memory, SerialPort, Timer

Instance Method Summary collapse

Methods inherited from Zemu::ConfigObject

#method_missing

Constructor Details

#initializeBusDevice

Constructor.

This object should not be constructed directly.



88
89
90
91
92
93
94
95
96
97
# File 'lib/zemu/config.rb', line 88

def initialize
    if self.class == Zemu::Config::BusDevice
        raise NotImplementedError, "Cannot construct an instance of the abstract class Zemu::Config::BusDevice."
    end

    @nmi = false
    @interrupt = false

    super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zemu::ConfigObject

Instance Method Details

#clock(cycles) ⇒ Object

Clock handler.

Handles a clock cycle for this device. Deriving objects can use the nmi function to set the state of the non-maskable interrupt at each clock cycle.



159
160
# File 'lib/zemu/config.rb', line 159

def clock(cycles)
end

#functionsObject

FFI functions provided by this device.



163
164
165
# File 'lib/zemu/config.rb', line 163

def functions
    []
end

#interrupt(state) ⇒ Object

Sets state of INT for this device.



178
179
180
# File 'lib/zemu/config.rb', line 178

def interrupt(state)
    @interrupt = state
end

#interrupt?Boolean

Gets state of INT for this device.

Returns:

  • (Boolean)


183
184
185
# File 'lib/zemu/config.rb', line 183

def interrupt?
    @interrupt
end

#io_read(port) ⇒ Object

IO bus read handler.

Handles read access via the IO bus to this device.

Returns the value read from the port, or nil if no value (e.g. port does not correspond to this device).

Parameters:

  • port

    The IO port being accessed.



149
150
151
# File 'lib/zemu/config.rb', line 149

def io_read(port)
    nil
end

#io_write(port, value) ⇒ Object

IO bus write handler.

Handles write access via the IO bus to this device.

Parameters:

  • port

    The IO port being accessed.

  • value

    The value being written.



138
139
# File 'lib/zemu/config.rb', line 138

def io_write(port, value)
end

#mem_read(addr) ⇒ Object

Memory bus read handler.

Handles read access via the memory bus to this device.

Returns the value read, or nil if no value (e.g. if address falls outside range for this device).

Parameters:

  • addr

    The address being accessed.



128
129
130
# File 'lib/zemu/config.rb', line 128

def mem_read(addr)
    nil
end

#mem_write(addr, value) ⇒ Object

Memory bus write handler.

Handles write access via the memory bus to this device.

Parameters:

  • addr

    The address being accessed.

  • value

    The value being written.



117
118
# File 'lib/zemu/config.rb', line 117

def mem_write(addr, value)
end

#memoryObject

Parameters used for generating C code to implement this bus device.



101
102
103
# File 'lib/zemu/config.rb', line 101

def memory
    nil
end

#nmi(state) ⇒ Object

Sets state of the NMI for this device.



168
169
170
# File 'lib/zemu/config.rb', line 168

def nmi(state)
    @nmi = state
end

#nmi?Boolean

Gets state of NMI for this device.

Returns:

  • (Boolean)


173
174
175
# File 'lib/zemu/config.rb', line 173

def nmi?
    @nmi
end

#paramsObject

Parameters for a bus device.



188
189
190
# File 'lib/zemu/config.rb', line 188

def params
    %w(name)
end

#when_setupObject

Setup to be performed on initialising the emulator instance.



107
108
109
# File 'lib/zemu/config.rb', line 107

def when_setup
    ""
end