home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rmfiles.zip / mitsrc.zip / CMD.H < prev    next >
C/C++ Source or Header  |  1994-06-15  |  14KB  |  399 lines

  1. // Mistumi LS005 commands
  2. // ALl commands return AT least Drive Status
  3.  
  4.  
  5. #define TimeOut              0xff
  6. #define SearchCount            2000
  7. #define Spincount            0x4ee0L
  8. #define ReadSpinCount        0x8AA0L
  9. #define ReadToc                0x10
  10. #define ReadDiscInfo           0x11
  11. #define ReadSubQ               0x20
  12. #define RequestSense           0x30
  13. #define RequestDriveStatus     0x40
  14. #define SetDriveMode           0x50
  15. #define Reset                  0x60
  16. #define Hold                   0x70
  17. #define HoldTime        (UCHAR)0x80
  18. #define GetAudioVolume  (UCHAR)0x8E
  19. #define DriveConfig            0x90
  20. #define ModeSet         (UCHAR)0xA0
  21. #define ReadUPC         (UCHAR)0xA2
  22. #define SetAudioVolume  (UCHAR)0xAE
  23. #define ReadSubCode            0xB0
  24. #define Seek            (UCHAR)0xC0
  25. #define PlayAudioMSF    (UCHAR)0xC1
  26. #define ReadDriveMode   (UCHAR)0xC2
  27. #define Read            (UCHAR)0xC3
  28. #define ReadFast        (UCHAR)0xC1
  29. #define SetInterleave   (UCHAR)0xC8
  30. #define GetVersion      (UCHAR)0xDC
  31. #define Stop            (UCHAR)0xF0
  32. #define Eject           (UCHAR)0xF6
  33. #define Close           (UCHAR)0xF8
  34. #define LockUnlock      (UCHAR)0xFE
  35. #define SuspendData     0x0C
  36. #define ReleaseData     0x04
  37.  
  38. #define DataReg   0
  39. #define StatusReg 1
  40.  
  41. // Drive status bit definitions
  42. // base adapter address +1 (301h for example)
  43.  
  44. #define DoorOpen     0x80 // 1 = door open
  45. #define DiscIn       0x40 // 1 = disc in
  46. #define DiscChg      0x20 // 1 = disc changed
  47. #define Spinup       0x10 // 1 = disc spinning
  48. #define AudioDisc    0x08 // 1= Audio
  49. #define ReadError    0x04 // 1 = error, see sense data
  50. #define AudioBusy    0x02 // 1 = playback in progress
  51. #define CommandCheck 0x01 // 1 = command error
  52. #define COMMANDCHECK(x) ((LOBYTE(x) & CommandCheck))
  53. #define DOOROPEN(x) ((LOBYTE(x) & DoorOpen))
  54. #define TIMEOUT(x) ((HIBYTE(x)==TimeOut))
  55. #define DUMMYWAIT  { USHORT i=0x4000;while(i)i--;}
  56. #define SHORTWAIT  { USHORT i=0x0100;while(i)i--;}
  57. #define DISCCHANGE(x)  ((LOBYTE(x) & DiscChg))
  58. #define DISCIN(x)      ((LOBYTE(x) & DiscIn))
  59. #define READERROR(x)   ((LOBYTE(x) & ReadError))
  60. #define AUDIODISC(x)   ((LOBYTE(x) & AudioDisc))
  61. #define AUDIOBUSY(x)   ((LOBYTE(x) & AudioBusy))
  62. #define SPINNING(x)    ((LOBYTE(x) & Spinup))
  63.  
  64. union   OutputCommands {
  65.         UCHAR Command;
  66.         struct {
  67.                UCHAR c;
  68.                UCHAR Min;
  69.                UCHAR Sec;
  70.                UCHAR Frame;
  71.                UCHAR Rsv[3];
  72.                } SeekCmd;
  73.         struct {
  74.                UCHAR c;
  75.                UCHAR Min;
  76.                UCHAR Sec;
  77.                UCHAR Frame;
  78.                UCHAR Length1;
  79.                UCHAR Length2;
  80.                UCHAR Length3;
  81.                } ReadCmd;
  82.         struct {
  83.                UCHAR c;
  84.                UCHAR StartMin;
  85.                UCHAR StartSec;
  86.                UCHAR StartFrame;
  87.                UCHAR StopFrame;
  88.                UCHAR StopMin;
  89.                UCHAR StopSec;
  90.                } PlayAudio;
  91.         struct {
  92.                UCHAR c;
  93.                UCHAR ModeType;
  94.                #define Mode0 0
  95.                #define Mode1 1
  96.                #define Mode2 2
  97.                } DataModeSet;
  98.  
  99.         struct {
  100.                UCHAR c;
  101.                UCHAR UnitsofTenSeconds;
  102.                // Default is 0C= 120 seconds, 01-FF valid
  103.                } HoldCmd;
  104.  
  105.         struct {
  106.                UCHAR c;
  107.                UCHAR Mode;
  108.                // drive modes used in command 0x50 (set) and 0xC2 (get)
  109.  
  110.                #define TestMode   0x80   // 0 = bit 6 (next bit) is valid
  111.                #define DataLength 0x40   // 1 = 2352, 2048 user data
  112.                                          // 0 = 2048 user data only
  113.                #define EccBit     0x20   // 0 = yes secondary correction after CIRC error
  114.                                          // 1 = no correction
  115.                #define RsvMode1   0x10   // reserved, set to 0 on write
  116.                #define SpinDisc   0x08   // 1 = spindown
  117.                                          // 0 = spinup
  118.                #define TocData    0x04   // 1 = read TOC on ReadSubQ (0x20)
  119.                #define RsvMode2   0x02
  120.                #define MuteData   0x01   // 1 = no audio playback of data tracks
  121.                                          // 0 = always muted
  122.                } DriveMode;
  123.  
  124.         struct {
  125.                UCHAR c;
  126.                union {
  127.                      UCHAR  Byte;
  128.                      struct {
  129.                             UCHAR  ByteLength:1;
  130.                                    // if True
  131.                                    // Byte 2 = MSB of block length
  132.                                    // Byte 3 - LSB of block length
  133.                             UCHAR  DMAMode:1;
  134.                                    // if True Data Transfers use DMA, Regardless of this bit, ONLY Data can use DMA, nothing else
  135.                             UCHAR  UPCCode:1;
  136.                                    // If True
  137.                                    // Issue ReadUpc (0xA2) as next command
  138.                             UCHAR  DMATimeut:1;
  139.                                    // if True
  140.                                    // Byte2 = millisecond timeout value
  141.                             UCHAR  IRQEnable:1;
  142.                                    // if IRQEnable = True
  143.                                    // Byte2 settings
  144.                                       #define PreIrq  1
  145.                                       #define PostIrq 2
  146.                                       #define ErrIrq  4
  147.                             UCHAR  Reserved:3;
  148.                             } Bits;
  149.                       } Byte1;
  150.                UCHAR  Byte2;
  151.                UCHAR  Byte3;
  152.                } DriveConfigCmd;
  153.                #define IRQFLAG 0x10L
  154.                #define DMAFLAG 0x08L
  155.                #define UPCFLAG 0x04L
  156.                #define GetSubq 0
  157.                #define GetUpc  1
  158.                #define MODEFLAG 0x02L
  159.                #define BLOCKSIZE 0x01L
  160.  
  161.                // don't know why we'd use this command yet, reads P-W subchannels all at once, 98 bytes returned
  162.         struct {
  163.                UCHAR c;
  164.                UCHAR  Min;
  165.                UCHAR  Sec;
  166.                UCHAR  Frame;
  167.                UCHAR Length1; // MSB
  168.                UCHAR Length2;
  169.                UCHAR Length3; // LSB
  170.                } ReadSubCode_n_Block;
  171.  
  172.         struct {
  173.                UCHAR c;
  174.                UCHAR ATT0;
  175.                UCHAR ATT1;
  176.                UCHAR ATT2;
  177.                UCHAR ATT3;
  178.  
  179.                  // table of settings
  180.                  // ┌──────┬──────┬──────┬──────┬──────────┬──────────┐
  181.                  // │ Att0 │ Att1 │ Att2 │ Att3 │ Right Ch │ Left Ch  │
  182.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  183.                  // │  01  │  00  │  01  │  00  │   On     │   On     │
  184.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  185.                  // │  00  │  00  │  01  │  00  │   On     │   Off    │
  186.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  187.                  // │  01  │  00  │  00  │  00  │   Off    │   On     │
  188.                  // ├──────┼──────┼──────┼──────┼──────────┴──────────┤
  189.                  // │  00  │  00  │  01  │  01  │  Mono From Right Ch │
  190.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  191.                  // │  01  │  01  │  00  │  00  │  Mono From Left  Ch │
  192.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  193.                  // │  01  │  01  │  01  │  01  │      Mixing         │
  194.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  195.                  // │  00  │  01  │  00  │  01  │      Reverse        │
  196.                  // └──────┴──────┴──────┴──────┴─────────────────────┘
  197.  
  198.                } AudioLevel;
  199.  
  200.         struct {
  201.                UCHAR c;
  202.                 UCHAR Size;
  203.                 // Default = Minimum = 1;
  204.                 // Value is decremented by 1 at drive, so 1 = 0 = No interleave
  205.                } InterLeave;
  206.         struct {
  207.                UCHAR c;
  208.                UCHAR Option;
  209.                #define Unlock 0
  210.                #define Lock 1
  211.                #define Query  2
  212.                } LockDrawer;
  213.         } ;
  214.  
  215. typedef union   CommandResults {
  216.         struct {
  217.                UCHAR Code; // always 'M'
  218.                UCHAR VerLSN:4;
  219.                UCHAR VerMSN:4;
  220.                } Version;
  221.  
  222.         struct {
  223.                UCHAR SenseKey;
  224.                // Only valid if ReadError or Drive_Status is on
  225.                #define No_Error      0
  226.                #define ModeMismatch  1
  227.                #define BlockNotFound 2
  228.                #define FatalError    3
  229.                #define SeekError     4
  230.                } SenseData;
  231.  
  232.         struct t {
  233.                struct {
  234.                       UCHAR ADR:4;
  235.                       UCHAR Control:4;
  236.                        }S;
  237.                UCHAR TNO;
  238.                UCHAR Index;
  239.                UCHAR Min;
  240.                UCHAR Sec;
  241.                UCHAR Frame;
  242.                UCHAR Zero;
  243.                UCHAR AMin;
  244.                UCHAR ASec;
  245.                UCHAR AFrame;
  246.                } TrackInfo;
  247.                #define MinFrame 0x00000200L             // 2 min, 0 seconds
  248.  
  249.         struct {
  250.                UCHAR FirstTrack;
  251.                UCHAR LastTrack;
  252.                UCHAR LeadoutMin;
  253.                UCHAR LeadoutSec;
  254.                UCHAR LeadoutFrame;
  255.                UCHAR FirstTrackMin;
  256.                UCHAR FirstTrackSec;
  257.                UCHAR FirstTrackFrame;
  258.                } TOC;
  259.  
  260.         struct {
  261.                UCHAR ATT0;
  262.                UCHAR ATT1;
  263.                UCHAR ATT2;
  264.                UCHAR ATT3;
  265.  
  266.                  // table of settings
  267.                  // ┌──────┬──────┬──────┬──────┬──────────┬──────────┐
  268.                  // │ Att0 │ Att1 │ Att2 │ Att3 │ Right Ch │ Left Ch  │
  269.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  270.                  // │  01  │  00  │  01  │  00  │   On     │   On     │
  271.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  272.                  // │  00  │  00  │  01  │  00  │   On     │   Off    │
  273.                  // ├──────┼──────┼──────┼──────┼──────────┼──────────┤
  274.                  // │  01  │  00  │  00  │  00  │   Off    │   On     │
  275.                  // ├──────┼──────┼──────┼──────┼──────────┴──────────┤
  276.                  // │  00  │  00  │  01  │  01  │  Mono From Right Ch │
  277.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  278.                  // │  01  │  01  │  00  │  00  │  Mono From Left  Ch │
  279.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  280.                  // │  01  │  01  │  01  │  01  │      Mixing         │
  281.                  // ├──────┼──────┼──────┼──────┼─────────────────────┤
  282.                  // │  00  │  01  │  00  │  01  │      Reverse        │
  283.                  // └──────┴──────┴──────┴──────┴─────────────────────┘
  284.  
  285.                } AudioLevel;
  286.  
  287.         struct {
  288.                UCHAR Mode;
  289.                // drive modes used in command 0x50 (set) and 0xC2 (get), see 0x50 for values
  290.                } DriveMode;
  291.  
  292.         struct {
  293.                 UCHAR Size;
  294.                 // Default = Minimum = 1;
  295.                 // Value is decremented by 1 at drive, so 1 = 0 = No interleave
  296.                } InterLeave;
  297.         struct {
  298.                 UCHAR State;
  299.                 #define Unlocked 0
  300.                 #define Locked 1
  301.                 // Value is decremented by 1 at drive, so 1 = 0 = No interleave
  302.                } LockStatus;
  303.         struct {
  304.                UCHAR Control:4;
  305.                UCHAR ADR:4;
  306.                UCHAR UPCCode[7];
  307.                UCHAR Zero;
  308.                UCHAR AFrame;
  309.                } UPC;
  310.         struct {
  311.                UCHAR Type;
  312.                // Disc types, see DataMode command above
  313.                // Mode1 = Multi-Session Photo CD
  314.                // if Mode1, then these values are the first sector of last session
  315.                // else all zeros
  316.                UCHAR Min;
  317.                UCHAR Sec;
  318.                UCHAR Frame;
  319.                } DiscInfo;
  320.  
  321.         } CDROMSTAT, *PCDROMSTAT, near * nPCDROMSTAT ;
  322.  
  323. typedef struct {
  324.        UCHAR Sync1[12];
  325.        UCHAR Header[4];
  326.        UCHAR Subheader1[4];
  327.        UCHAR Subheader2[4];
  328.        UCHAR Data[2048];
  329.        UCHAR ECCbits[280];
  330.        } RawSector, *PRawSector;
  331.  
  332. #define Disable _asm { cli }
  333. #define Enable  _asm { sti }
  334. #define STEN 4                  // status Enable, when 0, status is available
  335. #define DTEN 2                  // data Enable, when 0, data is available
  336.  
  337. #define DefaultDiscSize    270000L
  338.  
  339. typedef struct TOCInfo
  340. {
  341.    UCHAR          min;
  342.    UCHAR          sec;
  343.    UCHAR          frame;
  344.    UCHAR          Control:4;
  345.    UCHAR          ADR:4;
  346.    ULONG          start;
  347. } TOCINFO ;
  348.  
  349. #ifdef DEBUG
  350. #define DPRINTF(x)   printf x ; flushall();
  351. #else
  352. #define DPRINTF(x)
  353. #endif
  354. #define SET_VS             0x04
  355. #define SET_TI             0x08
  356.  
  357. #define CLR_TI             0xF7
  358. #define CLR_VS             0xFB
  359.  
  360. #define TCI_DATA           0x04
  361. #define TCI_AUDIO          0x00
  362. #define CDXA               0x20
  363.  
  364. #define CHANGED         -1
  365. #define DONT_KNOW       0
  366. #define NOT_CHANGED     1
  367. #define I386            (UCHAR)1
  368. #define I486            (UCHAR)2
  369.  
  370. #ifdef TRACE
  371. #define DevHelp_RAS(w,x,y,z) DevHelp_RAS(w,x,y,z)
  372. #else
  373. #define DevHelp_RAS(w,x,y,z)
  374. #endif
  375. #if defined(TRACE1) | defined(TRACE)
  376. #define DevHelp_RAS1(w,x,y,z) DevHelp_RAS(w,x,y,z)
  377. #else
  378. #define DevHelp_RAS1(w,x,y,z)
  379. #endif
  380. #define NoIrq   0
  381. #define Oti12   0x00
  382. #define Irq9    0x10
  383. #define Irq3    0x20
  384. #define Irq5    0x30
  385. #define Irq10   0x40
  386. #define Irq11   0x50
  387. #define Irq12   0x60
  388. #define Irq15   0x70
  389.  
  390. typedef struct _MSGTABLE {              /* DHMT */
  391.  
  392.   USHORT   MsgId;                       /* Message Id #                  */
  393.   USHORT   cMsgStrings;                 /* # of (%) substitution strings */
  394.   PSZ      MsgStrings[1];               /* Substitution string pointers  */
  395. } MSGTABLE;
  396.  
  397. #define MSG_REPLACEMENT_STRING 1178
  398.  
  399.