jfrace
Class SystemConfigurator

java.lang.Object
  |
  +--jfrace.SystemConfigurator

public class SystemConfigurator
extends java.lang.Object

Configure a computer system based on a configuration file. The configuration file is like a Java Properties file with key-value pairs (where '=' is the delimiter between the key and the value). A key-value pair has to be in one line. Empty lines and lines starting with '#' will be ignored. Contrary to properties file there can be several key-value pairs for the same key.

Numerical values can be denoted either decimal, binary (with a leading '0b'), octal (with a leading '0'), or hexadecimal (with a leading 0x).

The following table explains all keys and the meaning of their values. Note, that packagePrefix and defaultValue have to be defined before the first CPU, RAM, or device definition.

KeyDefault Value Multiple Definitions? Meaning
packagePrefixmandatory no Package prefix for all dynamically loaded classes. The subpackages cpu, device, and terminal are derived from the main package.
defaultValuemandatory no Default return value of the AddressSpace when no address bank is defined for a given address in a getValue() or getByte() call.
yieldInterval1000 no Number of clock cycles between two calls of Thread.yield(). After such a call the Thread.sleep() will be invoked if a delay is necessary to adapt the effective clock frequency to the frequency defined in the property clockFrequency.
clockFrequencythe maximum no The frequency of the system clock (in MHz). After yieldInterval numbers of clock cycles a delay will be made to adapt the emulation speed to this frequency. If clockFrequency is not defined. no delay will be performed an the emualtion runs at the maximum speed possible.
adaptationTime2000 no The time (in milliseconds) between two recalibration of the time origin. In addition the effective clock frequency will be printed onto the console if the command line option -p is set.
CPU  yes Definition of a CPU. The value has to be

<class name> [<offset>] [<method call 1> <method call 2> ...]

For more details see CPUConfigurator.
RAM  yes Definition of a memory bank (RAM or ROM). The value has to be

<number of bits> <first address> {<size>|<raw data>} [<mode mask>] [readOnly]

For more details see RAM.createRAMAndAddToAS().
device  yes Definition of a device. The value has to be

<class name> <first address> [<mode mask>]

or

<class name> <configuration resources>

where
<class name>
is the class name of the device (without package name)
<first address>
is the first address in the AddressSpace.
<mode mask>
is the optional mode mask.
<configuration resources>
is a string which does not start with a digit.
In the first form the device will be added to the address space without doing some configuration. In the second case the device will be created and configurated by a special Configurator for this device. The interpretation of the string <configuration resources> depends on the Configurator. In most cases it will be the name of a configuration file.

Example of a configuration file:

      packagePrefix = jfrace
      defaultValue = 0
      CPU = MC6502
      CPU = Intel8080 0x20000 setPortBiasAddress(0x30000)
      RAM = 8 0 0xc000
      RAM = 8 0xc000 ROM.dat 3
      RAM = 8 0x20000 65536
      device = GI_AY_3_8910 0x300b6
      device = CPMEmulator CPMConfig1.cfg
  

Author:
Franz-Josef Elmer

Constructor Summary
SystemConfigurator(java.net.URL theDocumentBase)
          Create an instance for the given document base.
 
Method Summary
 void configure(java.lang.String configSource, java.lang.String[] args)
          Configure a computer system based on the given configuration source.
 long getAdaptationTime()
          Return the property adaptationTime read from the configuration data.
 AddressSpace getAddressSpace()
          Return the address space.
 double getClockFrequency()
          Return the clock frequency.
 long getYieldInterval()
          Return the property yieldInterval read from the configuration data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemConfigurator

public SystemConfigurator(java.net.URL theDocumentBase)
Create an instance for the given document base. The document base is need for reading configuration file with no absolute URL.
Parameters:
theDocumentBase -  
Method Detail

getAddressSpace

public AddressSpace getAddressSpace()
Return the address space. Call this method after configure(java.lang.String, java.lang.String[]).

getClockFrequency

public double getClockFrequency()
Return the clock frequency. Call this method after configure(java.lang.String, java.lang.String[]).

getYieldInterval

public long getYieldInterval()
Return the property yieldInterval read from the configuration data. Default value is 1000. Call this method after configure(java.lang.String, java.lang.String[]).

getAdaptationTime

public long getAdaptationTime()
Return the property adaptationTime read from the configuration data. Default value is 2000. Call this method after configure(java.lang.String, java.lang.String[]).

configure

public void configure(java.lang.String configSource,
                      java.lang.String[] args)
               throws ConfigurationException
Configure a computer system based on the given configuration source.
Parameters:
configSource - Absolute or relative URL of the configuration file.
args - Arguments needed by Configurators of Devices declared in the configuration file.
Throws:
ConfigurationException - in the case of an error (including syntax errors in the configuration file).