@database "disk"
@master "ADCD_v1.2:IncludesD/Inc&AD1.3/doc/disk.doc"

@Node Main "disk.doc"
@TOC 1.3Includes_Autodocs/Autodocs

@{" AllocUnit() " Link "AllocUnit()"}    @{" GetUnit() " Link "GetUnit()"}      @{" GiveUnit() " Link "GiveUnit()"}
@{" FreeUnit() " Link "FreeUnit()"}     @{" GetUnitID() " Link "GetUnitID()"}

@EndNode

@Node "AllocUnit()" "disk.resource/AllocUnit"

NAME
    AllocUnit - allocate a unit of the disk

SYNOPSIS
    Success = AllocUnit( unitNum ), DRResource
     D0                   D0         A6

FUNCTION
    This routine allocates one of the units of the disk.  It should
    be called before trying to use the disk (via GetUnit).

INPUTS
    unitNum -- a legal unit number (zero through three)

RESULTS
    Success -- nonzero if successful.  zero on failure.

EXCEPTIONS

SEE ALSO

BUGS

@EndNode

@Node "FreeUnit()" "disk.resource/FreeUnit"

NAME
    FreeUnit - deallocate the disk

SYNOPSIS
    FreeUnit( unitNum ), DRResource
              D0         A6

FUNCTION
    This routine deallocates one of the units of the disk.  It should
    be called when done with the disk.  Do not call it if you did
    no successfully allocate the disk (there is no protection -- you
    will probably crash the disk system).

INPUTS
    unitNum -- a legal unit number (zero through three)

RESULTS

EXCEPTIONS

SEE ALSO

BUGS

@EndNode

@Node "GetUnit()" "disk.resource/GetUnit"

NAME
    GetUnit - allocate the disk for a driver

SYNOPSIS
    lastDriver = GetUnit( unitPointer ), DRResource
     D0                     A1             A6

FUNCTION
    This routine allocates the disk to a driver.  It is either
    immediately available, or the request is saved until the disk
    is available.  When it is available, your unitPointer is
    sent back to you (via ReplyMsg).  You may then reattempt the
    GetUnit.

    Allocating the disk allows you to use the disk's resources.
    @{"Remember" Link "ADCD_v1.2:Inc&AD1.3/Includes/intuition/intuition.h/Main" 927} however that there are four units to the disk; you are
    only one of them.  Please be polite to the other units (by never
    selecting them, and by not leaving interrupts enabled, etc.).

    When you are done, please leave the disk in the following state:
        dmacon dma bit ON
        dsklen dma bit OFF (write a #DSKDMAOFF to dsklen)
        adkcon disk bits -- any way you want
        entena:disk sync and disk block interrupts -- Both DISABLED
        @{"CIA" Link "ADCD_v1.2:Inc&AD1.3/Includes/hardware/cia.h/Main" 21} resource index interrupt -- DISABLED
        8520 outputs -- doesn't matter, because all bits will be
            set to inactive by the resource.
        8520 data direction regs -- restore to original state.

INPUTS
    unitPtr - a pointer you your disk resource unit structure.
            Note that the message filed of the structure MUST
            be a valid message, ready to be replied to.

RESULTS
    lastDriver - if the disk is not busy, then the last unit
            to use the disk is returned.  This may be used to
            see if a driver needs to reset device registers.
            (If you were the last user, then no one has changed
            any of the registers.  If someone else has used it,
            then any allowable changes may have been made).  If the
            disk is busy, then a null is returned.

EXCEPTIONS

SEE ALSO

BUGS

@EndNode

@Node "GetUnitID()" "disk.resource/GetUnitID"

NAME
    GetUnitID - find out what type of disk is out there

SYNOPSIS
    idtype = GetUnitID( unitNum ), DRResource
     D0                  D0         A6

FUNCTION

INPUTS

RESULTS
    idtype -- the type of the disk drive.  Standard types are
              defined in the resource include file.

EXCEPTIONS

SEE ALSO

BUGS

@EndNode

@Node "GiveUnit()" "disk.resource/GiveUnit"

NAME
    GiveUnit - Free the disk back up

SYNOPSIS
    GiveUnit(), DRResource
                A6

FUNCTION
    This routine frees the disk after a driver is done with it.
    If others are waiting, it will notify them.

INPUTS

RESULTS

EXCEPTIONS

SEE ALSO

@EndNode

