home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D4.DMS / in.adf / Interfaces / TrackDisk.mod < prev    next >
Encoding:
Text File  |  1992-12-17  |  8.5 KB  |  260 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                                                                         *)
  3. (*  Amiga Oberon Interface Module:                    Date: 02-Nov-92      *)
  4. (*                                                                         *)
  5. (*   © 1992 by Fridtjof Siebert                                            *)
  6. (*                                                                         *)
  7. (*-------------------------------------------------------------------------*)
  8.  
  9. MODULE TrackDisk;   (* $Implementation- *)
  10.  
  11. IMPORT e * := Exec;
  12.  
  13.  
  14. (*
  15.  *--------------------------------------------------------------------
  16.  *
  17.  * Physical drive constants
  18.  *
  19.  *--------------------------------------------------------------------
  20.  *)
  21.  
  22. (* OBSOLETE -- use the TD_GETNUMTRACKS command! *)
  23. (*#define       NUMCYLS 80*)            (*  normal # of cylinders *)
  24. (*#define       MAXCYLS (NUMCYLS+20)*)  (* max # cyls to look for during cal *)
  25. (*#define       NUMHEADS 2*)
  26. (*#define       NUMTRACKS (NUMCYLS*NUMHEADS)*)
  27.  
  28. CONST
  29.  
  30.   numSecs * = 11;
  31.   numUnits * = 4;
  32.  
  33.  
  34. (*
  35.  *--------------------------------------------------------------------
  36.  *
  37.  * Useful constants
  38.  *
  39.  *--------------------------------------------------------------------
  40.  *)
  41.  
  42. (*-- sizes before mfm encoding *)
  43.   sector * = 512;
  44.   secShift * = 9;    (* log TD_SECTOR *)
  45.  
  46. (*
  47.  *--------------------------------------------------------------------
  48.  *
  49.  * Driver Specific Commands
  50.  *
  51.  *--------------------------------------------------------------------
  52.  *)
  53.  
  54. (*
  55.  *-- TD_NAME is a generic macro to get the name of the driver.  This
  56.  *-- way if the name is ever changed you will pick up the change
  57.  *-- automatically.
  58.  *--
  59.  *-- Normal usage would be:
  60.  *--
  61.  *-- char internalName[] = TD_NAME;
  62.  *--
  63.  *)
  64.  
  65.   name * = "trackdisk.device";
  66.  
  67.   extCom * = 8000U;                (* for internal use only! *)
  68.  
  69.  
  70.   motor        * = e.nonstd+0;  (* control the disk's motor *)
  71.   seek         * = e.nonstd+1;  (* explicit seek (for testing) *)
  72.   format       * = e.nonstd+2;  (* format disk *)
  73.   remove       * = e.nonstd+3;  (* notify when disk changes *)
  74.   changeNum    * = e.nonstd+4;  (* number of disk changes *)
  75.   changeState  * = e.nonstd+5;  (* is there a disk in the drive? *)
  76.   protStatus   * = e.nonstd+6;  (* is the disk write protected? *)
  77.   rawRead      * = e.nonstd+7;  (* read raw bits from the disk *)
  78.   rawWrite     * = e.nonstd+8;  (* write raw bits to the disk *)
  79.   getDriveType * = e.nonstd+9;  (* get the type of the disk drive *)
  80.   getNumTracks * = e.nonstd+10; (* # of tracks for this type drive *)
  81.   addChangeInt * = e.nonstd+11; (* TD_REMOVE done right *)
  82.   remChangeInt * = e.nonstd+12; (* remove softint set by ADDCHANGEINT *)
  83.   getGeometry  * = e.nonstd+13; (* gets the disk geometry table *)
  84.   eject        * = e.nonstd+14; (* for those drives that support it *)
  85.   lastcomm     * = e.nonstd+15;
  86.  
  87. (*
  88.  *
  89.  * The disk driver has an "extended command" facility.  These commands
  90.  * take a superset of the normal IO Request block.
  91.  *
  92.  *)
  93.  
  94.   extWrite       * = e.write  + extCom;
  95.   extRead        * = e.read   + extCom;
  96.   extMotor       * = motor    + extCom;
  97.   extSeek        * = seek     + extCom;
  98.   extFormat      * = format   + extCom;
  99.   extUpdate      * = e.update + extCom;
  100.   extClear       * = e.clear  + extCom;
  101.   extRawRead     * = rawRead  + extCom;
  102.   extRawWrite    * = rawWrite + extCom;
  103.  
  104. TYPE
  105.  
  106. (*
  107.  *
  108.  * extended IO has a larger than normal io request block.
  109.  *
  110.  *)
  111.  
  112.   IOExtTDPtr * = UNTRACED POINTER TO IOExtTD;
  113.   IOExtTD * = STRUCT (req * : e.IOStdReq)
  114.     count * : LONGINT;
  115.     secLabel * : LONGINT;
  116.   END;
  117.  
  118. (*
  119.  *  This is the structure returned by TD_DRIVEGEOMETRY
  120.  *  Note that the layout can be defined three ways:
  121.  *
  122.  *  1. TotalSectors
  123.  *  2. Cylinders and CylSectors
  124.  *  3. Cylinders, Heads, and TrackSectors.
  125.  *
  126.  *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
  127.  *  are usable, though #2 and #3 may waste some portion of the available
  128.  *  space on some drives.
  129.  *)
  130.  
  131.   DriveGeometryPtr * = UNTRACED POINTER TO DriveGeometry;
  132.   DriveGeometry * = STRUCT
  133.     sectorSize * : LONGINT;          (* in bytes *)
  134.     totalSectors * : LONGINT;        (* total # of sectors on drive *)
  135.     cylinders * : LONGINT;           (* number of cylinders *)
  136.     cylSectors * : LONGINT;          (* number of sectors/cylinder *)
  137.     heads * : LONGINT;               (* number of surfaces *)
  138.     trackSectors * : LONGINT;        (* number of sectors/track *)
  139.     bufMemType * : LONGINT;          (* preferred buffer memory type *)
  140.                             (* (usually MEMF_PUBLIC) *)
  141.     deviceType * : SHORTINT;          (* codes as defined in the SCSI-2 spec*)
  142.     flags * : SHORTSET;               (* flags, including removable *)
  143.     reserved * : INTEGER;
  144.   END;
  145.  
  146. CONST
  147.  
  148. (* device types *)
  149.   directAccess     * = 0;
  150.   sequentialAccess * = 1;
  151.   printer          * = 2;
  152.   processor        * = 3;
  153.   worm             * = 4;
  154.   cdRom            * = 5;
  155.   scanner          * = 6;
  156.   opticalDisk      * = 7;
  157.   mediumChanger    * = 8;
  158.   communication    * = 9;
  159.   unknown          * = 31;
  160.  
  161. (* flags *)
  162.   removable        * = 0;
  163.  
  164. (*
  165. ** raw read and write can be synced with the index pulse.  This flag
  166. ** in io request's IO_FLAGS field tells the driver that you want this.
  167. *)
  168.  
  169.   indexSync        * = 4;
  170.  
  171. (*
  172. ** raw read and write can be synced with a 04489H sync pattern.  This flag
  173. ** in io request's IO_FLAGS field tells the driver that you want this.
  174. *)
  175.   wordSync         * = 5;
  176.  
  177.  
  178. (* labels are TD_LABELSIZE bytes per sector *)
  179.  
  180.   labelSize        * = 16;
  181.  
  182. (*
  183. ** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
  184. ** the driver will allow you to open all the disks that the trackdisk
  185. ** driver understands.  Otherwise only 3.5" disks will succeed.
  186. *)
  187.  
  188.   allowNon35       * = 0;
  189.  
  190. (*
  191. **  If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
  192. **  know what type of disk you really got.  These defines are for the
  193. **  TD_GETDRIVETYPE command.  In addition, you can find out how many
  194. **  tracks are supported via the TD_GETNUMTRACKS command.
  195. *)
  196.  
  197.   drive35          * = 1;
  198.   drive525         * = 2;
  199.   drvie35150rpm    * = 3;
  200.  
  201. (*
  202.  *--------------------------------------------------------------------
  203.  *
  204.  * Driver error defines
  205.  *
  206.  *--------------------------------------------------------------------
  207.  *)
  208.  
  209.   notSpecified      * = 20;      (* general catchall *)
  210.   noSecHdr          * = 21;      (* couldn't even find a sector *)
  211.   badSecPreamble    * = 22;      (* sector looked wrong *)
  212.   badSecID          * = 23;      (* ditto *)
  213.   badHdrSum         * = 24;      (* header had incorrect checksum *)
  214.   badSecSum         * = 25;      (* data had incorrect checksum *)
  215.   tooFewSecs        * = 26;      (* couldn't find enough sectors *)
  216.   badSecHdr         * = 27;      (* another "sector looked wrong" *)
  217.   writeProt         * = 28;      (* can't write to a protected disk *)
  218.   diskChanged       * = 29;      (* no disk in the drive *)
  219.   seekError         * = 30;      (* couldn't find track 0 *)
  220.   noMem             * = 31;      (* ran out of memory *)
  221.   badUnitNum        * = 32;      (* asked for a unit > NUMUNITS *)
  222.   badDriveType      * = 33;      (* not a drive that trackdisk groks *)
  223.   driveInUse        * = 34;      (* someone else allocated the drive *)
  224.   postReset         * = 35;      (* user hit reset; awaiting doom *)
  225.  
  226. TYPE
  227.  
  228. (*
  229.  *--------------------------------------------------------------------
  230.  *
  231.  * public portion of the unit structure
  232.  *
  233.  *--------------------------------------------------------------------
  234.  *)
  235.  
  236.   PublicUnitPtr * = UNTRACED POINTER TO PublicUnit;
  237.   PublicUnit * = STRUCT (unit * : e.Unit)          (* base message port *)
  238.     comp01Track * : INTEGER;        (* track for first precomp *)
  239.     comp10Track * : INTEGER;        (* track for second precomp *)
  240.     comp11Track * : INTEGER;        (* track for third precomp *)
  241.     stepDelay * : LONGINT;          (* time to wait after stepping *)
  242.     settleDelay * : LONGINT;        (* time to wait after seeking *)
  243.     retryCnt * : SHORTINT;          (* # of times to retry *)
  244.     pubFlags * : SHORTSET;          (* public flags, see below *)
  245.     currTrk * : INTEGER;            (* track the heads are over... *)
  246.                                     (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  247.     calibrateDelay * : LONGINT;     (* time to wait after stepping *)
  248.                                     (* during a recalibrate *)
  249.     counter * : LONGINT;            (* counter for disk changes... *)
  250.                                     (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  251.   END;
  252.  
  253. CONST
  254.  
  255. (* flags for tdu_PubFlags *)
  256.   noClick          * = 0;
  257.  
  258. END TrackDisk.
  259.  
  260.