dioscuri.module.fdc
Class FDC

java.lang.Object
  extended by dioscuri.module.AbstractModule
      extended by dioscuri.module.ModuleFDC
          extended by dioscuri.module.fdc.FDC
All Implemented Interfaces:
Addressable, Module, Updateable, DMATransferCapable

public class FDC
extends ModuleFDC
implements DMATransferCapable

An implementation of a Floppy disk controller module.

See Also:

Metadata module ******************************************** general.type : fdc general.name : Floppy Disk Controller general.architecture : Von Neumann general.description : Implements a standard floppy disk controller for 3.5" floppies general.creator : Tessella Support Services, Koninklijke Bibliotheek, Nationaal Archief of the Netherlands general.version : 1.0 general.keywords : floppy, disk, controller, 1.44, 2.88, 3.5 inch, SD, DD, HD general.relations : motherboard general.yearOfIntroduction : 1982 general.yearOfEnding : general.ancestor : 5.25 inch floppy disk general.successor : -

Issues: - check all fixme statements - sometimes MSR register is set to busy, but I am not sure if it is done the right way as it loses all previous bits: // Data register not ready, drive busy MSR = (byte) (1 << drive);

Notes: - Floppy disk controller is usually an 8272, 8272A, NEC765 (or compatible), or an 82072 or 82077AA for perpendicular recording at 2.88M. - The FDC is only capable of reading from and writing to virtual floppy disks (images), not physical disks. - The FDC does not perform a CRC (Cyclic Redundancy Check). - FDC commands Scan low, scan low or equal, scan high or equal are not implemented. - Datarates (speed of reading/writing) is not taken into account. - Enhanced commands like lock and unlock are not fully implemented. - Current FDC only works with DMA data transfer

Overview of FDC registers (ref: Port list, made by Ralf Brown: [http://mudlist.eorbit.net/~adam/pickey/ports.html]) 03F0 R diskette controller status A (PS/2) (see #P173) 03F0 R diskette controller status A (PS/2 model 30) (see #P174) 03F0 R diskette EHD controller board jumper settings (82072AA) (see #P175) 03F1 R diskette controller status B (PS/2) (see #P176) 03F1 R diskette controller status B (PS/2 model 30) (see #P177) 03F2 W diskette controller DOR (Digital Output Register) (see #P178) 03F3 ?W tape drive register (on the 82077AA) bit 7-2 reserved, tri-state bit 1-0 tape select =00 none, drive 0 cannot be a tape drive. =01 drive1 =10 drive2 =11 drive3 03F4 R diskette controller main status register (see #P179) Note: in non-DMA mode, all data transfers occur through PORT 03F5h and the status registers (bit 5 here indicates data read/write rather than than command/status read/write) 03F4 W diskette controller data rate select register (see #P180) 03F5 R diskette command/data register 0 (ST0) (see #P181) status register 1 (ST1) (see #P182) status register 2 (ST2) (see #P183) status register 3 (ST3) (see #P184) 03F5 W diskette command register. The commands summarized here are mostly multibyte commands. This is for brief recognition only. (see #P187) 03F6 -- reserved on FDC 03F6 rW FIXED disk controller data register (see #P185) 03F7 RW harddisk controller (see #P186) 03F7 R diskette controller DIR (Digital Input Register, PC/AT mode) bit 7 = 1 diskette change bit 6-0 tri-state on FDC 03F7 R diskette controller DIR (Digital Input Register, PS/2 mode) bit 7 = 1 diskette change bit 6-3 = 1 bit 2 datarate select1 bit 1 datarate select0 bit 0 = 0 high density select (500Kb/s, 1Mb/s) conflict bit 0 FIXED DISK drive 0 select 03F7 R diskette controller DIR (Digital Input Register, PS/2 model 30) bit 7 = 0 diskette change bit 6-4 = 0 bit 3 -DMA gate (value from DOR register) bit 2 NOPREC (value from CCR register) bit 1 datarate select1 bit 0 datarate select0 conflict bit 0 FIXED DISK drive 0 select 03F7 W configuration control register (PC/AT, PS/2) bit 7-2 reserved, tri-state bit 1-0 = 00 500 Kb/S mode (MFM) = 01 300 Kb/S mode (MFM) = 10 250 Kb/S mode (MFM) = 11 1 Mb/S mode (MFM) (on 82072/82077AA) conflict bit 0 FIXED DISK drive 0 select 03F7 W configuration control register (PS/2 model 30) bit 7-3 reserved, tri-state bit 2 NOPREC (has no function. set to 0 by hardreset) bit 1-0 = 00 500 Kb/S mode (MFM) = 01 300 Kb/S mode (MFM) = 10 250 Kb/S mode (MFM) = 11 1 Mb/S mode (MFM) (on 82072/82077AA) conflict bit 0 FIXED DISK drive 0 select


Nested Class Summary
 
Nested classes/interfaces inherited from interface dioscuri.interfaces.Module
Module.Type
 
Field Summary
 DMA8Handler dma8Handler
           
protected  byte[] floppyBuffer
           
 
Fields inherited from class dioscuri.module.AbstractModule
type
 
Constructor Summary
FDC(Emulator owner)
          Class constructor
 
Method Summary
 void acceptComponent(HardwareComponent component)
           
protected  int calculateStepDelay(int drive, int newCylinder)
          Calculate the delay for timer This method makes an approximation of the delay in the drive It does this based on the gap between current position of head in cylinder and desired cylinder
protected  void clearInterrupt()
          Clear interrupt signal
 boolean ejectCarrier(int driveIndex)
          Ejects a carrier (if any) from a selected drive
 boolean ejectCarrier(java.lang.String driveLetter)
          Ejects a carrier (if any) from a selected drive
protected  byte getDMAByte()
          Get byte from floppy buffer for DMA transfer This method is used for DMA transfer a byte from FDC to memory
 java.lang.String getDump()
          Return a dump of module status
 byte getIOPortByte(int portAddress)
          
 byte[] getIOPortDoubleWord(int portAddress)
          
 byte[] getIOPortWord(int portAddress)
          
 int getUpdateInterval()
          Get the update interval.
 boolean insertCarrier(int driveIndex, byte carrierType, java.io.File imageFile, boolean writeProtected)
          Inserts a new carrier into a selected drive
 boolean insertCarrier(java.lang.String driveLetter, byte carrierType, java.io.File imageFile, boolean writeProtected)
          Inserts a new carrier into a selected drive
 boolean reset()
          Reset all parameters of module.
protected  void setDMAByte(byte data)
          Set byte in floppy buffer for DMA transfer This method is used for DMA transfer a byte from memory to FDC
protected  void setInterrupt()
          Raise interrupt signal
 void setIOPortByte(int portAddress, byte value)
          
 void setIOPortDoubleWord(int portAddress, byte[] dataDoubleWord)
          
 void setIOPortWord(int portAddress, byte[] dataWord)
          
 boolean setNumberOfDrives(int totalDrives)
          Defines the total number of available drives Note: total number may not exceed 4
 void setUpdateInterval(int interval)
          Defines the interval between subsequent updates
 void stop()
          Stops the module from being active.
 int transferHandler(int nchan, int pos, int size)
           
 void update()
          Update the module.
 
Methods inherited from class dioscuri.module.AbstractModule
getConnection, getConnections, getDebugMode, getExpectedConnections, getType, isConnected, setConnection, setDebugMode, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dioscuri.interfaces.Module
getConnection, getConnections, getDebugMode, getExpectedConnections, getType, isConnected, setConnection, setDebugMode, start
 

Field Detail

dma8Handler

public DMA8Handler dma8Handler

floppyBuffer

protected byte[] floppyBuffer
Constructor Detail

FDC

public FDC(Emulator owner)
Class constructor

Parameters:
owner -
Method Detail

reset

public boolean reset()
Reset all parameters of module.

Specified by:
reset in interface Module
Specified by:
reset in class AbstractModule
Returns:
true iff the AbstractModule was reset properly.
See Also:
AbstractModule

stop

public void stop()
Stops the module from being active.

Provides an empty implementations since many of the subclasses of this abstract module class do not need a stop() implementation. The ones that do, can override this method.

Specified by:
stop in interface Module
Overrides:
stop in class AbstractModule
See Also:
Module

getDump

public java.lang.String getDump()
Return a dump of module status

Provides a dummy implementation since many of the subclasses of this abstract module class do not need or use a getDump() implementation. The ones that do, can override this method.

Specified by:
getDump in interface Module
Overrides:
getDump in class AbstractModule
Returns:
string containing a dump of this module
See Also:
AbstractModule

getUpdateInterval

public int getUpdateInterval()
Get the update interval.

Specified by:
getUpdateInterval in interface Updateable
Returns:
the update interval
See Also:
Updateable

setUpdateInterval

public void setUpdateInterval(int interval)
Defines the interval between subsequent updates

Specified by:
setUpdateInterval in interface Updateable
Parameters:
interval - the interval between subsequent updates in ms.
See Also:
Updateable

update

public void update()
Update the module.

Specified by:
update in interface Updateable
See Also:
Updateable

getIOPortByte

public byte getIOPortByte(int portAddress)
                   throws ModuleException,
                          UnknownPortException,
                          WriteOnlyPortException

Specified by:
getIOPortByte in interface Addressable
Returns:
Throws:
ModuleException
UnknownPortException
WriteOnlyPortException
See Also:
Addressable

setIOPortByte

public void setIOPortByte(int portAddress,
                          byte value)
                   throws ModuleException,
                          UnknownPortException

Specified by:
setIOPortByte in interface Addressable
Throws:
ModuleException
UnknownPortException
See Also:
Addressable

getIOPortWord

public byte[] getIOPortWord(int portAddress)
                     throws ModuleException,
                            WriteOnlyPortException

Specified by:
getIOPortWord in interface Addressable
Returns:
Throws:
ModuleException
WriteOnlyPortException
See Also:
Addressable

setIOPortWord

public void setIOPortWord(int portAddress,
                          byte[] dataWord)
                   throws ModuleException

Specified by:
setIOPortWord in interface Addressable
Throws:
ModuleException
See Also:
Addressable

getIOPortDoubleWord

public byte[] getIOPortDoubleWord(int portAddress)
                           throws ModuleException,
                                  WriteOnlyPortException

Specified by:
getIOPortDoubleWord in interface Addressable
Returns:
Throws:
ModuleException
WriteOnlyPortException
See Also:
Addressable

setIOPortDoubleWord

public void setIOPortDoubleWord(int portAddress,
                                byte[] dataDoubleWord)
                         throws ModuleException

Specified by:
setIOPortDoubleWord in interface Addressable
Throws:
ModuleException
See Also:
Addressable

setInterrupt

protected void setInterrupt()
Raise interrupt signal


clearInterrupt

protected void clearInterrupt()
Clear interrupt signal


setNumberOfDrives

public boolean setNumberOfDrives(int totalDrives)
Defines the total number of available drives Note: total number may not exceed 4

Specified by:
setNumberOfDrives in class ModuleFDC
Returns:
true if drives set successfully, false otherwise
See Also:
ModuleFDC

insertCarrier

public boolean insertCarrier(java.lang.String driveLetter,
                             byte carrierType,
                             java.io.File imageFile,
                             boolean writeProtected)
Inserts a new carrier into a selected drive

Specified by:
insertCarrier in class ModuleFDC
Returns:
boolean true if carrier is inserted successfully, false otherwise
See Also:
ModuleFDC

ejectCarrier

public boolean ejectCarrier(java.lang.String driveLetter)
Ejects a carrier (if any) from a selected drive

Specified by:
ejectCarrier in class ModuleFDC
Returns:
boolean true if carrier is ejected successfully, false otherwise
See Also:
ModuleFDC

insertCarrier

public boolean insertCarrier(int driveIndex,
                             byte carrierType,
                             java.io.File imageFile,
                             boolean writeProtected)
Inserts a new carrier into a selected drive

Specified by:
insertCarrier in class ModuleFDC
Returns:
boolean true if carrier is inserted successfully, false otherwise
See Also:
ModuleFDC

ejectCarrier

public boolean ejectCarrier(int driveIndex)
Ejects a carrier (if any) from a selected drive

Specified by:
ejectCarrier in class ModuleFDC
Returns:
boolean true if carrier is ejected successfully, false otherwise
See Also:
ModuleFDC

getDMAByte

protected byte getDMAByte()
Get byte from floppy buffer for DMA transfer This method is used for DMA transfer a byte from FDC to memory

Returns:
byte current byte from floppy buffer

setDMAByte

protected void setDMAByte(byte data)
Set byte in floppy buffer for DMA transfer This method is used for DMA transfer a byte from memory to FDC

Parameters:
data -

calculateStepDelay

protected int calculateStepDelay(int drive,
                                 int newCylinder)
Calculate the delay for timer This method makes an approximation of the delay in the drive It does this based on the gap between current position of head in cylinder and desired cylinder

Parameters:
drive -
newCylinder -
Returns:
-

transferHandler

public int transferHandler(int nchan,
                           int pos,
                           int size)
Specified by:
transferHandler in interface DMATransferCapable
Parameters:
nchan -
pos -
size -
Returns:
-

acceptComponent

public void acceptComponent(HardwareComponent component)
Parameters:
component -