home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / mCD / Source / scsi_cd.subproj / cd_cmdsint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-26  |  24.4 KB  |  691 lines

  1. /*
  2.  * cd_cmds.h: structs and other declarations which are internal
  3.  *            to cd_commands.c (cd_commands.h only describes what
  4.  *            it is making available to other source files).
  5.  *
  6.  * Garance Alistair Drosehn/March 1994.
  7.  *
  8.  */
  9.  
  10. #define    GET_4BYTE_UINT(x)    \
  11.         (((x##_4b1)<<24)|((x##_4b2)<<16)|((x##_4b3)<<8)|(x##_4b4))
  12. #define    GET_3BYTE_UINT(x)    \
  13.         (((x##_3b1)<<16)|((x##_3b2)<<8)|(x##_3b3))
  14. #define    GET_2BYTE_UINT(x)    \
  15.         (((x##_2b1)<<8)|(x##_2b2))
  16.  
  17. #define    SET_4BYTE_UINT(x,newvalue)    \
  18.         x##_4b1 = (newvalue>>24) & 0x000000FF; \
  19.         x##_4b2 = (newvalue>>16) & 0x000000FF; \
  20.         x##_4b3 = (newvalue>>8) & 0x000000FF; \
  21.         x##_4b4 = newvalue & 0x000000FF
  22. #define    SET_3BYTE_UINT(x,newvalue)    \
  23.         x##_3b1 = (newvalue>>16) & 0x000000FF; \
  24.         x##_3b2 = (newvalue>>8) & 0x000000FF; \
  25.         x##_3b3 = newvalue & 0x000000FF
  26. #define    SET_2BYTE_UINT(x,newvalue)    \
  27.         x##_2b1 = (newvalue>>8) & 0x000000FF; \
  28.         x##_2b2 = newvalue & 0x000000FF
  29.  
  30. /* formats used to indicate the current position on the CD */
  31. struct msf_addr_fmt {
  32.     u_char              hour:8;    /* will probably always be zero */
  33.     u_char              min:8;    /* note this will have values > 60 */
  34.     u_char              sec:8;
  35.     u_char              frame:8;
  36. };
  37.  
  38. struct lba_addr_fmt {
  39.     u_char              lblock_4b1:8,    /* use GET_4BYTE_UINT(lblock) */
  40.                         lblock_4b2:8,    /* to pick up this value */
  41.                         lblock_4b3:8,
  42.                         lblock_4b4:8;
  43. };
  44.  
  45. union cd_addr_fmt {
  46.     struct msf_addr_fmt msf;    /* MSF = minutes, seconds, frame */
  47.     struct lba_addr_fmt lba;    /* LBA = logical block address */
  48. };
  49.  
  50.  
  51. /**************************************************************************
  52.  * start/stop command
  53.  */
  54. struct start_stop_1B_cmd {
  55. #if    __BIG_ENDIAN__
  56.     u_char              ssc_opcode:8;    /* C6OP_STARTSTOP: x'1B' */
  57.     u_char              ssc_lun:3,
  58.                         ssc_reserved1:4,
  59.                         ssc_imm:1;
  60.     u_char              ssc_reserved2[2];
  61.     u_char              ssc_reserved3:6,
  62.                         ssc_loej:1,
  63.                         ssc_start:1;
  64.     u_char              ssc_control:8;
  65. #elif    __LITTLE_ENDIAN__
  66.     u_char              ssc_opcode:8;    /* C6OP_STARTSTOP: x'1B' */
  67.     u_char              ssc_imm:1,
  68.                         ssc_reserved1:4,
  69.                         ssc_lun:3;
  70.     u_char              ssc_reserved2[2];
  71.     u_char              ssc_start:1,
  72.                         ssc_loej:1,
  73.                         ssc_reserved3:6;
  74.     u_char              ssc_control:8;
  75. #else
  76. #error    SCSI command / data structures are compiler sensitive
  77. #endif
  78. };
  79.  
  80.  
  81. /**************************************************************************
  82.  * rezero unit command (other devices call this "rewind" = C6OP_REWIND)
  83.  */
  84. #define C6OP_REZEROUNIT_01 0x01    /* 6-byte SCSI cmd */
  85. struct rezero_unit_01_cmd {
  86. #if    __BIG_ENDIAN__
  87.     u_char              rzu_opcode:8;    /* C6OP_REZEROUNIT: x'01' */
  88.     u_char              rzu_lun:3,
  89.                         rzu_reserved1:5;
  90.     u_char              rzu_reserved2[3];
  91.     u_char              rzu_control:8;
  92. #elif    __LITTLE_ENDIAN__
  93.     u_char              rzu_opcode:8;    /* C6OP_REZEROUNIT: x'01' */
  94.     u_char              rzu_reserved1:5,
  95.                         rzu_lun:3;
  96.     u_char              rzu_reserved2[3];
  97.     u_char              rzu_control:8;
  98. #else
  99. #error    SCSI command / data structures are compiler sensitive
  100. #endif
  101. };
  102.  
  103.  
  104. /**************************************************************************
  105.  * pause/resume command
  106.  */
  107. #define C10OP_PAUSE_4B 0x4b    /* 10-byte SCSI cmd */
  108. struct pause_4b_cmd {
  109. #if    __BIG_ENDIAN__
  110.     u_char              p_op_code:8;    /* C10OP_PAUSE: x'4B' */
  111.     u_char              p_lun:3,
  112.                         p_reserved1:5;
  113.     u_char              p_reserved2[6];
  114.     u_char              p_reserved3:7,
  115.                         p_resume:1;    /* 0 = pause, 1 = resume */
  116.     u_char              p_control:8;
  117. #elif    __LITTLE_ENDIAN__
  118.     u_char              p_op_code:8;    /* C10OP_PAUSE: x'4B' */
  119.     u_char              p_reserved1:5,
  120.                         p_lun:3;
  121.     u_char              p_reserved2[6];
  122.     u_char              p_resume:1,    /* 0 = pause, 1 = resume */
  123.                         p_reserved3:7;
  124.     u_char              p_control:8;
  125. #else
  126. #error    SCSI command / data structures are compiler sensitive
  127. #endif
  128. };
  129.  
  130.  
  131. /**************************************************************************
  132.  * pause command (this opcode probably Sony-specific)
  133.  */
  134. #define C10OP_PAUSE_C5 0xc5    /* 10-byte SCSI cmd */
  135. struct pause_c5_cmd {
  136. #if    __BIG_ENDIAN__
  137.     u_char              p_op_code:8;    /* C10OP_PAUSE: x'C5' */
  138.     u_char              p_lun:3,
  139.                         p_pause:1,    /* 0 = resume, 1 = pause */
  140.                         p_reserved1:4;
  141.     u_char              p_reserved2[7];
  142.     u_char              p_control:8;
  143. #elif    __LITTLE_ENDIAN__
  144.     u_char              p_op_code:8;    /* C10OP_PAUSE: x'C5' */
  145.     u_char              p_reserved1:4,
  146.                         p_pause:1,    /* 0 = resume, 1 = pause */
  147.                         p_lun:3;
  148.     u_char              p_reserved2[7];
  149.     u_char              p_control:8;
  150. #else
  151. #error    SCSI command / data structures are compiler sensitive
  152. #endif
  153. };
  154.  
  155.  
  156. /**************************************************************************
  157.  * playaudio command (this opcode probably Sony-specific)
  158.  */
  159. #define C6OP_PLAYAUDIO_C8 0xc8    /* 6-byte SCSI cmd */
  160. struct playaudio_c8_cmd {
  161. #if    __BIG_ENDIAN__
  162.     u_char              pa_op_code:8;    /* C6OP_PLAYAUDIO: x'C8' */
  163.     u_char              pa_lun:3,
  164.                         pa_reserved1:5;
  165.     u_char              pa_lba_4b1:8,    /* LBA to start playing */
  166.                         pa_lba_4b2:8,    /* use GET_4BYTE_UINT(pa_lba) */
  167.                         pa_lba_4b3:8,    /* to pick up this value */
  168.                         pa_lba_4b4:8;
  169.     u_char              pa_reserved2:8;
  170.     u_char              pa_length_2b1:8,    /* GET_2BYTE_UINT(pa_length) */
  171.                         pa_length_2b2:8;    /* will get this value */
  172.     u_char              pa_control:8;
  173. #elif    __LITTLE_ENDIAN__
  174.     u_char              pa_op_code:8;    /* C6OP_PLAYAUDIO: x'C8' */
  175.     u_char              pa_reserved1:5,
  176.                         pa_lun:3;
  177.     u_char              pa_lba_4b1:8,    /* LBA to start playing */
  178.                         pa_lba_4b2:8,    /* use GET_4BYTE_UINT(pa_lba) */
  179.                         pa_lba_4b3:8,    /* to pick up this value */
  180.                         pa_lba_4b4:8;
  181.     u_char              pa_reserved2:8;
  182.     u_char              pa_length_2b1:8,    /* GET_2BYTE_UINT(pa_length) */
  183.                         pa_length_2b2:8;    /* will get this value */
  184.     u_char              pa_control:8;
  185. #else
  186. #error    SCSI command / data structures are compiler sensitive
  187. #endif
  188. };
  189.  
  190. /**************************************************************************
  191.  * play audio command
  192.  */
  193. #define C10OP_PLAYAUDIO_MSF_47 0x47    /* 10-byte SCSI cmd */
  194. struct playaudio_msf_47_cmd {
  195. #if    __BIG_ENDIAN__
  196.     u_char              pam_op_code:8;    /* C10OP_PLAYAUDIO_MSF: x'47' */
  197.     u_char              pam_lun:3,
  198.                         pam_reserved1:5;
  199.     u_char              pam_reserved2:8;
  200.     u_char              pam_start_min:8;
  201.     u_char              pam_start_sec:8;
  202.     u_char              pam_start_frame:8;
  203.     u_char              pam_end_min:8;
  204.     u_char              pam_end_sec:8;
  205.     u_char              pam_end_frame:8;
  206.     u_char              pam_control:8;
  207. #elif    __LITTLE_ENDIAN__
  208.     u_char              pam_op_code:8;    /* C10OP_PLAYAUDIO_MSF: x'47' */
  209.     u_char              pam_reserved1:5,
  210.                         pam_lun:3;
  211.     u_char              pam_reserved2:8;
  212.     u_char              pam_start_min:8;
  213.     u_char              pam_start_sec:8;
  214.     u_char              pam_start_frame:8;
  215.     u_char              pam_end_min:8;
  216.     u_char              pam_end_sec:8;
  217.     u_char              pam_end_frame:8;
  218.     u_char              pam_control:8;
  219. #else
  220. #error    SCSI command / data structures are compiler sensitive
  221. #endif
  222. };
  223.  
  224. /**************************************************************************
  225.  * read subchannel command
  226.  */
  227. #define C10OP_READSUBCHANNEL_42 0x42    /* 10-byte SCSI cmd */
  228. struct read_subchannel_42_cmd {
  229. #if    __BIG_ENDIAN__
  230.     u_char              rsc_op_code:8;    /* C10OP_READSUBCHANNEL: x'42' */
  231.     u_char              rsc_lun:3,
  232.                         rsc_reserved1:3,
  233.                         rsc_msf:1,
  234.                         rsc_reserved2:1;
  235.     u_char              rsc_reserved3:1,
  236.                         rsc_subq:1,    /* sub-channel data (vs header-only) */
  237.                         rsc_reserved4:6;
  238.     u_char              rsc_dformat:8;
  239.     u_char              rsc_reserved5[2];
  240.     u_char              rsc_track:8;
  241.  /*
  242.   * use SET_2BYTE_UINT(rsc_length,newvalue) to set the following two-byte
  243.   * integer value 
  244.   */
  245.     u_char              rsc_length_2b1:8,    /* GET_2BYTE_UINT(rsc_length) */
  246.                         rsc_length_2b2:8;    /* will get this value */
  247.     u_char              rsc_control:8;
  248. #elif    __LITTLE_ENDIAN__
  249.     u_char              rsc_op_code:8;    /* C10OP_READSUBCHANNEL: x'42' */
  250.     u_char              rsc_reserved2:1,
  251.                         rsc_msf:1,
  252.                         rsc_reserved1:3,
  253.                         rsc_lun:3;
  254.     u_char              rsc_reserved4:6;
  255.     u_char              rsc_subq:1,    /* sub-channel data (vs header-only) */
  256.                         rsc_reserved3:1;
  257.     u_char              rsc_dformat:8;
  258.     u_char              rsc_reserved5[2];
  259.     u_char              rsc_track:8;
  260.  /*
  261.   * use SET_2BYTE_UINT(rsc_length,newvalue) to set the following two-byte
  262.   * integer value 
  263.   */
  264.     u_char              rsc_length_2b1:8,    /* GET_2BYTE_UINT(rsc_length) */
  265.                         rsc_length_2b2:8;    /* will get this value */
  266.     u_char              rsc_control:8;
  267. #else
  268. #error    SCSI command / data structures are compiler sensitive
  269. #endif
  270. };
  271.  
  272. /* sub-channel data header */
  273. struct sc_header {
  274.     u_char              sch_reserved1:8;
  275.     u_char              sch_astatus:8;    /* audio status */
  276.  /*
  277.   * use SET_2BYTE_UINT(sch_length,newvalue) to set the following two-byte
  278.   * integer value 
  279.   */
  280.     u_char              sch_length_2b1:8,    /* GET_2BYTE_UINT(sch_length) */
  281.                         sch_length_2b2:8;    /* will get this value */
  282. };
  283.  
  284. /* sub-channel data format page 1:
  285.  *     CD-ROM current position data block
  286.  */
  287. struct sc_cur_pos {
  288. #if    __BIG_ENDIAN__
  289.     u_char              sc1_data_code:8;
  290.     u_char              sc1_reserved1:4,
  291.                         sc1_control:4;
  292.     u_char              sc1_track:8;
  293.     u_char              sc1_index:8;
  294.     union cd_addr_fmt   sc1_abs_addr;    /* 4 bytes */
  295.     union cd_addr_fmt   sc1_rel_addr;    /* 4 bytes */
  296. #elif    __LITTLE_ENDIAN__
  297.     u_char              sc1_data_code:8;
  298.     u_char              sc1_control:4,
  299.                         sc1_reserved1:4;
  300.     u_char              sc1_track:8;
  301.     u_char              sc1_index:8;
  302.     union cd_addr_fmt   sc1_abs_addr;    /* 4 bytes */
  303.     union cd_addr_fmt   sc1_rel_addr;    /* 4 bytes */
  304. #else
  305. #error    SCSI command / data structures are compiler sensitive
  306. #endif
  307. };
  308.  
  309. /* sub-channel data format page 2:
  310.  *     Media Catalog Number Data Format
  311.  */
  312. struct sc_med_cat {
  313. #if    __BIG_ENDIAN__
  314.     u_char              sc2_data_code:8;
  315.     u_char              sc2_reserved1[3];
  316.     u_char              sc2_mcval:1,
  317.                         sc2_reserved2:7;
  318.     u_char              sc2_med_cat[15];
  319. #elif    __LITTLE_ENDIAN__
  320.     u_char              sc2_data_code:8;
  321.     u_char              sc2_reserved1[3];
  322.     u_char              sc2_reserved2:7,
  323.                         sc2_mcval:1;
  324.     u_char              sc2_med_cat[15];
  325. #else
  326. #error    SCSI command / data structures are compiler sensitive
  327. #endif
  328. };
  329.  
  330. /* sub-channel data format page 3:
  331.  *     Track International Standard Recording Data Format
  332.  */
  333. struct sc_isrc {
  334. #if    __BIG_ENDIAN__
  335.     u_char              sc3_data_code:8;
  336.     u_char              sc3_reserved1:8;
  337.     u_char              sc3_track:8;
  338.     u_char              sc3_reserved2:8;
  339.     u_char              sc3_tcval:1,
  340.                         sc3_reserved3:7;
  341.     u_char              sc3_isrc[15];
  342. #elif    __LITTLE_ENDIAN__
  343.     u_char              sc3_data_code:8;
  344.     u_char              sc3_reserved1:8;
  345.     u_char              sc3_track:8;
  346.     u_char              sc3_reserved2:8;
  347.     u_char              sc3_reserved3:7,
  348.                         sc3_tcval:1;
  349.     u_char              sc3_isrc[15];
  350. #else
  351. #error    SCSI command / data structures are compiler sensitive
  352. #endif
  353. };
  354.  
  355. /* ----------------------------------------- */
  356. /* sub-channel reply, the union of all pages */
  357. /* ----------------------------------------- */
  358. struct sc_reply {
  359.     struct sc_header    scr_header;
  360.     union {
  361.     struct sc_cur_pos   u_scr_cur_pos;
  362.     struct sc_med_cat   u_scr_med_cat;
  363.     struct sc_isrc      u_scr_isrc;
  364.     }                   u;
  365. };
  366.  
  367. /* the routine almost no one calls: */
  368. int
  369. do_readsubchannel_42(int fd, int msf, int subq, int page, int track,
  370.              struct sc_reply * scrp, struct esense_reply * erp);
  371.  
  372.  
  373. /**************************************************************************
  374.  * read Table-Of-Contents command
  375.  */
  376. #define C10OP_READTOC_43 0x43    /* 10-byte SCSI cmd */
  377. struct readtoc_43_cmd {
  378. #if    __BIG_ENDIAN__
  379.     u_char              rt_op_code:8;    /* C10OP_READTOC: x'43' */
  380.     u_char              rt_lun:3,
  381.                         rt_reserved1:3,
  382.                         rt_msf:1,
  383.                         rt_reserved2:1;
  384.     u_char              rt_reserved3[4];
  385.     u_char              rt_starttrack:8;
  386.  /*
  387.   * use SET_2BYTE_UINT(rt_length,newvalue) to set the following two-byte
  388.   * integer value 
  389.   */
  390.     u_char              rt_length_2b1:8,    /* GET_2BYTE_UINT(rt_length) */
  391.                         rt_length_2b2:8;    /* will get this value */
  392.     u_char              rt_control:8;
  393. #elif    __LITTLE_ENDIAN__
  394.     u_char              rt_op_code:8;    /* C10OP_READTOC: x'43' */
  395.     u_char              rt_reserved2:1,
  396.                         rt_msf:1,
  397.                         rt_reserved1:3,
  398.                         rt_lun:3;
  399.     u_char              rt_reserved3[4];
  400.     u_char              rt_starttrack:8;
  401.  /*
  402.   * use SET_2BYTE_UINT(rt_length,newvalue) to set the following two-byte
  403.   * integer value 
  404.   */
  405.     u_char              rt_length_2b1:8,    /* GET_2BYTE_UINT(rt_length) */
  406.                         rt_length_2b2:8;    /* will get this value */
  407.     u_char              rt_control:8;
  408. #else
  409. #error    SCSI command / data structures are compiler sensitive
  410. #endif
  411. };
  412.  
  413. /* read toc reply header */
  414. struct rtr_header {
  415.     u_char              rtr_datalen_2b1,    /* GET_2BYTE_UINT(rtr_datalen)
  416.                          * */
  417.                         rtr_datalen_2b2;    /* will pick up this value */
  418.     u_char              rtr_firsttrack;
  419.     u_char              rtr_lasttrack;
  420. };
  421.  
  422. /* read toc reply descriptor */
  423. struct rtr_desc {
  424. #if    __BIG_ENDIAN__
  425.     u_char              rtrd_reserved1:8;
  426.     u_char              rtrd_reserved2:4,
  427.                         rtrd_control:4;
  428.     u_char              rtrd_track:8,
  429.                         rtrd_reserved3:8;
  430.     union cd_addr_fmt   rtrd_addr;    /* 4 bytes */
  431. #elif    __LITTLE_ENDIAN__
  432.     u_char              rtrd_reserved1:8;
  433.     u_char              rtrd_control:4,
  434.                         rtrd_reserved2:4;
  435.     u_char              rtrd_track:8,
  436.                         rtrd_reserved3:8;
  437.     union cd_addr_fmt   rtrd_addr;    /* 4 bytes */
  438. #else
  439. #error    SCSI command / data structures are compiler sensitive
  440. #endif
  441. };
  442.  
  443. /* read toc reply with one descriptor, to read more than 1 descriptor
  444.    blocks at a time, one must allocate
  445.    sizeof(struct rtr_desc)*num_descriptrs+sizeof(struct rtr_header) bytes,
  446.    and then traverse through the memory */
  447.  
  448. struct readtoc_43_reply {
  449.     struct rtr_header   h;
  450.     struct rtr_desc     d[101];    /* array of descriptor block's */
  451. };
  452.  
  453.  
  454. /**************************************************************************
  455.  * declarations for playback-status and playback-control cmds
  456.  *              (both probably Sony-specific)
  457.  */
  458. #define C10OP_PLAYBACKSTATUS_C4  0xc4    /* 10-byte SCSI cmd */
  459. #define C10OP_PLAYBACKCONTROL_C9 0xc9    /* 10-byte SCSI cmd */
  460. struct playback_statuscontrol_cmd {
  461. #if    __BIG_ENDIAN__
  462.     u_char              pb_opcode:8;    /* C10OP_PLAYBACKSTATUS: x'C4' or
  463.                      * C10OP_PLAYBACKCONTROL: x'C9' */
  464.     u_char              pb_lun:3,
  465.                         pb_reserved1:5;
  466.     u_char              pb_reserved2[5];
  467.  /*
  468.   * use SET_2BYTE_UINT(pb_length,newvalue) to set the following two-byte
  469.   * integer value 
  470.   */
  471.     u_char              pb_length_2b1:8,    /* GET_2BYTE_UINT(pb_length) */
  472.                         pb_length_2b2:8;    /* will get this value */
  473.     u_char              pb_control:8;
  474. #elif    __LITTLE_ENDIAN__
  475.     u_char              pb_opcode:8;    /* C10OP_PLAYBACKSTATUS: x'C4' or
  476.                      * C10OP_PLAYBACKCONTROL: x'C9' */
  477.     u_char              pb_reserved1:5,
  478.                         pb_lun:3;
  479.     u_char              pb_reserved2[5];
  480.  /*
  481.   * use SET_2BYTE_UINT(pb_length,newvalue) to set the following two-byte
  482.   * integer value 
  483.   */
  484.     u_char              pb_length_2b1:8,    /* GET_2BYTE_UINT(pb_length) */
  485.                         pb_length_2b2:8;    /* will get this value */
  486.     u_char              pb_control:8;
  487. #else
  488. #error    SCSI command / data structures are compiler sensitive
  489. #endif
  490. };
  491.  
  492. struct playback_c4c9_data {
  493. #if    __BIG_ENDIAN__
  494.     u_char              pbd_reserved1:8;
  495.     u_char              pbd_reserved2:7,
  496.                         pbd_lbamsf:1;
  497.     u_char              pbd_astatDataLength_2b1:8,    /* GET_2BYTE_UINT(pbd_ast
  498.                              * atDataLength) */
  499.                         pbd_astatDataLength_2b2:8;    /* will get this value */
  500.     u_char              pbd_audio_status:8;
  501.     u_char              pbd_reserved3:4,
  502.                         pbd_control:4;
  503.     union cd_addr_fmt   pbd_cd_addr;    /* 4 bytes */
  504.     u_char              pbd_reserved4:4,
  505.                         pbd_ch0_sel:4;
  506.     u_char              pbd_ch0_vol:8;
  507.     u_char              pbd_reserved5:4,
  508.                         pbd_ch1_sel:4;
  509.     u_char              pbd_ch1_vol:8;
  510.     u_char              pbd_reserved6:4,
  511.                         pbd_ch2_sel:4;
  512.     u_char              pbd_ch2_vol:8;
  513.     u_char              pbd_reserved7:4,
  514.                         pbd_ch3_sel:4;
  515.     u_char              pbd_ch3_vol:8;
  516. #elif    __LITTLE_ENDIAN__
  517.     u_char              pbd_reserved1:8;
  518.     u_char              pbd_lbamsf:1,
  519.                         pbd_reserved2:7;
  520.     u_char              pbd_astatDataLength_2b1:8,    /* GET_2BYTE_UINT(pbd_ast
  521.                              * atDataLength) */
  522.                         pbd_astatDataLength_2b2:8;    /* will get this value */
  523.     u_char              pbd_audio_status:8;
  524.     u_char              pbd_control:4,
  525.                         pbd_reserved3:4;
  526.     union cd_addr_fmt   pbd_cd_addr;    /* 4 bytes */
  527.     u_char              pbd_ch0_sel:4,
  528.                         pbd_reserved4:4;
  529.     u_char              pbd_ch0_vol:8;
  530.     u_char              pbd_ch1_sel:4,
  531.                         pbd_reserved5:4;
  532.     u_char              pbd_ch1_vol:8;
  533.     u_char              pbd_ch2_sel:4,
  534.                         pbd_reserved6:4;
  535.     u_char              pbd_ch2_vol:8;
  536.     u_char              pbd_ch3_sel:4,
  537.                         pbd_reserved7:4;
  538.     u_char              pbd_ch3_vol:8;
  539. #else
  540. #error    SCSI command / data structures are compiler sensitive
  541. #endif
  542. };
  543.  
  544.  
  545. /**************************************************************************
  546.  * declarations for mode-sense and mode-select cmds
  547.  */
  548. struct mode_sense_select_cmd {
  549. #if    __BIG_ENDIAN__
  550.     u_char              msc_opcode;    /* C6OP_MODESELECT: x'15' or
  551.                      * C6OP_MODESENSE: x'1A' */
  552.     u_char              msc_lun:3,
  553.                         msc_pf:1,    /* only used by MODESELECT */
  554.                         msc_reserved1:3,
  555.                         msc_sp:1;    /* only used by MODESELECT */
  556.     u_char              msc_pcf:2,    /* only used by MODESENSE */
  557.                         msc_page:6;    /* only used by MODESENSE */
  558.     u_char              msc_reserved2:8;
  559.     u_char              msc_len;
  560.     u_char              msc_control;
  561. #elif    __LITTLE_ENDIAN__
  562.     u_char              msc_opcode;    /* C6OP_MODESELECT: x'15' or
  563.                      * C6OP_MODESENSE: x'1A' */
  564.     u_char              msc_sp:1,    /* only used by MODESELECT */
  565.                         msc_reserved1:3,
  566.                         msc_pf:1,    /* only used by MODESELECT */
  567.                         msc_lun:3;
  568.     u_char              msc_page:6,    /* only used by MODESENSE */
  569.                         msc_pcf:2;    /* only used by MODESENSE */
  570.     u_char              msc_reserved2:8;
  571.     u_char              msc_len;
  572.     u_char              msc_control;
  573. #else
  574. #error    SCSI command / data structures are compiler sensitive
  575. #endif
  576. };
  577.  
  578. struct mode_sense_param_list_header {
  579.     u_char              plh_snslen;    /* only used by MODESENSE */
  580.     u_char              plh_medium;
  581.     u_char              plh_reserved;
  582.     u_char              plh_blkdesclen;    /* either 0 or 8, usually 8 */
  583. };
  584.  
  585. struct mode_sense_block_descriptor {
  586.     u_char              bd_density;
  587.     u_char              bd_nblk_3b1,    /* use GET_3BYTE_UINT(bd_nblk) */
  588.                         bd_nblk_3b2,    /* to pick up this value */
  589.                         bd_nblk_3b3;    /* # of blocks, in 3 bytes */
  590.     u_char              bd_reserved;
  591.     u_char              bd_blklen_3b1,    /* use GET_3BYTE_UINT(bd_blklen) */
  592.                         bd_blklen_3b2,    /* to pick up this value */
  593.                         bd_blklen_3b3;    /* block-length, in 3 bytes */
  594. };
  595.  
  596. struct mode_sense_pagecode_E {
  597. #if    __BIG_ENDIAN__
  598.     u_char              pce_reserved1:2,
  599.                         pce_pagecode:6;    /* page code x'0E' */
  600.     u_char              pce_parlen;    /* length, always x'0E' */
  601.     u_char              pce_reserved2:5,
  602.                         pce_immd:1,
  603.                         pce_reserved3:2;
  604.     u_char              pce_reserved4[5];    /* skip over a few bytes */
  605.     u_char              pce_reserved5:4,
  606.                         pce_ch0_sel:4;
  607.     u_char              pce_ch0_vol;
  608.     u_char              pce_reserved6:4,
  609.                         pce_ch1_sel:4;
  610.     u_char              pce_ch1_vol;
  611.     u_char              pce_reserved7:4,
  612.                         pce_ch2_sel:4;
  613.     u_char              pce_ch2_vol;
  614.     u_char              pce_reserved8:4,
  615.                         pce_ch3_sel:4;
  616.     u_char              pce_ch3_vol;
  617. #elif    __LITTLE_ENDIAN__
  618.     u_char              pce_pagecode:6,    /* page code x'0E' */
  619.                         pce_reserved1:2;
  620.     u_char              pce_parlen;    /* length, always x'0E' */
  621.     u_char              pce_reserved3:2,
  622.                         pce_immd:1,
  623.                         pce_reserved2:5;
  624.     u_char              pce_reserved4[5];    /* skip over a few bytes */
  625.     u_char              pce_ch0_sel:4,
  626.                         pce_reserved5:4;
  627.     u_char              pce_ch0_vol;
  628.     u_char              pce_ch1_sel:4,
  629.                         pce_reserved6:4;
  630.     u_char              pce_ch1_vol;
  631.     u_char              pce_ch2_sel:4,
  632.                         pce_reserved7:4;
  633.     u_char              pce_ch2_vol;
  634.     u_char              pce_ch3_sel:4,
  635.                         pce_reserved8:4;
  636.     u_char              pce_ch3_vol;
  637. #else
  638. #error    SCSI command / data structures are compiler sensitive
  639. #endif
  640. };
  641.  
  642. struct mode_sense_select_reply {
  643.     struct mode_sense_param_list_header msr_plh;
  644.     struct mode_sense_block_descriptor msr_bd;
  645.  /*
  646.   * the following really should be declared as a union that included all the
  647.   * structs used by any page-code 
  648.   */
  649.     union {
  650.     struct mode_sense_pagecode_E u_msr_pcE;
  651.     }                   u;
  652. };
  653.  
  654. struct mode_select_alt_reply {    /* sans block descriptor */
  655.     struct mode_sense_param_list_header msar_plh;
  656.  /*
  657.   * the following really should be declared as a union that included all the
  658.   * structs used by any page-code 
  659.   */
  660.     union {
  661.     struct mode_sense_pagecode_E u_msar_pcE;
  662.     }                   u;
  663. };
  664.  
  665.  
  666. /**************************************************************************
  667.  * prevent/allow medium removal command
  668.  */
  669. #define C6OP_PREVENT_REMOVAL_1E 0x1E    /* 6-byte command */
  670. struct prevent_removal_1e_cmd {
  671. #if    __BIG_ENDIAN__
  672.     u_char              par_op_code;    /* C6OP_PREVENT_REMOVAL: x'1E' */
  673.     u_char              par_lun:3,
  674.                         par_reserved1:5;
  675.     u_char              par_reserved2[2];
  676.     u_char              par_reserved3:7,
  677.                         par_prevent:1;    /* 0 = allow, 1 = prevent */
  678.     u_char              par_control;
  679. #elif    __LITTLE_ENDIAN__
  680.     u_char              par_op_code;    /* C6OP_PREVENT_REMOVAL: x'1E' */
  681.     u_char              par_reserved1:5,
  682.                         par_lun:3;
  683.     u_char              par_reserved2[2];
  684.     u_char              par_prevent:1,    /* 0 = allow, 1 = prevent */
  685.                         par_reserved3:7;
  686.     u_char              par_control;
  687. #else
  688. #error    SCSI command / data structures are compiler sensitive
  689. #endif
  690. };
  691.