mfm.library Reference

Comprehensive function reference for mfm.library, synthesised from the AmigaOS NDK 3.2 Release 4 (Autodocs/AG/mfm) — the official Hyperion Entertainment SDK covering AmigaOS 3.5, 3.9, and OS 4.x conventions.

This page documents 19 functions of mfm.library. Each function entry follows the canonical autodoc format: NAME, SYNOPSIS (C signature with 68k register convention + modern C), FUNCTION, INPUTS, OUTPUTS, RESULTS, NOTE, EXAMPLE, SEE ALSO.

Source: AmigaOS NDK 3.2 R4 (Hyperion Entertainment, 2022). The autodoc is the primary reference; cross-references to include files use the convention @{<exec/types.h> Link ...} from the source.

Editorial markers: V36 = OS 2.0, V39 = OS 3.0, V40 = OS 3.5, V45 = OS 3.9, V50 = OS 4.0. Functions introduced at a specific OS version are marked accordingly in the SYNOPSIS section.

Function index


CMD_CLEAR()

CMD_CLEAR/ETD_CLEAR -- mark the track buffer as containing invalid data.

Function

These commands mark the track buffer as invalid, forcing a reread of the disk on the next operation. ETD_UPDATE or CMD_UPDATE would be used to force data out to the disk before turning the motor off. ETD_CLEAR or CMD_CLEAR are usually used after having locked out the mfm.device via the use of the disk resource, when you wish to prevent the track from being updated, or when you wish to force the track to be re-read. ETD_CLEAR or CMD_CLEAR will not do an update, nor will an update command do a clear.


CMD_READ()

CMD_READ/ETD_READ -- read sectors of data from a disk.

Function

These commands transfer data from the track buffer to a supplied buffer. If the desired sector is already in the track buffer, no disk activity is initiated. If the desired sector is not in the buffer, the track containing that sector is automatically read in. If the data in the current track buffer has been modified, it is written out to the disk before a new track is read. The mfm.device never reads sector label information.


CMD_UPDATE()

CMD_UPDATE/ETD_UPDATE -- write out the track buffer if it is dirty.

Function

The mfm.device does not write data sectors unless it is necessary (you request that a different track be used) or until the user requests that an update be performed. This improves system speed by caching disk operations. These commands ensure that any buffered data is flushed out to the disk. If the track buffer has not been changed since the track was read in, these commands do nothing. ETD_UPDATE command checks for diskchange.


CMD_WRITE()

CMD_WRITE/ETD_WRITE -- write sectors of data to a disk.

Function

These commands transfer data from a supplied buffer to the track buffer. If the track that contains this sector is already in the track buffer, no disk activity is initiated. If the desired sector is not in the buffer, the track containing that sector is automatically read in. If the data in the current track buffer has been modified, it is written out to the disk before the new track is read in for modification. ETD_WRITE does not write sector label information.


MD_SETPARMS()

MD_SETPARMS -- set track and sector layout.

Function

This defines the track and sector layout the mfm.device shall use for reading and writing to disk. Typically, applications will retrieve this layout from the MS-DOS bootblock of the disk.

The disk geometry is taken from a struct DosEnvec that is typically
used to mount devices. The following entries are recognized:

de_HighCyl: defines the number of tracks on the disk - 1
de_DosType: if set to MDD\0, the drive is double-stepped, i.e.
        each track step command steps over two tracks.
        The number of tracks is then computed as
        (de_HighCyl+1)/2.
de_SizeBlock:   Number of longs per sector, i.e. 128 longs =
        512 bytes per sector.
de_SecOrg:  Sector index of the first sector in the track.
        Normally 0.
de_Surfaces:    Defines whether the disk is single or double
        sided. Must be 1 or 2.
de_BlocksPerTrack: Number of sectors(!) per track.

TD_ADDCHANGEINT()

TD_ADDCHANGEINT -- add a disk change software interrupt handler.

Function

This command lets you add a software interrupt handler to the disk device that gets invoked whenever a disk insertion or removal occurs.

You must pass in a properly initialized Exec Interrupt structure
and be prepared to deal with disk insertions/removals
immediately. From within the interrupt handler, you may only call the
status commands that can use IOF_QUICK.

To set up the handler, an Interrupt structure must be initialized.
This structure is supplied as the io_Data to the TD_ADDCHANGEINT
command. The handler then gets linked into the handler chain and
gets invoked whenever a disk change happens. You must eventually
remove the handler before you exit.

This command only returns when the handler is removed. That is,
the device holds onto the IO request until the TD_REMCHANGEINT command
is executed with that same IO request. Hence, you must use SendIO()
with this command.

See also

Cause(), Cause()


TD_CHANGENUM()

TD_CHANGENUM -- return the current value of the disk-change counter.

Function

This command returns the current value of the disk-change counter (as used by the enhanced commands). The disk change counter is incremented each time a disk is inserted or removed from the trackdisk unit.

This command is directly forwarded to the trackdisk.device.

TD_CHANGESTATE()

TD_CHANGESTATE -- check if a disk is currently in a drive.

Function

This command checks to see if there is currently a disk in a drive.

This request is directly forwarded to the trackdisk.device.

TD_EJECT()

TD_EJECT -- eject (or load) the disk in the drive, if possible.

Function

This command causes the drive to attempt to eject the disk in it, if any. Note that the current mfm.device does not implement this command, but it might in the future, and other trackdisk-compatible drivers may implement this command. Some devices may be able to load disks on command also.


TD_FORMAT()

TD_FORMAT/ETD_FORMAT -- format a track on a disk.

Function

These commands are used to write data to a track that either has not yet been formatted or has had a hard error on a standard write command. TD_FORMAT completely ignores all data currently on a track and does not check for disk change before performing the command. The io_Data field must point to at least one track worth of data. The io_Offset field must be track aligned, and the io_Length field must be in units of track length (that is, NUMSEC*TD_SECTOR).

The device will format the requested tracks, filling each sector with
the contents of the buffer pointed to by io_Data. You
should do a read pass to verify the data.

If you have a hard write error during a normal write, you may find it
possible to use the TD_FORMAT command to reformat the track as part of
your error recovery process. Note that the mfm.device does not write
sector label information.

Notes

Under versions of Kickstart earlier than V36, the io_Data had to point to a buffer in chip memory. This restriction is no longer present as of Kickstart V36 and beyond.


TD_GETDRIVETYPE()

TD_GETDRIVETYPE -- return the type of disk drive for the unit that was opened.

Function

This command returns the type of the disk drive to the user. This number will be a small integer and will come from the set of DRIVEXXX constants defined in .

This command is directly forwarded to the trackdisk.device.

TD_GETGEOMETRY()

TD_GETGEOMETRY -- return the geometry of the drive.

Function

This command returns a full set of information about the layout of the drive. The information is returned in the DriveGeometry structure pointed to by io_Data.

Note

This information may change when a disk in inserted when certain hardware is present.


TD_GETNUMTRACKS()

TD_GETNUMTRACKS -- return the number of tracks for the type of disk drive for the unit that was opened.

Function

This command returns the number of tracks that are available on the disk unit.


TD_MOTOR()

TD_MOTOR/ETD_MOTOR -- control the on/off state of a drive motor.

Function

This command gives control over the disk motor. The motor may be turned on or off. When it is on, the drive light automatically turns on as well.

This command is directly forwarded to the trackdisk.device.

TD_PROTSTATUS()

TD_PROTSTATUS -- return whether the current disk is write-protected.

Function

This command is used to determine whether the current disk is write-protected.

This request is directly forwarded to the trackdisk.device.

TD_RAWREAD()

TD_RAWREAD/ETD_RAWREAD -- read raw data from the disk.

Function

These commands read a track of raw data from disk and deposits it in the provided buffer. The data is taken straight from the disk with no processing done on it. It will appear exactly as the bits come out off the disk, hopefully in some legal MFM format.

This command is directly forwarded to the trackdisk.device.

Notes

The track buffer provided MUST be in CHIP memory


TD_RAWWRITE()

TD_RAWWRITE/ETD_RAWWRITE -- write raw data to the disk.

Function

This command writes a track of raw data from the provided buffer to the specified track on disk. The data is copied straight to the disk with no processing done on it. It will appear exactly on the disk as it is in the memory buffer, hopefully in a legal MFM format.

This command is directly forwarded to the trackdisk.device.

Notes

The track buffer provided MUST be in CHIP memory


TD_REMCHANGEINT()

TD_REMCHANGEINT -- remove a disk change software interrupt handler.

Function

This command removes a disk change software interrupt added by a previous use of TD_ADDCHANGEINT.

This command is directly forwarded to the trackdisk.device.

TD_SEEK()

TD_SEEK/ETD_SEEK -- control positioning of the drive heads.

Function

These commands are currently provided for internal diagnostics, disk repair, and head cleaning only.

TD_SEEK and ETD_SEEK move the drive heads to the track specified. The
io_Offset field should be set to the (byte) offset to which the seek is
to occur. TD_SEEK and ETD_SEEK do not verify their position until the
next read. That is, they only move the heads; they do not actually read
any data.