Copyright (c) Hyperion Entertainment and contributors.

Disk Resource

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
Warning.png This page is not yet fully updated to AmigaOS 4.x some of the information contained here may not be applicable in part or totally.

The Disk resource obtains exclusive access to the floppy disk hardware There are four disk/MFM units available, units 0–3.

Six functions are available for dealing with the floppy disk hardware.

Disk Resource Functions

AllocUnit() Allocate one of the units of the disk resource.
FreeUnit() Deallocate an allocated disk unit.
GetUnit() Allocate the disk for a driver.
GetUnitID() Return the drive ID of a specified drive unit.
GiveUnit() Free the disk.
ReadUnitID() Reread and return the drive ID of a specified unit.

The disk resource provides both a gross and a fine unit allocation scheme. AllocUnit() and FreeUnit() are used to claim a unit for long term use, and GetUnit() and GiveUnit() are used to claim a unit and the disk hardware for shorter periods.

The trackdisk device uses and abides by both allocation schemes. Because a trackdisk unit is never closed for Amiga 3.5’’ drives (the file system keeps them open) the associated resource units will always be allocated for these drives. GetUnit() and GiveUnit() can still be used, however, by other applications that have not succeeded with AllocUnit().

You must not change the state of of a disk that the trackdisk device is using unless you either

  1. force its removal before giving it up, or

  2. return it to the original track (with no changes to the track), or


    the unit before GetUnit(), update the current track number and CMD_START it after GiveUnit(). This option is only available under V36 and higher versions of the operating system.

ReadUnitID() is provided to handle drives which use the unit number in a dynamic manner. Subsequent GetUnit() calls will return the value obtained by ReadUnitID().

It is therefore possible to prevent the trackdisk device from using units that have not yet been mounted by successfully performing an AllocUnit() for that unit. It is also possible to starve trackdisk usage by performing a GetUnit(). The appropriate companion routine (FreeUnit() or GiveUnit()) should be called to restore the resource at the end of its use.

Additional programming information on the disk resource can be found in the include files and the Autodocs for the disk resource.

Disk Resource Information
Includes resources/disk.h
AutoDocs disk.doc