home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / M2V11-1.LHA / modula / amiga / CD.def < prev    next >
Encoding:
Text File  |  1993-11-01  |  11.1 KB  |  299 lines

  1. DEFINITION FOR C MODULE CD ;
  2.  
  3. FROM SYSTEM IMPORT ADDRESS ;
  4. FROM Exec   IMPORT CMD_NONSTD , MinNode ;
  5.  
  6. (**************************************************************************
  7.  *                                      *
  8.  *   CD Commands                              *
  9.  *                                      *
  10.  **************************************************************************)
  11.  
  12. CONST
  13.   CD_RESET        =  1 ;
  14.   CD_READ        =  2 ;
  15.   CD_WRITE        =  3 ;
  16.   CD_UPDATE        =  4 ;
  17.   CD_CLEAR        =  5 ;
  18.   CD_STOP        =  6 ;
  19.   CD_START        =  7 ;
  20.   CD_FLUSH        =  8 ;
  21.   CD_MOTOR        =  9 ;
  22.   CD_SEEK        = 10 ;
  23.   CD_FORMAT        = 11 ;
  24.   CD_REMOVE        = 12 ;
  25.   CD_CHANGENUM        = 13 ;
  26.   CD_CHANGESTATE    = 14 ;
  27.   CD_PROTSTATUS        = 15 ;
  28.  
  29.   CD_GETDRIVETYPE    = 18 ;
  30.   CD_GETNUMTRACKS    = 19 ;
  31.   CD_ADDCHANGEINT    = 20 ;
  32.   CD_REMCHANGEINT    = 21 ;
  33.   CD_GETGEOMETRY    = 22 ;
  34.   CD_EJECT        = 23 ;
  35.  
  36.   CD_INFO        = 32 ;
  37.   CD_CONFIG        = 33 ;
  38.   CD_TOCMSF        = 34 ;
  39.   CD_TOCLSN        = 35 ;
  40.  
  41.   CD_READXL        = 36 ;
  42.  
  43.   CD_PLAYTRACK        = 37 ;
  44.   CD_PLAYMSF        = 38 ;
  45.   CD_PLAYLSN        = 39 ;
  46.   CD_PAUSE        = 40 ;
  47.   CD_SEARCH        = 41 ;
  48.  
  49.   CD_QCODEMSF        = 42 ;
  50.   CD_QCODELSN        = 43 ;
  51.   CD_ATTENUATE        = 44 ;
  52.  
  53.   CD_ADDFRAMEINT    = 45 ;
  54.   CD_REMFRAMEINT    = 46 ;
  55.  
  56. (**************************************************************************
  57.  *                                      *
  58.  *   Device Driver Error Codes                          *
  59.  *                                      *
  60.  **************************************************************************)
  61.  
  62.   CDERR_OPENFAIL    = -1 ; (* device/unit failed to open        *)
  63.   CDERR_ABORTED        = -2 ; (* request terminated early        *)
  64.   CDERR_NOCMD        = -3 ; (* command not supported by device    *)
  65.   CDERR_BADLENGTH       = -4 ; (* invalid length (IO_LENGTH/IO_OFFSET)    *)
  66.   CDERR_BADADDRESS      = -5 ; (* invalid address (IO_DATA misaligned)    *)
  67.   CDERR_UNITBUSY    = -6 ; (* device opens ok, but unit is busy    *)
  68.   CDERR_SELFTEST    = -7 ; (* hardware failed self-test        *)
  69.  
  70.   CDERR_NotSpecified    = 20 ; (* general catchall          *)
  71.   CDERR_NoSecHdr    = 21 ; (* couldn't even find a sector      *)
  72.   CDERR_BadSecPreamble  = 22 ; (* sector looked wrong          *)
  73.   CDERR_BadSecID    = 23 ; (* ditto                  *)
  74.   CDERR_BadHdrSum       = 24 ; (* header had incorrect checksum      *)
  75.   CDERR_BadSecSum       = 25 ; (* data had incorrect checksum      *)
  76.   CDERR_TooFewSecs      = 26 ; (* couldn't find enough sectors      *)
  77.   CDERR_BadSecHdr       = 27 ; (* another "sector looked wrong"      *)
  78.   CDERR_WriteProt       = 28 ; (* can't write to a protected disk *)
  79.   CDERR_NoDisk        = 29 ; (* no disk in the drive          *)
  80.   CDERR_SeekError       = 30 ; (* couldn't find track 0          *)
  81.   CDERR_NoMem        = 31 ; (* ran out of memory          *)
  82.   CDERR_BadUnitNum      = 32 ; (* asked for a unit > NUMUNITS      *)
  83.   CDERR_BadDriveType    = 33 ; (* not a drive cd.device understands    *)
  84.   CDERR_DriveInUse      = 34 ; (* someone else allocated the drive    *)
  85.   CDERR_PostReset       = 35 ; (* user hit reset; awaiting doom        *)
  86.   CDERR_BadDataType     = 36 ; (* data on disk is wrong type          *)
  87.   CDERR_InvalidState    = 37 ; (* invalid cmd under current conditions    *)
  88.  
  89.   CDERR_Phase        = 42 ; (* illegal or unexpected SCSI phase   *)
  90.   CDERR_NoBoard        = 50 ; (* open failed for non-existant board *)
  91.  
  92. (**************************************************************************
  93.  *                                      *
  94.  * Configuration                              *
  95.  *                                      *
  96.  *     The drive is configured by TagList items defined as follows:      *
  97.  *                                      *
  98.  **************************************************************************)
  99.  
  100.   TAGCD_PLAYSPEED    = 00001 ;
  101.   TAGCD_READSPEED    = 00002 ;
  102.   TAGCD_READXLSPEED    = 00003 ;
  103.   TAGCD_SECTORSIZE    = 00004 ;
  104.   TAGCD_XLECC        = 00005 ;
  105.   TAGCD_EJECTRESET    = 00006 ;
  106.  
  107. (**************************************************************************
  108.  *                                      *
  109.  * Information                                  *
  110.  *                                      *
  111.  *    Information/Status structure describes current speed settings      *
  112.  *    for read and play commands, sector size, audio attenuation      *
  113.  *    precision, and drive status.                      *
  114.  *                                      *
  115.  **************************************************************************)
  116.  
  117. TYPE
  118.   CDInfo = RECORD (* Default *)
  119.     PlaySpeed    : CARDINAL ; (* Audio play speed          (75)      *)
  120.     ReadSpeed    : CARDINAL ; (* Data-rate of CD_READ command   (Max)      *)
  121.     ReadXLSpeed : CARDINAL ; (* Data-rate of CD_READXL command (75)      *)
  122.     SectorSize  : CARDINAL ; (* Number of bytes per sector     (2048)      *)
  123.     XLECC    : CARDINAL ; (* CDXL ECC enabled/disabled          *)
  124.     EjectReset    : CARDINAL ; (* Reset on eject enabled/disabled          *)
  125.     Reserved1    : ARRAY [0..3] OF CARDINAL ;
  126.                      (* Reserved for future expansion          *)
  127.  
  128.     MaxSpeed       : CARDINAL ;    (* Maximum speed drive can handle (75,150)*)
  129.     AudioPrecision : CARDINAL ; (* 0 = no attenuator, 1 = mute only,      *)
  130.                 (* other = (# levels - 1)          *)
  131.     Status    : BITSET ;      (* See flags below              *)
  132.     Reserved2    : ARRAY [0..3] OF CARDINAL ;
  133.                     (* Reserved for future expansion      *)
  134.  
  135.   END ;
  136.  
  137. (* Flags for Status *)
  138.  
  139. CONST
  140.   CDSTSB_CLOSED       = 0 ; (* Drive door is closed              *)
  141.   CDSTSB_DISK       = 1 ; (* A disk has been detected              *)
  142.   CDSTSB_SPIN       = 2 ; (* Disk is spinning (motor is on)          *)
  143.   CDSTSB_TOC       = 3 ; (* Table of contents read.  Disk is valid.      *)
  144.   CDSTSB_CDROM       = 4 ; (* Track 1 contains CD-ROM data          *)
  145.   CDSTSB_PLAYING   = 5 ; (* Audio is playing                  *)
  146.   CDSTSB_PAUSED       = 6 ; (* Pause mode (pauses on play command)          *)
  147.   CDSTSB_SEARCH       = 7 ; (* Search mode (Fast Forward/Fast Reverse)      *)
  148.   CDSTSB_DIRECTION = 8 ; (* Search direction (0 = Forward, 1 = Reverse)      *)
  149.  
  150.   CDSTSF_CLOSED       = { CDSTSB_CLOSED }      ;
  151.   CDSTSF_DISK       = { CDSTSB_DISK }      ;
  152.   CDSTSF_SPIN       = { CDSTSB_SPIN }      ;
  153.   CDSTSF_TOC       = { CDSTSB_TOC }      ;
  154.   CDSTSF_CDROM       = { CDSTSB_CDROM }      ;
  155.   CDSTSF_PLAYING   = { CDSTSB_PLAYING }      ;
  156.   CDSTSF_PAUSED       = { CDSTSB_PAUSED }       ;
  157.   CDSTSF_SEARCH       = { CDSTSB_SEARCH }      ;
  158.   CDSTSF_DIRECTION = { CDSTSB_DIRECTION    } ;
  159.  
  160. (* Modes for CD_SEARCH *)
  161.  
  162.   CDMODE_NORMAL    = 0 ; (* Normal play at current play speed     *)
  163.   CDMODE_FFWD    = 1 ; (* Fast forward play (skip-play forward) *)
  164.   CDMODE_FREV    = 2 ; (* Fast reverse play (skip-play reverse) *)
  165.  
  166. (***************************************************************************
  167.  *                                       *
  168.  * Position Information                                 *
  169.  *                                       *
  170.  *    Position information can be described in two forms: MSF and LSN    *
  171.  *    form.  MSF (Minutes, Seconds, Frames) form is a time encoding.       *
  172.  *    LSN (Logical Sector Number) form is frame (sector) count.       *
  173.  *    The desired form is selected using the io_Flags field of the       *
  174.  *    IOStdReq structure.  The flags and the union are described       *
  175.  *    below.                                   *
  176.  *                                       *
  177.  ***************************************************************************)
  178.  
  179. TYPE
  180.   RMSF = RECORD
  181.     Reserved : SHORTCARD ; (* Reserved (always zero)  *)
  182.     Minute   : SHORTCARD ; (* Minutes (0-72ish)       *)
  183.     Second   : SHORTCARD ; (* Seconds (0-59)          *)
  184.     Frame    : SHORTCARD ; (* Frame   (0-74)          *)
  185.   END ;
  186.  
  187. TYPE
  188.   LSNMSF = RECORD
  189.     CASE :LONGINT OF
  190.     |0: MSF : RMSF    (* Minute, Second, Frame  *)
  191.     |1: LSN : LONGINT (* Logical Sector Number  *)
  192.     END
  193.   END ;
  194.  
  195. (**************************************************************************
  196.  *                                      *
  197.  * CD Transfer Lists                              *
  198.  *                                      *
  199.  *    A CDXL node is a double link node; however only single linkage      *
  200.  *    is used by the device driver.  If you wish to construct a      *
  201.  *    transfer list manually, it is only neccessary to define the      *
  202.  *    mln_Succ pointer of the MinNode.  You may also use the Exec      *
  203.  *    list functions by defining a List or MinList structure and by      *
  204.  *    using the AddHead/AddTail functions to create the list.  This      *
  205.  *    will create a double-linked list.  Although a double-linked      *
  206.  *    list is not required by the device driver, you may wish use it      *
  207.  *    for your own purposes.    Don't forget to initialize the          *
  208.  *    the List/MinList before using it!                  *
  209.  *                                      *
  210.  **************************************************************************)
  211.  
  212. TYPE
  213.   CDXL = RECORD
  214.     Node    : MinNode ;    (* double linkage           *)
  215.     Buffer  : ADDRESS ;    (* data destination (word aligned) *)
  216.     Length  : LONGINT ;    (* must be even # bytes           *)
  217.     Actual  : LONGINT ;    (* bytes transferred           *)
  218.     IntData : ADDRESS ; (* interrupt server data segment   *)
  219.     IntCode : ADDRESS ; (* interrupt server code entry       *)
  220.   END ;
  221.  
  222. (**************************************************************************
  223.  *                                      *
  224.  * CD Table of Contents                              *
  225.  *                                      *
  226.  *    The CD_TOC command returns an array of CDTOC entries.          *
  227.  *    Entry zero contains summary information describing how many      *
  228.  *    tracks the disk has and the play-time of the disk.          *
  229.  *    Entries 1 through N (N = Number of tracks on disk) contain      *
  230.  *    information about the track.                      *
  231.  *                                      *
  232.  **************************************************************************)
  233.  
  234. TYPE
  235.   TOCSummary = RECORD
  236.     FirstTrack : SHORTCARD ; (* First track on disk (always 1)          *)
  237.     LastTrack  : SHORTCARD ; (* Last track on disk              *)
  238.     LeadOut    : LSNMSF    ; (* Beginning of lead-out track (end of disk) *)
  239.   END ;
  240.  
  241.   TOCEntry = RECORD
  242.     CtlAdr   : SHORTCARD ; (* Q-Code info             *)
  243.     Track    : SHORTCARD ; (* Track number             *)
  244.     Position : LSNMSF    ; (* Start position of this track   *)
  245.   END ;
  246.  
  247.   CDTOC = RECORD
  248.     CASE :LONGINT OF
  249.     |0 : Summary : TOCSummary ;    (* First entry (0) is summary information *)
  250.     |1 : Entry   : TOCEntry   ;    (* Entries 1-N are track entries      *)
  251.     END ;
  252.   END ;
  253.  
  254. (**************************************************************************
  255.  *                                      *
  256.  * Q-Code Packets                              *
  257.  *                                      *
  258.  *    Q-Code packets are only returned when audio is playing.          *
  259.  *    Currently, only position packets are returned (ADR_POSITION)      *
  260.  *    The other ADR_ types are almost never encoded on the disk      *
  261.  *    and are of little use anyway.  To avoid making the QCode      *
  262.  *    structure a union, these other ADR_ structures are not defined.   *
  263.  *                                      *
  264.  **************************************************************************)
  265.  
  266. TYPE
  267.   QCode = RECORD
  268.     CtlAdr      : SHORTCARD ;    (* Data type / QCode type        *)
  269.     Track      : SHORTCARD ;    (* Track number                *)
  270.     Index      : SHORTCARD ;    (* Track subindex number        *)
  271.     Zero      : SHORTCARD ;    (* The "Zero" byte of Q-Code packet *)
  272.     TrackPosition : LSNMSF    ; (* Position from start of track     *)
  273.     DiskPosition  : LSNMSF    ;    (* Position from start of disk        *)
  274.   END ;
  275.  
  276. CONST
  277.   CTLADR_CTLMASK = 0F0H ;  (* Control field                  *)
  278.  
  279.   CTL_CTLMASK    = 0D0H ;  (* To be ANDed with CtlAdr before compared      *)
  280.  
  281.   CTL_2AUD       = 000H ;  (* 2 audio channels without preemphasis      *)
  282.   CTL_2AUDEMPH   = 010H ;  (* 2 audio channels with preemphasis          *)
  283.   CTL_4AUD       = 080H ;  (* 4 audio channels without preemphasis      *)
  284.   CTL_4AUDEMPH   = 090H ;  (* 4 audio channels with preemphasis          *)
  285.   CTL_DATA       = 040H ;  (* CD-ROM Data                  *)
  286.  
  287.   CTL_COPYMASK   = 020H ;  (* To be ANDed with CtlAdr before compared      *)
  288.  
  289.   CTL_COPY       = 020H ;  (* When true, this audio/data can be copied      *)
  290.  
  291.   CTLADR_ADRMASK = 00FH ;  (* Address field                  *)
  292.  
  293.   ADR_POSITION   = 001H ;  (* Q-Code is position information          *)
  294.   ADR_UPC        = 002H ;  (* Q-Code is UPC information (not used)      *)
  295.   ADR_ISRC       = 003H ;  (* Q-Code is ISRC (not used)              *)
  296.   ADR_HYBRID     = 005H ;  (* This disk is a hybrid disk          *)
  297.  
  298. END CD.
  299.