home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / atapi_pnp300 / developer_kit / atapi_cd.h next >
C/C++ Source or Header  |  1977-12-31  |  17KB  |  384 lines

  1. #ifndef ATAPI_CD_H
  2. #define ATAPI_CD_H
  3. /*
  4. **      $VER: atapi_cd.h 3.0 (1.9.96)
  5. **
  6. **      atapi.device include file
  7. **
  8. **      (C) Copyright 1995 1996  G. Campana M.Campinoti
  9. **          All Rights Reserved
  10. */
  11.  
  12. #include <exec/types.h>
  13. #include <exec/nodes.h>
  14.  
  15. /**************************************************************************
  16.  *                                                                        *
  17.  *   ATAPI Task Alerts Errors                                             *
  18.  *                                                                        *
  19.  **************************************************************************/
  20.  
  21. #define AATP_General    0
  22.  
  23.  
  24.  
  25.  
  26. /**************************************************************************
  27.  *                                                                        *
  28.  *   ATAPI CD Commands                                                    *
  29.  *                                                                        *
  30.  **************************************************************************/
  31.  
  32. #define CD_RESET             1  /* Private !*/
  33. #define CD_READ              2
  34. #define CD_WRITE             3  /* WriteProtected error */
  35. #define CD_UPDATE            4  /* empty call */
  36. #define CD_CLEAR             5  /* empty call */
  37. #define CD_STOP              6
  38. #define CD_START             7
  39. #define CD_FLUSH             8
  40. #define CD_MOTOR             9  /* empty call */
  41. #define CD_SEEK             10
  42.  
  43.  
  44. /* 
  45. #define CD_REMOVE           12 
  46. */
  47.  
  48. #define CD_CHANGENUM        13  /* supports Quick */
  49. #define CD_CHANGESTATE      14
  50. #define CD_PROTSTATUS       15  /* always return 1 (write protected) */
  51.  
  52. #define CD_ADDCHANGEINT     20
  53. #define CD_REMCHANGEINT     21  /* Immediate */
  54. #define CD_GETGEOMETRY      22
  55. #define CD_EJECT            23
  56.  
  57.  
  58. #define CD_SCSI_DIRECT      28  /* compatible w. HD_SCSICMD   */
  59.  
  60.  
  61. #define CD_INFO             32
  62. #define CD_CONFIG           33
  63. #define CD_TOCMSF           34
  64. #define CD_TOCLSN           35
  65.  
  66. #define CD_READXL           36
  67.  
  68. #define CD_PLAYTRACK        37
  69. #define CD_PLAYMSF          38
  70. #define CD_PLAYLSN          39
  71. #define CD_PAUSE            40
  72. #define CD_SEARCH           41   /* Not supported at the present */
  73.  
  74. #define CD_QCODEMSF         42
  75. #define CD_QCODELSN         43
  76. #define CD_ATTENUATE        44
  77.  
  78. #define CD_ADDFRAMEINT      45   /* Not supported at the present */
  79. #define CD_REMFRAMEINT      46   /* Not supported at the present */
  80.  
  81. /******** NewStyle Commands *************/
  82.  
  83. #define NSCMD_DEVICEQUERY   0x4000     // Return the Newstyle Query Infos
  84.  
  85.  
  86. /****** 64 bit *****/
  87. #define NSCMD_TD_READ64     0xc000
  88. #define NSCMD_TD_WRITE64    0xc001
  89. #define NSCMD_TD_SEEK64     0xc002
  90. #define NSCMD_TD_FORMAT64   0xc003
  91.  
  92.  
  93. /***  Reserved and obsolete ******/
  94. #define CD_Reserved         0x7fff
  95. #define CD_ATAPI_IDENTIFY   0x7fff
  96. /*********************************/
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. /**************************************************************************
  105.  *                                                                        *
  106.  *   NewStyle Query Info structure                                        *
  107.  *                                                                        *
  108.  **************************************************************************/
  109.  
  110.  
  111. struct NSDeviceQueryResult
  112. {
  113.     /*
  114.     ** Standard information
  115.     */
  116.     ULONG   DevQueryFormat;         /* this is type 0               */
  117.     ULONG   SizeAvailable;          /* bytes available              */
  118.  
  119.     /*
  120.     ** Common information (READ ONLY!)
  121.     */
  122.     UWORD   DeviceType;             /* what the device does         */
  123.     UWORD   DeviceSubType;          /* depends on the main type     */
  124.     UWORD   *SupportedCommands;     /* 0 terminated list of cmd's   */
  125.  
  126.     /* May be extended in the future! Check SizeAvailable! */
  127. };
  128.  
  129. /****** Device Type **********/
  130. #define NSDEVTYPE_TRACKDISK     5   /* cd.device is like trackdisk.device */
  131.  
  132.  
  133.  
  134. /**************************************************************************
  135.  *                                                                        *
  136.  *   Device Driver Error Codes                                            *
  137.  *                                                                        *
  138.  **************************************************************************/
  139.  
  140. #define CDERR_OPENFAIL       (-1) /* device/unit failed to open   */
  141. #define CDERR_ABORTED        (-2) /* request terminated early             */
  142. #define CDERR_NOCMD          (-3) /* command not supported by device      */
  143. #define CDERR_BADLENGTH      (-4) /* invalid length (IO_LENGTH/IO_OFFSET) */
  144. #define CDERR_BADADDRESS     (-5) /* invalid address (IO_DATA misaligned) */
  145. #define CDERR_UNITBUSY       (-6) /* device opens ok, but unit is busy    */
  146. #define CDERR_SELFTEST       (-7) /* hardware failed self-test            */
  147.  
  148. #define CDERR_NotSpecified   20   /* general catchall                     */
  149. #define CDERR_NoSecHdr       21   /* couldn't even find a sector          */
  150. #define CDERR_BadSecPreamble 22   /* sector looked wrong                  */
  151. #define CDERR_BadSecID       23   /* ditto                                */
  152. #define CDERR_BadHdrSum      24   /* header had incorrect checksum        */
  153. #define CDERR_BadSecSum      25   /* data had incorrect checksum          */
  154. #define CDERR_TooFewSecs     26   /* couldn't find enough sectors         */
  155. #define CDERR_BadSecHdr      27   /* another "sector looked wrong"        */
  156. #define CDERR_WriteProt      28   /* can't write to a protected disk      */
  157. #define CDERR_NoDisk         29   /* no disk in the drive                 */
  158. #define CDERR_SeekError      30   /* couldn't find track 0                */
  159. #define CDERR_NoMem          31   /* ran out of memory                    */
  160. #define CDERR_BadUnitNum     32   /* asked for a unit > NUMUNITS          */
  161. #define CDERR_BadDriveType   33   /* not a drive cd.device understands    */
  162. #define CDERR_DriveInUse     34   /* someone else allocated the drive     */
  163. #define CDERR_PostReset      35   /* user hit reset; awaiting doom        */
  164. #define CDERR_BadDataType    36   /* data on disk is wrong type   */
  165. #define CDERR_InvalidState   37   /* invalid cmd under current conditions */
  166.  
  167. #define CDERR_Phase          42   /* illegal or unexpected SCSI phase     */
  168. #define CDERR_NoBoard        50   /* open failed for non-existant board   */
  169.  
  170.  
  171.  
  172. /**************************************************************************
  173.  *                                                                        *
  174.  * Configuration                                                          *
  175.  *                                                                        *
  176.  *       The drive is configured by TagList items defined as follows:     *
  177.  *                                                                        *
  178.  **************************************************************************/
  179.  
  180. #define TAGCD_PLAYSPEED 0x0001
  181. #define TAGCD_READSPEED 0x0002
  182. #define TAGCD_READXLSPEED       0x0003
  183. #define TAGCD_SECTORSIZE        0x0004
  184. #define TAGCD_XLECC             0x0005
  185. #define TAGCD_EJECTRESET        0x0006
  186.  
  187.  
  188. /**************************************************************************
  189.  *                                                                        *
  190.  * Information                                                            *
  191.  *                                                                        *
  192.  *      Information/Status structure describes current speed settings     *
  193.  *      for read and play commands, sector size, audio attenuation        *
  194.  *      precision, and drive status.                                      *
  195.  *                                                                        *
  196.  **************************************************************************/
  197.  
  198. struct CDInfo {
  199.                             /*                                Default     */
  200.     UWORD   PlaySpeed;      /* Audio play speed       (75)        */
  201.     UWORD   ReadSpeed;      /* Data-rate of CD_READ command   (Max)       */
  202.     UWORD   ReadXLSpeed;    /* Data-rate of CD_READXL command (75)        */
  203.     UWORD   SectorSize;     /* Number of bytes per sector     (2048)      */
  204.     UWORD   XLECC;          /* CDXL ECC enabled/disabled                  */
  205.     UWORD   EjectReset;     /* Reset on eject enabled/disabled            */
  206.     UWORD   Reserved1[4];   /* Reserved for future expansion              */
  207.  
  208.     UWORD   MaxSpeed;       /* Maximum speed drive can handle (75, 150)   */
  209.     UWORD   AudioPrecision; /* 0 = no attenuator, 1 = mute only,          */
  210.                             /* other = (# levels - 1)                     */
  211.     UWORD   Status;         /* See flags below                            */
  212.     UWORD   Reserved2[4];   /* Reserved for future expansion              */
  213.     };
  214.  
  215.  
  216. /* Flags for Status */
  217.  
  218. #define CDSTSB_CLOSED    0 /* Drive door is closed                        */
  219. #define CDSTSB_DISK      1 /* A disk has been detected                    */
  220. #define CDSTSB_SPIN      2 /* Disk is spinning (motor is on)              */
  221. #define CDSTSB_TOC       3 /* Table of contents read.  Disk is valid.     */
  222. #define CDSTSB_CDROM     4 /* Track 1 contains CD-ROM data                */
  223. #define CDSTSB_PLAYING   5 /* Audio is playing                            */
  224. #define CDSTSB_PAUSED    6 /* Pause mode (pauses on play command)         */
  225. #define CDSTSB_SEARCH    7 /* Search mode (Fast Forward/Fast Reverse)     */
  226. #define CDSTSB_DIRECTION 8 /* Search direction (0 = Forward, 1 = Reverse) */
  227.  
  228. #define CDSTSF_CLOSED    0x0001
  229. #define CDSTSF_DISK      0x0002
  230. #define CDSTSF_SPIN      0x0004
  231. #define CDSTSF_TOC       0x0008
  232. #define CDSTSF_CDROM     0x0010
  233. #define CDSTSF_PLAYING   0x0020
  234. #define CDSTSF_PAUSED    0x0040
  235. #define CDSTSF_SEARCH    0x0080
  236. #define CDSTSF_DIRECTION 0x0100
  237.  
  238.  
  239. /* Modes for CD_SEARCH */
  240.  
  241. #define CDMODE_NORMAL   0         /* Normal play at current play speed    */
  242. #define CDMODE_FFWD     1         /* Fast forward play (skip-play forward)*/
  243. #define CDMODE_FREV     2         /* Fast reverse play (skip-play reverse)*/
  244.  
  245.  
  246. /**************************************************************************
  247.  *                                                                        *
  248.  * Position Information                                           *
  249.  *                                                                        *
  250.  *      Position information can be described in two forms: MSF and LSN   *
  251.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  252.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  253.  *      The desired form is selected using the io_Flags field of the      *
  254.  *      IOStdReq structure.  The flags and the union are described        *
  255.  *      below.                                                            *
  256.  *                                                                        *
  257.  **************************************************************************/
  258.  
  259. struct RMSF {
  260.  
  261.     UBYTE   Reserved;       /* Reserved (always zero) */
  262.     UBYTE   Minute;         /* Minutes (0-72ish)      */
  263.     UBYTE   Second;         /* Seconds (0-59)         */
  264.     UBYTE   Frame;          /* Frame   (0-74)         */
  265.     };
  266.  
  267. union LSNMSF {
  268.  
  269.     struct  RMSF MSF;       /* Minute, Second, Frame  */
  270.     ULONG   LSN;            /* Logical Sector Number  */
  271.     };
  272.  
  273.  
  274. /**************************************************************************
  275.  *                                                                        *
  276.  * CD Transfer Lists                                                      *
  277.  *                                                                        *
  278.  *      A CDXL node is a double link node; however only single linkage    *
  279.  *      is used by the device driver.  If you wish to construct a         *
  280.  *      transfer list manually, it is only neccessary to define the       *
  281.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  282.  *      list functions by defining a List or MinList structure and by     *
  283.  *      using the AddHead/AddTail functions to create the list.  This     *
  284.  *      will create a double-linked list.  Although a double-linked       *
  285.  *      list is not required by the device driver, you may wish use it    *
  286.  *      for your own purposes.  Don't forget to initialize the            *
  287.  *      the List/MinList before using it!                                 *
  288.  *                                                                        *
  289.  **************************************************************************/
  290.  
  291. struct  CDXL {
  292.  
  293.     struct MinNode    Node;            /* double linkage                  */
  294.     char             *Buffer;          /* data destination (word aligned) */
  295.     LONG              Length;          /* must be even # bytes            */
  296.     LONG              Actual;          /* bytes transferred               */
  297.     APTR              IntData;         /* interrupt server data segment   */
  298.     VOID              (*IntCode)();    /* interrupt server code entry     */
  299.     };
  300.  
  301.  
  302. /**************************************************************************
  303.  *                                                                        *
  304.  * CD Table of Contents                                           *
  305.  *                                                                        *
  306.  *      The CD_TOC command returns an array of CDTOC entries.             *
  307.  *      Entry zero contains summary information describing how many       *
  308.  *      tracks the disk has and the play-time of the disk.                *
  309.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  310.  *      information about the track.                                      *
  311.  *                                                                        *
  312.  **************************************************************************/
  313.  
  314. struct TOCSummary {
  315.  
  316.     UBYTE        FirstTrack; /* First track on disk (always 1)            */
  317.     UBYTE        LastTrack;  /* Last track on disk                        */
  318.     union LSNMSF LeadOut;    /* Beginning of lead-out track (end of disk) */
  319.     };
  320.  
  321.  
  322. struct TOCEntry {
  323.  
  324.     UBYTE        CtlAdr;     /* Q-Code info                  */
  325.     UBYTE        Track;      /* Track number                 */
  326.     union LSNMSF Position;   /* Start position of this track */
  327.     };
  328.  
  329.  
  330. union CDTOC {
  331.  
  332.     struct TOCSummary Summary;  /* First entry (0) is summary information */
  333.     struct TOCEntry   Entry;    /* Entries 1-N are track entries          */
  334.     };
  335.  
  336.  
  337.  
  338. /**************************************************************************
  339.  *                                                                        *
  340.  * Q-Code Packets                                                         *
  341.  *                                                                        *
  342.  *      Q-Code packets are only returned when audio is playing.   *
  343.  *      Currently, only position packets are returned (ADR_POSITION)      *
  344.  *      The other ADR_ types are almost never encoded on the disk         *
  345.  *      and are of little use anyway.  To avoid making the QCode          *
  346.  *      structure a union, these other ADR_ structures are not defined.   *
  347.  *                                                                        *
  348.  **************************************************************************/
  349.  
  350. struct QCode {
  351.  
  352.     UBYTE        CtlAdr;        /* Data type / QCode type           */
  353.     UBYTE        Track; /* Track number             */
  354.     UBYTE        Index; /* Track subindex number            */
  355.     UBYTE        Zero;          /* The "Zero" byte of Q-Code packet */
  356.     union LSNMSF TrackPosition; /* Position from start of track     */
  357.     union LSNMSF DiskPosition;  /* Position from start of disk      */
  358.     };
  359.  
  360.  
  361. #define CTLADR_CTLMASK 0xF0   /* Control field */
  362.  
  363. #define CTL_CTLMASK    0xD0   /* To be ANDed with CtlAdr before compared  */
  364.  
  365. #define CTL_2AUD       0x00   /* 2 audio channels without preemphasis     */
  366. #define CTL_2AUDEMPH   0x10   /* 2 audio channels with preemphasis        */
  367. #define CTL_4AUD       0x80   /* 4 audio channels without preemphasis     */
  368. #define CTL_4AUDEMPH   0x90   /* 4 audio channels with preemphasis        */
  369. #define CTL_DATA       0x40   /* CD-ROM Data                              */
  370.  
  371. #define CTL_COPYMASK   0x20   /* To be ANDed with CtlAdr before compared  */
  372.  
  373. #define CTL_COPY       0x20   /* When true, this audio/data can be copied */
  374.  
  375. #define CTLADR_ADRMASK 0x0F   /* Address field                            */
  376.  
  377. #define ADR_POSITION   0x01   /* Q-Code is position information   */
  378. #define ADR_UPC        0x02   /* Q-Code is UPC information (not used)     */
  379. #define ADR_ISRC       0x03   /* Q-Code is ISRC (not used)                */
  380. #define ADR_HYBRID     0x05   /* This disk is a hybrid disk               */
  381.  
  382.  
  383. #endif
  384.