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