(*
**	Cyclone Modula-2 Interface module:
**	$VER: disk.h 27.11 (21.11.90)
**	Includes Release 40.15
**
**	disk.h -- external declarations for the disk resource
**
**	(C) Copyright 1985-1993 Commodore-Amiga, Inc.
**	    All Rights Reserved
**
**      Interface module by Marcel Timmermans
**      (C) Copyright 1995-1996 Marcel Timmermans
**          All Rights Reserved
*)

(*$ Implementation- *)
DEFINITION MODULE Disk;

FROM SYSTEM   IMPORT ADDRESS,SHORTSET;
FROM ExecD    IMPORT Message,Interrupt,Library,LibraryPtr,TaskPtr,List;

IMPORT Reg;

TYPE

(********************************************************************
*
* Resource structures
*
********************************************************************)

 DiscResourceUnitPtr = POINTER TO DiscResourceUnit;
 DiscResourceUnit = RECORD
  message   : Message;
  discBlock : Interrupt;
  discSync  : Interrupt;
  index     : Interrupt;
 END;

 DiscResourcePtr = POINTER TO DiscResource;
 DiscResource = RECORD
  library       : Library;
  current       : DiscResourceUnitPtr;
  flags         : SHORTSET;
  pad           : SHORTCARD;
  sysLib        : LibraryPtr;
  ciaResource   : LibraryPtr;
  unitID        : ARRAY[0..3] OF LONGCARD;
  waiting       : List;
  discBlock     : Interrupt;
  discSync      : Interrupt;
  index         : Interrupt;
  currTask      : TaskPtr;
 END;

CONST

(* DiskResource.flags entries *)
  alloc0  = 0;      (* unit zero is allocated *)
  alloc1  = 1;      (* unit one is allocated *)
  alloc2  = 2;      (* unit two is allocated *)
  alloc3  = 3;      (* unit three is allocated *)
  active  = 7;      (* is the disc currently busy? *)



(********************************************************************
*
* Hardware Magic
*
********************************************************************)


  dskDMAOff = 4000H;   (* idle command for dsklen register *)


(********************************************************************
*
* Resource specific commands
*
********************************************************************)

(*
 * DISKNAME is a generic macro to get the name of the resource.
 * This way if the name is ever changed you will pick up the
 *  change automatically.
 *)

  diskName = "disk.resource";


(********************************************************************
*
* drive types
*
********************************************************************)

  amiga         = 000000000H;
  drt37422D2S   = 055555555H;
  empty         = 0FFFFFFFFH;
  drt150RPM     = 0AAAAAAAAH;



PROCEDURE AllocUnit(disk{Reg.A6}:DiscResourcePtr;unitNum{Reg.D0}:LONGINT):BOOLEAN; CODE -6;

PROCEDURE FreeUnit(disk{Reg.A6}:DiscResourcePtr;unitNum{Reg.D0}:LONGINT); CODE -12;

PROCEDURE GetUnit(disk{Reg.A6}:DiscResourcePtr;
                  unitPointer{Reg.A1}:DiscResourceUnitPtr):DiscResourceUnitPtr; CODE -18;

PROCEDURE GiveUnit(disk{Reg.A6}:DiscResourcePtr); CODE -24;

PROCEDURE GetUnitID(disk{Reg.A6}:DiscResourcePtr;
                    unitNum{Reg.D0}:LONGINT):LONGCARD; CODE -30;

PROCEDURE ReadUnitID(disk{Reg.A6}:DiscResourcePtr;
                     unitNum{Reg.D0}:LONGINT):LONGCARD; CODE -36;


END Disk.
