home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / inc&ad2.0 / includes / devices / trackdisk.h < prev    next >
C/C++ Source or Header  |  1992-09-01  |  8KB  |  262 lines

  1. #ifndef DEVICES_TRACKDISK_H
  2. #define DEVICES_TRACKDISK_H
  3.  
  4. /*
  5. **
  6. **    $Filename: devices/trackdisk.h $
  7. **    $Release: 2.04 Includes, V37.4 $
  8. **    $Revision: 33.13 $
  9. **    $Date: 90/11/28 $
  10. **
  11. **    trackdisk device structure and value definitions
  12. **
  13. **    (C) Copyright 1985-1991 Commodore-Amiga, Inc.
  14. **        All Rights Reserved
  15. **
  16. */
  17.  
  18. #ifndef EXEC_IO_H
  19. #include "exec/io.h"
  20. #endif
  21.  
  22. #ifndef EXEC_DEVICES_H
  23. #include "exec/devices.h"
  24. #endif
  25.  
  26. /*
  27.  *--------------------------------------------------------------------
  28.  *
  29.  * Physical drive constants
  30.  *
  31.  *--------------------------------------------------------------------
  32.  */
  33.  
  34. /* OBSOLETE -- use the TD_GETNUMTRACKS command! */
  35. /*#define    NUMCYLS    80*/        /*  normal # of cylinders */
  36. /*#define    MAXCYLS    (NUMCYLS+20)*/    /* max # cyls to look for during cal */
  37. /*#define    NUMHEADS 2*/
  38. /*#define    NUMTRACKS (NUMCYLS*NUMHEADS)*/
  39.  
  40. #define    NUMSECS    11
  41. #define NUMUNITS 4
  42.  
  43. /*
  44.  *--------------------------------------------------------------------
  45.  *
  46.  * Useful constants
  47.  *
  48.  *--------------------------------------------------------------------
  49.  */
  50.  
  51. /*-- sizes before mfm encoding */
  52. #define    TD_SECTOR 512
  53. #define    TD_SECSHIFT 9        /* log TD_SECTOR */
  54.  
  55. /*
  56.  *--------------------------------------------------------------------
  57.  *
  58.  * Driver Specific Commands
  59.  *
  60.  *--------------------------------------------------------------------
  61.  */
  62.  
  63. /*
  64.  *-- TD_NAME is a generic macro to get the name of the driver.    This
  65.  *-- way if the name is ever changed you will pick up the change
  66.  *-- automatically.
  67.  *--
  68.  *-- Normal usage would be:
  69.  *--
  70.  *-- char internalName[] = TD_NAME;
  71.  *--
  72.  */
  73.  
  74. #define    TD_NAME    "trackdisk.device"
  75.  
  76. #define    TDF_EXTCOM (1<<15)        /* for internal use only! */
  77.  
  78.  
  79. #define    TD_MOTOR    (CMD_NONSTD+0)    /* control the disk's motor */
  80. #define    TD_SEEK        (CMD_NONSTD+1)    /* explicit seek (for testing) */
  81. #define    TD_FORMAT    (CMD_NONSTD+2)    /* format disk */
  82. #define    TD_REMOVE    (CMD_NONSTD+3)    /* notify when disk changes */
  83. #define    TD_CHANGENUM    (CMD_NONSTD+4)    /* number of disk changes */
  84. #define    TD_CHANGESTATE    (CMD_NONSTD+5)    /* is there a disk in the drive? */
  85. #define    TD_PROTSTATUS    (CMD_NONSTD+6)    /* is the disk write protected? */
  86. #define    TD_RAWREAD    (CMD_NONSTD+7)    /* read raw bits from the disk */
  87. #define    TD_RAWWRITE    (CMD_NONSTD+8)    /* write raw bits to the disk */
  88. #define    TD_GETDRIVETYPE    (CMD_NONSTD+9)    /* get the type of the disk drive */
  89. #define    TD_GETNUMTRACKS    (CMD_NONSTD+10)    /* # of tracks for this type drive */
  90. #define    TD_ADDCHANGEINT    (CMD_NONSTD+11)    /* TD_REMOVE done right */
  91. #define    TD_REMCHANGEINT    (CMD_NONSTD+12)    /* remove softint set by ADDCHANGEINT */
  92. #define TD_GETGEOMETRY    (CMD_NONSTD+13) /* gets the disk geometry table */
  93. #define TD_EJECT    (CMD_NONSTD+14) /* for those drives that support it */
  94. #define    TD_LASTCOMM    (CMD_NONSTD+15)
  95.  
  96. /*
  97.  *
  98.  * The disk driver has an "extended command" facility.    These commands
  99.  * take a superset of the normal IO Request block.
  100.  *
  101.  */
  102.  
  103. #define    ETD_WRITE    (CMD_WRITE|TDF_EXTCOM)
  104. #define    ETD_READ    (CMD_READ|TDF_EXTCOM)
  105. #define    ETD_MOTOR    (TD_MOTOR|TDF_EXTCOM)
  106. #define    ETD_SEEK    (TD_SEEK|TDF_EXTCOM)
  107. #define    ETD_FORMAT    (TD_FORMAT|TDF_EXTCOM)
  108. #define    ETD_UPDATE    (CMD_UPDATE|TDF_EXTCOM)
  109. #define    ETD_CLEAR    (CMD_CLEAR|TDF_EXTCOM)
  110. #define    ETD_RAWREAD    (TD_RAWREAD|TDF_EXTCOM)
  111. #define    ETD_RAWWRITE    (TD_RAWWRITE|TDF_EXTCOM)
  112.  
  113. /*
  114.  *
  115.  * extended IO has a larger than normal io request block.
  116.  *
  117.  */
  118.  
  119. struct IOExtTD {
  120.     struct    IOStdReq iotd_Req;
  121.     ULONG    iotd_Count;
  122.     ULONG    iotd_SecLabel;
  123. };
  124.  
  125. /*
  126.  *  This is the structure returned by TD_DRIVEGEOMETRY
  127.  *  Note that the layout can be defined three ways:
  128.  *
  129.  *  1. TotalSectors
  130.  *  2. Cylinders and CylSectors
  131.  *  3. Cylinders, Heads, and TrackSectors.
  132.  *
  133.  *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
  134.  *  are usable, though #2 and #3 may waste some portion of the available
  135.  *  space on some drives.
  136.  */
  137. struct DriveGeometry {
  138.     ULONG    dg_SectorSize;        /* in bytes */
  139.     ULONG    dg_TotalSectors;    /* total # of sectors on drive */
  140.     ULONG    dg_Cylinders;        /* number of cylinders */
  141.     ULONG    dg_CylSectors;        /* number of sectors/cylinder */
  142.     ULONG    dg_Heads;        /* number of surfaces */
  143.     ULONG    dg_TrackSectors;    /* number of sectors/track */
  144.     ULONG    dg_BufMemType;        /* preferred buffer memory type */
  145.                     /* (usually MEMF_PUBLIC) */
  146.     UBYTE    dg_DeviceType;        /* codes as defined in the SCSI-2 spec*/
  147.     UBYTE    dg_Flags;        /* flags, including removable */
  148.     UWORD    dg_Reserved;
  149. };
  150.  
  151. /* device types */
  152. #define DG_DIRECT_ACCESS    0
  153. #define DG_SEQUENTIAL_ACCESS    1
  154. #define DG_PRINTER        2
  155. #define DG_PROCESSOR        3
  156. #define DG_WORM            4
  157. #define DG_CDROM        5
  158. #define DG_SCANNER        6
  159. #define DG_OPTICAL_DISK        7
  160. #define DG_MEDIUM_CHANGER    8
  161. #define DG_COMMUNICATION    9
  162. #define DG_UNKNOWN        31
  163.  
  164. /* flags */
  165. #define DGB_REMOVABLE        0
  166. #define DGF_REMOVABLE        1
  167.  
  168. /*
  169. ** raw read and write can be synced with the index pulse.  This flag
  170. ** in io request's IO_FLAGS field tells the driver that you want this.
  171. */
  172.  
  173. #define IOTDB_INDEXSYNC    4
  174. #define IOTDF_INDEXSYNC (1<<4)
  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. #define IOTDB_WORDSYNC    5
  180. #define IOTDF_WORDSYNC (1<<5)
  181.  
  182.  
  183. /* labels are TD_LABELSIZE bytes per sector */
  184.  
  185. #define    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. #define TDB_ALLOW_NON_3_5    0
  194. #define TDF_ALLOW_NON_3_5    (1<<0)
  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. #define    DRIVE3_5    1
  204. #define    DRIVE5_25    2
  205. #define    DRIVE3_5_150RPM    3
  206.  
  207. /*
  208.  *--------------------------------------------------------------------
  209.  *
  210.  * Driver error defines
  211.  *
  212.  *--------------------------------------------------------------------
  213.  */
  214.  
  215. #define    TDERR_NotSpecified    20    /* general catchall */
  216. #define    TDERR_NoSecHdr        21    /* couldn't even find a sector */
  217. #define    TDERR_BadSecPreamble    22    /* sector looked wrong */
  218. #define    TDERR_BadSecID        23    /* ditto */
  219. #define    TDERR_BadHdrSum        24    /* header had incorrect checksum */
  220. #define    TDERR_BadSecSum        25    /* data had incorrect checksum */
  221. #define    TDERR_TooFewSecs    26    /* couldn't find enough sectors */
  222. #define    TDERR_BadSecHdr        27    /* another "sector looked wrong" */
  223. #define    TDERR_WriteProt        28    /* can't write to a protected disk */
  224. #define    TDERR_DiskChanged    29    /* no disk in the drive */
  225. #define    TDERR_SeekError        30    /* couldn't find track 0 */
  226. #define    TDERR_NoMem        31    /* ran out of memory */
  227. #define    TDERR_BadUnitNum    32    /* asked for a unit > NUMUNITS */
  228. #define    TDERR_BadDriveType    33    /* not a drive that trackdisk groks */
  229. #define    TDERR_DriveInUse    34    /* someone else allocated the drive */
  230. #define    TDERR_PostReset        35    /* user hit reset; awaiting doom */
  231.  
  232. /*
  233.  *--------------------------------------------------------------------
  234.  *
  235.  * public portion of the unit structure
  236.  *
  237.  *--------------------------------------------------------------------
  238.  */
  239.  
  240. struct TDU_PublicUnit {
  241.     struct    Unit tdu_Unit;        /* base message port */
  242.     UWORD    tdu_Comp01Track;    /* track for first precomp */
  243.     UWORD    tdu_Comp10Track;    /* track for second precomp */
  244.     UWORD    tdu_Comp11Track;    /* track for third precomp */
  245.     ULONG    tdu_StepDelay;        /* time to wait after stepping */
  246.     ULONG    tdu_SettleDelay;    /* time to wait after seeking */
  247.     UBYTE    tdu_RetryCnt;        /* # of times to retry */
  248.     UBYTE    tdu_PubFlags;        /* public flags, see below */
  249.     UWORD    tdu_CurrTrk;        /* track the heads are over... */
  250.                     /* ONLY ACCESS WHILE UNIT IS STOPPED! */
  251.     ULONG    tdu_CalibrateDelay;    /* time to wait after stepping */
  252.                     /* during a recalibrate */
  253.     ULONG    tdu_Counter;        /* counter for disk changes... */
  254.                     /* ONLY ACCESS WHILE UNIT IS STOPPED! */
  255. };
  256.  
  257. /* flags for tdu_PubFlags */
  258. #define TDPB_NOCLICK    0
  259. #define TDPF_NOCLICK    (1L << 0)
  260.  
  261. #endif    /* DEVICES_TRACKDISK_H */
  262.