Class: Zemu::Config

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

Overview

Configuration object.

An object which represents the configuration of a Zemu emulator.

Defined Under Namespace

Classes: BlockDrive, BusDevice, Memory, RAM, ROM, SerialPort, Timer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConfigObject

#method_missing

Constructor Details

#initializeConfig

Constructor.

Takes a block in which parameters of the configuration can be initialized.

All parameters can be set within this block. They become readonly as soon as the block completes.

Examples:


Zemu::Config.new do
    name "my_config"

    add_memory Zemu::Config::ROM.new do
        name "rom"
        address 0x0000
        size 0x1000
    end
end

Raises:

  • (Zemu::ConfigError)

    Raised if the name parameter is not set, or contains whitespace.



767
768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/zemu/config.rb', line 767

def initialize
    @devices = []

    super

    if @name.empty?
        raise ConfigError, "The name parameter of a Zemu::Config configuration object cannot be empty."
    end

    if /\s/ =~ @name
        raise ConfigError, "The name parameter of a Zemu::Config configuration object cannot contain whitespace."
    end
end

Dynamic Method Handling

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

Instance Attribute Details

#devicesObject (readonly)

The bus devices of this configuration object.



729
730
731
# File 'lib/zemu/config.rb', line 729

def devices
  @devices
end

Instance Method Details

#add_device(device) ⇒ Object

Adds a new device to the bus for this configuration.

Parameters:



804
805
806
# File 'lib/zemu/config.rb', line 804

def add_device(device)
    @devices << device
end

#add_io(io) ⇒ Object

Adds a new IO device to this configuration.

Deprecated - retained only for backwards compatibility. Use add_device instead.

Parameters:



797
798
799
# File 'lib/zemu/config.rb', line 797

def add_io(io)
    @devices << io
end

#add_memory(mem) ⇒ Object

Adds a new memory section to this configuration.

Deprecated - retained only for backwards compatibility. Use add_device instead.

Parameters:



787
788
789
# File 'lib/zemu/config.rb', line 787

def add_memory(mem)
    @devices << mem
end

#get_bindingObject

Gets a binding for this object.



724
725
726
# File 'lib/zemu/config.rb', line 724

def get_binding
    return binding
end

#paramsObject

Parameters accessible by this configuration object.



732
733
734
# File 'lib/zemu/config.rb', line 732

def params
    return %w(name compiler output_directory clock_speed serial_delay)
end

#params_initObject

Initial value for parameters of this configuration object.



737
738
739
740
741
742
743
744
# File 'lib/zemu/config.rb', line 737

def params_init
    return {
        "compiler" => "clang",
        "output_directory" => "bin",
        "clock_speed" => 0,
        "serial_delay" => 0
    }
end