trackdisk.pas 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit trackdisk;
  13. INTERFACE
  14. uses exec;
  15. {
  16. *--------------------------------------------------------------------
  17. *
  18. * Physical drive constants
  19. *
  20. *--------------------------------------------------------------------
  21. }
  22. Const
  23. NUMSECS = 11;
  24. NUMUNITS = 4;
  25. {
  26. *--------------------------------------------------------------------
  27. *
  28. * Useful constants
  29. *
  30. *--------------------------------------------------------------------
  31. }
  32. {-- sizes before mfm encoding }
  33. TD_SECTOR = 512;
  34. TD_SECSHIFT = 9; { log TD_SECTOR }
  35. {
  36. *--------------------------------------------------------------------
  37. *
  38. * Driver Specific Commands
  39. *
  40. *--------------------------------------------------------------------
  41. }
  42. {
  43. *-- TD_NAME is a generic macro to get the name of the driver. This
  44. *-- way if the name is ever changed you will pick up the change
  45. *-- automatically.
  46. *--
  47. *-- Normal usage would be:
  48. *--
  49. *-- char internalName[] = TD_NAME;
  50. *--
  51. }
  52. TD_NAME : PChar = 'trackdisk.device';
  53. TDF_EXTCOM = $00010000; { for internal use only! }
  54. TD_MOTOR = CMD_NONSTD + 0; { control the disk's motor }
  55. TD_SEEK = CMD_NONSTD + 1; { explicit seek (for testing) }
  56. TD_FORMAT = CMD_NONSTD + 2; { format disk }
  57. TD_REMOVE = CMD_NONSTD + 3; { notify when disk changes }
  58. TD_CHANGENUM = CMD_NONSTD + 4; { number of disk changes }
  59. TD_CHANGESTATE = CMD_NONSTD + 5; { is there a disk in the drive? }
  60. TD_PROTSTATUS = CMD_NONSTD + 6; { is the disk write protected? }
  61. TD_RAWREAD = CMD_NONSTD + 7; { read raw bits from the disk }
  62. TD_RAWWRITE = CMD_NONSTD + 8; { write raw bits to the disk }
  63. TD_GETDRIVETYPE = CMD_NONSTD + 9; { get the type of the disk drive }
  64. TD_GETNUMTRACKS = CMD_NONSTD + 10; { # of tracks for this type drive }
  65. TD_ADDCHANGEINT = CMD_NONSTD + 11; { TD_REMOVE done right }
  66. TD_REMCHANGEINT = CMD_NONSTD + 12; { remove softint set by ADDCHANGEINT }
  67. TD_GETGEOMETRY = CMD_NONSTD + 13;
  68. TD_EJECT = CMD_NONSTD + 14; { for those drives that support it }
  69. TD_LASTCOMM = CMD_NONSTD + 15;
  70. {
  71. *
  72. * The disk driver has an "extended command" facility. These commands
  73. * take a superset of the normal IO Request block.
  74. *
  75. }
  76. ETD_WRITE = CMD_WRITE + TDF_EXTCOM;
  77. ETD_READ = CMD_READ + TDF_EXTCOM;
  78. ETD_MOTOR = TD_MOTOR + TDF_EXTCOM;
  79. ETD_SEEK = TD_SEEK + TDF_EXTCOM;
  80. ETD_FORMAT = TD_FORMAT + TDF_EXTCOM;
  81. ETD_UPDATE = CMD_UPDATE + TDF_EXTCOM;
  82. ETD_CLEAR = CMD_CLEAR + TDF_EXTCOM;
  83. ETD_RAWREAD = TD_RAWREAD + TDF_EXTCOM;
  84. ETD_RAWWRITE = TD_RAWWRITE + TDF_EXTCOM;
  85. {
  86. *
  87. * extended IO has a larger than normal io request block.
  88. *
  89. }
  90. Type
  91. pIOExtTD = ^tIOExtTD;
  92. tIOExtTD = record
  93. iotd_Req : tIOStdReq;
  94. iotd_Count : ULONG;
  95. iotd_SecLabel : ULONG;
  96. end;
  97. {
  98. * This is the structure returned by TD_DRIVEGEOMETRY
  99. * Note that the layout can be defined three ways:
  100. *
  101. * 1. TotalSectors
  102. * 2. Cylinders and CylSectors
  103. * 3. Cylinders, Heads, and TrackSectors.
  104. *
  105. * #1 is most accurate, #2 is less so, and #3 is least accurate. All
  106. * are usable, though #2 and #3 may waste some portion of the available
  107. * space on some drives.
  108. }
  109. pDriveGeometry = ^tDriveGeometry;
  110. tDriveGeometry = record
  111. dg_SectorSize, { in bytes }
  112. dg_TotalSectors, { total # of sectors on drive }
  113. dg_Cylinders, { number of cylinders }
  114. dg_CylSectors, { number of sectors/cylinder }
  115. dg_Heads, { number of surfaces }
  116. dg_TrackSectors, { number of sectors/track }
  117. dg_BufMemType : ULONG; { preferred buffer memory type }
  118. { (usually MEMF_PUBLIC) }
  119. dg_DeviceType, { codes as defined in the SCSI-2 spec}
  120. dg_Flags : Byte; { flags, including removable }
  121. dg_Reserved : Word;
  122. END;
  123. Const
  124. { device types }
  125. DG_DIRECT_ACCESS = 0 ;
  126. DG_SEQUENTIAL_ACCESS = 1 ;
  127. DG_PRINTER = 2 ;
  128. DG_PROCESSOR = 3 ;
  129. DG_WORM = 4 ;
  130. DG_CDROM = 5 ;
  131. DG_SCANNER = 6 ;
  132. DG_OPTICAL_DISK = 7 ;
  133. DG_MEDIUM_CHANGER = 8 ;
  134. DG_COMMUNICATION = 9 ;
  135. DG_UNKNOWN = 31;
  136. { flags }
  137. DGB_REMOVABLE = 0;
  138. DGF_REMOVABLE = 1;
  139. {
  140. ** raw read and write can be synced with the index pulse. This flag
  141. ** in io request's IO_FLAGS field tells the driver that you want this.
  142. }
  143. IOTDB_INDEXSYNC = 4;
  144. IOTDF_INDEXSYNC = 16;
  145. {
  146. ** raw read and write can be synced with a $4489 sync pattern. This flag
  147. ** in io request's IO_FLAGS field tells the driver that you want this.
  148. }
  149. IOTDB_WORDSYNC = 5;
  150. IOTDF_WORDSYNC = 32;
  151. { labels are TD_LABELSIZE bytes per sector }
  152. TD_LABELSIZE = 16;
  153. {
  154. ** This is a bit in the FLAGS field of OpenDevice. If it is set, then
  155. ** the driver will allow you to open all the disks that the trackdisk
  156. ** driver understands. Otherwise only 3.5" disks will succeed.
  157. }
  158. TDB_ALLOW_NON_3_5 = 0;
  159. TDF_ALLOW_NON_3_5 = 1;
  160. {
  161. ** If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
  162. ** know what type of disk you really got. These defines are for the
  163. ** TD_GETDRIVETYPE command. In addition, you can find out how many
  164. ** tracks are supported via the TD_GETNUMTRACKS command.
  165. }
  166. DRIVE3_5 = 1;
  167. DRIVE5_25 = 2;
  168. DRIVE3_5_150RPM = 3;
  169. {
  170. *--------------------------------------------------------------------
  171. *
  172. * Driver error defines
  173. *
  174. *--------------------------------------------------------------------
  175. }
  176. TDERR_NotSpecified = 20; { general catchall }
  177. TDERR_NoSecHdr = 21; { couldn't even find a sector }
  178. TDERR_BadSecPreamble = 22; { sector looked wrong }
  179. TDERR_BadSecID = 23; { ditto }
  180. TDERR_BadHdrSum = 24; { header had incorrect checksum }
  181. TDERR_BadSecSum = 25; { data had incorrect checksum }
  182. TDERR_TooFewSecs = 26; { couldn't find enough sectors }
  183. TDERR_BadSecHdr = 27; { another "sector looked wrong" }
  184. TDERR_WriteProt = 28; { can't write to a protected disk }
  185. TDERR_DiskChanged = 29; { no disk in the drive }
  186. TDERR_SeekError = 30; { couldn't find track 0 }
  187. TDERR_NoMem = 31; { ran out of memory }
  188. TDERR_BadUnitNum = 32; { asked for a unit > NUMUNITS }
  189. TDERR_BadDriveType = 33; { not a drive that trackdisk groks }
  190. TDERR_DriveInUse = 34; { someone else allocated the drive }
  191. TDERR_PostReset = 35; { user hit reset; awaiting doom }
  192. {
  193. *--------------------------------------------------------------------
  194. *
  195. * public portion of the unit structure
  196. *
  197. *--------------------------------------------------------------------
  198. }
  199. Type
  200. pTDU_PublicUnit = ^tTDU_PublicUnit;
  201. tTDU_PublicUnit = record
  202. tdu_Unit : tUnit; { base message port }
  203. tdu_Comp01Track : Word; { track for first precomp }
  204. tdu_Comp10Track : Word; { track for second precomp }
  205. tdu_Comp11Track : Word; { track for third precomp }
  206. tdu_StepDelay : ULONG; { time to wait after stepping }
  207. tdu_SettleDelay : ULONG; { time to wait after seeking }
  208. tdu_RetryCnt : Byte; { # of times to retry }
  209. tdu_PubFlags : Byte; { public flags, see below }
  210. tdu_CurrTrk : Word; { track the heads are over... }
  211. { ONLY ACCESS WHILE UNIT IS STOPPED! }
  212. tdu_CalibrateDelay : ULONG; { time to wait after stepping }
  213. { during a recalibrate }
  214. tdu_Counter : ULONG; { counter for disk changes... }
  215. { ONLY ACCESS WHILE UNIT IS STOPPED! }
  216. end;
  217. CONST
  218. { flags for tdu_PubFlags }
  219. TDPB_NOCLICK = 0;
  220. TDPF_NOCLICK = 1;
  221. IMPLEMENTATION
  222. end.