home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / atapi_pnp300 / developer_kit / amiga_e / modulessrc / devices / atapi_cd.e
Text File  |  1977-12-31  |  15KB  |  314 lines

  1. OPT PREPROCESS
  2. OPT MODULE
  3. OPT EXPORT
  4.  
  5. /*
  6. **      $VER: atapi_cd.e 2.1 (09.03.96)
  7. **
  8. **      atapi.device include file
  9. **
  10. **      (C) Copyright 1995-96 G. Campana M.Campinoti
  11. **          All Rights Reserved
  12. **
  13. **      Big pieces from the original cd.device from Commodore (Escom)
  14. **
  15. **      AmigaE translation by Federico Stango (09.03.96)
  16. */
  17.  
  18. MODULE   'exec/types','exec/nodes'
  19. MODULE   'devices/scsidisk'
  20.  
  21. /**************************************************************************
  22.  *                                                                        *
  23.  *   ATAPI Task Alerts Errors                                             *
  24.  *                                                                        *
  25.  **************************************************************************/
  26.  
  27. CONST AATP_General      =      0
  28.  
  29.  
  30. /**************************************************************************
  31.  *                                                                        *
  32.  *   ATAPI CD Commands                                                    *
  33.  *                                                                        *
  34.  **************************************************************************/
  35.  
  36. CONST CD_RESET          =      1,  /* Private !*/
  37.       CD_READ           =      2,
  38.       CD_WRITE          =      3,  /* CDERR_Writeprot error ;) */
  39.       CD_UPDATE         =      4,  /* empty call */
  40.       CD_CLEAR          =      5,  /* empty call */
  41.       CD_MOTOR          =      9,  /* empty call */
  42.       CD_SEEK           =     10,
  43.  
  44.       CD_CHANGENUM      =     13,  /* supports Quick-IO */
  45.       CD_CHANGESTATE    =     14,
  46.       CD_PROTSTATUS     =     15,  /* always return 1 (write protected) */
  47.  
  48.       CD_ADDCHANGEINT   =     20,
  49.       CD_REMCHANGEINT   =     21,  /* Immediate */
  50.       CD_GETGEOMETRY    =     22,
  51.       CD_EJECT          =     23,
  52.  
  53.  
  54.       CD_SCSI_DIRECT    =     28,  /* compatible w. HD_SCSICMD   */
  55.  
  56.  
  57.       CD_INFO           =     32,
  58.       CD_CONFIG         =     33,
  59.       CD_TOCMSF         =     34,
  60.       CD_TOCLSN         =     35,
  61.  
  62.       CD_READXL         =     36,
  63.  
  64.       CD_QCODEMSF       =     42,
  65.       CD_QCODELSN       =     43,
  66.       CD_ATTENUATE      =     44,
  67.  
  68.       CD_PLAYTRACK      =     37,
  69.       CD_PLAYMSF        =     38,
  70.       CD_PLAYLSN        =     39,
  71.       CD_PAUSE          =     40,
  72.  
  73.       CD_ATAPI_IDENTIFY =  $7fff
  74.  
  75. /****************************
  76.  *                          *
  77.  *   Not working now        *
  78.  *                          *
  79.  ****************************/
  80.  
  81. CONST CD_SEARCH         =     41
  82.  
  83.  
  84. /**************************************************************************
  85.  *                                                                        *
  86.  *   Device Driver Error Codes                                            *
  87.  *                                                                        *
  88.  **************************************************************************/
  89.  
  90. CONST CDERR_OPENFAIL       = -1,   /* device/unit failed to open           */
  91.       CDERR_ABORTED        = -2,   /* request terminated early             */
  92.       CDERR_NOCMD          = -3,   /* command not supported by device      */
  93.       CDERR_BADLENGTH      = -4,   /* invalid length (IO_LENGTH/IO_OFFSET) */
  94.       CDERR_BADADDRESS     = -5,   /* invalid address (IO_DATA misaligned) */
  95.       CDERR_UNITBUSY       = -6,   /* device opens ok, but unit is busy    */
  96.  
  97.       CDERR_NotSpecified   = 20,   /* general catchall                     */
  98.       CDERR_NoSecHdr       = 21,   /* couldn't even find a sector          */
  99.       CDERR_BadSecPreamble = 22,   /* sector looked wrong                  */
  100.       CDERR_BadSecID       = 23,   /* ditto                                */
  101.       CDERR_BadHdrSum      = 24,   /* header had incorrect checksum        */
  102.       CDERR_BadSecSum      = 25,   /* data had incorrect checksum          */
  103.       CDERR_TooFewSecs     = 26,   /* couldn't find enough sectors         */
  104.       CDERR_BadSecHdr      = 27,   /* another "sector looked wrong"        */
  105.       CDERR_WriteProt      = 28,   /* can't write to a protected disk      */
  106.       CDERR_NoDisk         = 29,   /* no disk in the drive                 */
  107.       CDERR_SeekError      = 30,   /* couldn't find track 0                */
  108.       CDERR_NoMem          = 31,   /* ran out of memory                    */
  109.       CDERR_BadUnitNum     = 32,   /* asked for a unit > NUMUNITS          */
  110.       CDERR_BadDriveType   = 33,   /* not a drive cd.device understands    */
  111.       CDERR_DriveInUse     = 34,   /* someone else allocated the drive     */
  112.       CDERR_BadDataType    = 36,   /* data on disk is wrong type           */
  113.       CDERR_InvalidState   = 37,   /* invalid cmd under current conditions */
  114.  
  115.       CDERR_NoBoard        = 50   /* open failed for non-existant board   */
  116.  
  117.  
  118.  
  119. /**************************************************************************
  120.  *                                                                        *
  121.  * Configuration                                                          *
  122.  *                                                                        *
  123.  *       The drive is configured by TagList items defined as follows:     *
  124.  *                                                                        *
  125.  **************************************************************************/
  126.  
  127. CONST TAGCD_PLAYSPEED       = 1,
  128.       TAGCD_READSPEED       = 2,
  129.       TAGCD_READXLSPEED     = 3,
  130.       TAGCD_SECTORSIZE      = 4,
  131.       TAGCD_XLECC           = 5,
  132.       TAGCD_EJECTRESET      = 6
  133.  
  134.  
  135. /**************************************************************************
  136.  *                                                                        *
  137.  * Information                                                            *
  138.  *                                                                        *
  139.  *      Information/Status structure describes current speed settings     *
  140.  *      for read and play commands, sector size, audio attenuation        *
  141.  *      precision, and drive status.                                      *
  142.  *                                                                        *
  143.  **************************************************************************/
  144.  
  145. OBJECT cdinfo                    /*                                Default     */
  146.     playspeed    : INT           /* Audio play speed               (75)        */
  147.     readspeed    : INT           /* Data-rate of CD_READ command   (Max)       */
  148.     readxlspeed  : INT           /* Data-rate of CD_READXL command (75)        */
  149.     sectorsize   : INT           /* Number of bytes per sector     (2048)      */
  150.     xlecc        : INT           /* CDXL ECC enabled/disabled                  */
  151.     ejectreset   : INT           /* Reset on eject enabled/disabled            */
  152.     reserved1[4] : ARRAY OF INT  /* Reserved for future expansion              */
  153.     maxspeed       : INT         /* Maximum speed drive can handle (75, 150)   */
  154.     audioprecision : INT         /* 0 = no attenuator, 1 = mute only,          */
  155.                                  /* other = (# levels - 1)                     */
  156.     status       : INT           /* See flags below                            */
  157.     reserved2[4] : ARRAY OF INT  /* Reserved for future expansion              */
  158. ENDOBJECT
  159.  
  160.  
  161. /* Flags for Status */
  162.  
  163. CONST CDSTSB_CLOSED    = 0,      /* Drive door is closed                        */
  164.       CDSTSB_DISK      = 1,      /* A disk has been detected                    */
  165.       CDSTSB_SPIN      = 2,      /* Disk is spinning (motor is on)              */
  166.       CDSTSB_TOC       = 3,      /* Table of contents read.  Disk is valid.     */
  167.       CDSTSB_CDROM     = 4,      /* Track 1 contains CD-ROM data                */
  168.       CDSTSB_PLAYING   = 5,      /* Audio is playing                            */
  169.       CDSTSB_PAUSED    = 6,      /* Pause mode (pauses on play command)         */
  170.       CDSTSB_SEARCH    = 7,      /* Search mode (Fast Forward/Fast Reverse)     */
  171.       CDSTSB_DIRECTION = 8,      /* Search direction (0 = Forward, 1 = Reverse) */
  172.  
  173.       CDSTSF_CLOSED    = 1,
  174.       CDSTSF_DISK      = 2,
  175.       CDSTSF_SPIN      = 4,
  176.       CDSTSF_TOC       = 8,
  177.       CDSTSF_CDROM     = $10,
  178.       CDSTSF_PLAYING   = $20,
  179.       CDSTSF_PAUSED    = $40,
  180.       CDSTSF_SEARCH    = $80,
  181.       CDSTSF_DIRECTION = $100
  182.  
  183.  
  184. /* Modes for CD_SEARCH */
  185.  
  186. CONST CDMODE_NORMAL    = 0,      /* Normal play at current play speed    */
  187.       CDMODE_FFWD      = 1,      /* Fast forward play (skip-play forward)*/
  188.       CDMODE_FREV      = 2       /* Fast reverse play (skip-play reverse)*/
  189.  
  190.  
  191. /**************************************************************************
  192.  *                                                                        *
  193.  * Position Information                                           *
  194.  *                                                                        *
  195.  *      Position information can be described in two forms: MSF and LSN   *
  196.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  197.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  198.  *      The desired form is selected using the io_Flags field of the      *
  199.  *      IOStdReq structure.  The flags and the union are described        *
  200.  *      below.                                                            *
  201.  *                                                                        *
  202.  **************************************************************************/
  203.  
  204. OBJECT rmsf
  205.   reserved : CHAR                /* Reserved (always zero) */
  206.   minute   : CHAR                /* Minutes (0-72ish)      */
  207.   second   : CHAR                /* Seconds (0-59)         */
  208.   frame    : CHAR                /* Frame   (0-74)         */
  209. ENDOBJECT
  210.  
  211. OBJECT lsnmsf
  212.   msf:rmsf                       /* Minute, Second, Frame  */
  213. ENDOBJECT                        /* Logical Sector Number  */
  214.  
  215.  
  216. /**************************************************************************
  217.  *                                                                        *
  218.  * CD Transfer Lists                                                      *
  219.  *                                                                        *
  220.  *      A CDXL node is a double link node; however only single linkage    *
  221.  *      is used by the device driver.  If you wish to construct a         *
  222.  *      transfer list manually, it is only neccessary to define the       *
  223.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  224.  *      list functions by defining a List or MinList structure and by     *
  225.  *      using the AddHead/AddTail functions to create the list.  This     *
  226.  *      will create a double-linked list.  Although a double-linked       *
  227.  *      list is not required by the device driver, you may wish use it    *
  228.  *      for your own purposes.  Don't forget to initialize the            *
  229.  *      the List/MinList before using it!                                 *
  230.  *                                                                        *
  231.  **************************************************************************/
  232.  
  233. OBJECT cdxl
  234.   node    : mln                  /* double linkage                  */
  235.   buffer  : PTR TO CHAR          /* data destination (word aligned) */
  236.   length  : LONG                 /* must be even # bytes            */
  237.   actual  : LONG                 /* bytes transferred               */
  238.   intdata : LONG                 /* interrupt server data segment   */
  239.   intcode : LONG                 /* interrupt server code entry     */
  240. ENDOBJECT
  241.  
  242.  
  243. /**************************************************************************
  244.  *                                                                        *
  245.  * CD Table of Contents                                                   *
  246.  *                                                                        *
  247.  *      The CD_TOC command returns an array of CDTOC entries.             *
  248.  *      Entry zero contains summary information describing how many       *
  249.  *      tracks the disk has and the play-time of the disk.                *
  250.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  251.  *      information about the track.                                      *
  252.  *                                                                        *
  253.  **************************************************************************/
  254.  
  255. OBJECT tocsummary
  256.   firsttrack : CHAR     /* First track on disk (always 1)            */
  257.   lasttrack  : CHAR     /* Last track on disk                        */
  258.   leadout    : lsnmsf   /* Beginning of lead-out track (end of disk) */
  259. ENDOBJECT
  260.  
  261. OBJECT tocentry
  262.   ctladr   : CHAR       /* Q-Code info                  */
  263.   track    : CHAR       /* Track number                 */
  264.   position : lsnmsf     /* Start position of this track */
  265. ENDOBJECT
  266.  
  267. OBJECT cdtoc                         /* First entry (0) is summary information */
  268.     entry   : tocentry               /* Entries 1-N are track entries          */
  269. ENDOBJECT
  270.  
  271.  
  272. /**************************************************************************
  273.  *                                                                        *
  274.  * Q-Code Packets                                                         *
  275.  *                                                                        *
  276.  *      Q-Code packets are only returned when audio is playing.   *
  277.  *      Currently, only position packets are returned (ADR_POSITION)      *
  278.  *      The other ADR_ types are almost never encoded on the disk         *
  279.  *      and are of little use anyway.  To avoid making the QCode          *
  280.  *      structure a union, these other ADR_ structures are not defined.   *
  281.  *                                                                        *
  282.  **************************************************************************/
  283.  
  284. OBJECT qcode
  285.   ctladr        : CHAR           /* Data type / QCode type           */
  286.   track         : CHAR           /* Track number                     */
  287.   index         : CHAR           /* Track subindex number            */
  288.   zero          : CHAR           /* The "Zero" byte of Q-Code packet */
  289.   trackposition : lsnmsf         /* Position from start of track     */
  290.   diskposition  : lsnmsf         /* Position from start of disk      */
  291. ENDOBJECT
  292.  
  293.  
  294. CONST CTLADR_CTLMASK = $F0,   /* Control field */
  295.  
  296.       CTL_CTLMASK    = $D0,   /* To be ANDed with CtlAdr before compared  */
  297.  
  298.       CTL_2AUD       = $00,   /* 2 audio channels without preemphasis     */
  299.       CTL_2AUDEMPH   = $10,   /* 2 audio channels with preemphasis        */
  300.       CTL_4AUD       = $80,   /* 4 audio channels without preemphasis     */
  301.       CTL_4AUDEMPH   = $90,   /* 4 audio channels with preemphasis        */
  302.       CTL_DATA       = $40,   /* CD-ROM Data                              */
  303.  
  304.       CTL_COPYMASK   = $20,   /* To be ANDed with CtlAdr before compared  */
  305.  
  306.       CTL_COPY       = $20,   /* When true, this audio/data can be copied */
  307.  
  308.       CTLADR_ADRMASK = $0F,   /* Address field                            */
  309.  
  310.       ADR_POSITION   = $01,   /* Q-Code is position information           */
  311.       ADR_UPC        = $02,   /* Q-Code is UPC information (not used)     */
  312.       ADR_ISRC       = $03,   /* Q-Code is ISRC (not used)                */
  313.       ADR_HYBRID     = $05    /* This disk is a hybrid disk               */
  314.