This is cd_cmdsint.h in view mode; [Download] [Up]
/* * cd_cmds.h: structs and other declarations which are internal * to cd_commands.c (cd_commands.h only describes what * it is making available to other source files). * * Garance Alistair Drosehn/March 1994. * */ #define GET_4BYTE_UINT(x) \ (((x##_4b1)<<24)|((x##_4b2)<<16)|((x##_4b3)<<8)|(x##_4b4)) #define GET_3BYTE_UINT(x) \ (((x##_3b1)<<16)|((x##_3b2)<<8)|(x##_3b3)) #define GET_2BYTE_UINT(x) \ (((x##_2b1)<<8)|(x##_2b2)) #define SET_4BYTE_UINT(x,newvalue) \ x##_4b1 = (newvalue>>24) & 0x000000FF; \ x##_4b2 = (newvalue>>16) & 0x000000FF; \ x##_4b3 = (newvalue>>8) & 0x000000FF; \ x##_4b4 = newvalue & 0x000000FF #define SET_3BYTE_UINT(x,newvalue) \ x##_3b1 = (newvalue>>16) & 0x000000FF; \ x##_3b2 = (newvalue>>8) & 0x000000FF; \ x##_3b3 = newvalue & 0x000000FF #define SET_2BYTE_UINT(x,newvalue) \ x##_2b1 = (newvalue>>8) & 0x000000FF; \ x##_2b2 = newvalue & 0x000000FF /* formats used to indicate the current position on the CD */ struct msf_addr_fmt { u_char hour:8; /* will probably always be zero */ u_char min:8; /* note this will have values > 60 */ u_char sec:8; u_char frame:8; }; struct lba_addr_fmt { u_char lblock_4b1:8, /* use GET_4BYTE_UINT(lblock) */ lblock_4b2:8, /* to pick up this value */ lblock_4b3:8, lblock_4b4:8; }; union cd_addr_fmt { struct msf_addr_fmt msf; /* MSF = minutes, seconds, frame */ struct lba_addr_fmt lba; /* LBA = logical block address */ }; /************************************************************************** * start/stop command */ struct start_stop_1B_cmd { #if __BIG_ENDIAN__ u_char ssc_opcode:8; /* C6OP_STARTSTOP: x'1B' */ u_char ssc_lun:3, ssc_reserved1:4, ssc_imm:1; u_char ssc_reserved2[2]; u_char ssc_reserved3:6, ssc_loej:1, ssc_start:1; u_char ssc_control:8; #elif __LITTLE_ENDIAN__ u_char ssc_opcode:8; /* C6OP_STARTSTOP: x'1B' */ u_char ssc_imm:1, ssc_reserved1:4, ssc_lun:3; u_char ssc_reserved2[2]; u_char ssc_start:1, ssc_loej:1, ssc_reserved3:6; u_char ssc_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * rezero unit command (other devices call this "rewind" = C6OP_REWIND) */ #define C6OP_REZEROUNIT_01 0x01 /* 6-byte SCSI cmd */ struct rezero_unit_01_cmd { #if __BIG_ENDIAN__ u_char rzu_opcode:8; /* C6OP_REZEROUNIT: x'01' */ u_char rzu_lun:3, rzu_reserved1:5; u_char rzu_reserved2[3]; u_char rzu_control:8; #elif __LITTLE_ENDIAN__ u_char rzu_opcode:8; /* C6OP_REZEROUNIT: x'01' */ u_char rzu_reserved1:5, rzu_lun:3; u_char rzu_reserved2[3]; u_char rzu_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * pause/resume command */ #define C10OP_PAUSE_4B 0x4b /* 10-byte SCSI cmd */ struct pause_4b_cmd { #if __BIG_ENDIAN__ u_char p_op_code:8; /* C10OP_PAUSE: x'4B' */ u_char p_lun:3, p_reserved1:5; u_char p_reserved2[6]; u_char p_reserved3:7, p_resume:1; /* 0 = pause, 1 = resume */ u_char p_control:8; #elif __LITTLE_ENDIAN__ u_char p_op_code:8; /* C10OP_PAUSE: x'4B' */ u_char p_reserved1:5, p_lun:3; u_char p_reserved2[6]; u_char p_resume:1, /* 0 = pause, 1 = resume */ p_reserved3:7; u_char p_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * pause command (this opcode probably Sony-specific) */ #define C10OP_PAUSE_C5 0xc5 /* 10-byte SCSI cmd */ struct pause_c5_cmd { #if __BIG_ENDIAN__ u_char p_op_code:8; /* C10OP_PAUSE: x'C5' */ u_char p_lun:3, p_pause:1, /* 0 = resume, 1 = pause */ p_reserved1:4; u_char p_reserved2[7]; u_char p_control:8; #elif __LITTLE_ENDIAN__ u_char p_op_code:8; /* C10OP_PAUSE: x'C5' */ u_char p_reserved1:4, p_pause:1, /* 0 = resume, 1 = pause */ p_lun:3; u_char p_reserved2[7]; u_char p_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * playaudio command (this opcode probably Sony-specific) */ #define C6OP_PLAYAUDIO_C8 0xc8 /* 6-byte SCSI cmd */ struct playaudio_c8_cmd { #if __BIG_ENDIAN__ u_char pa_op_code:8; /* C6OP_PLAYAUDIO: x'C8' */ u_char pa_lun:3, pa_reserved1:5; u_char pa_lba_4b1:8, /* LBA to start playing */ pa_lba_4b2:8, /* use GET_4BYTE_UINT(pa_lba) */ pa_lba_4b3:8, /* to pick up this value */ pa_lba_4b4:8; u_char pa_reserved2:8; u_char pa_length_2b1:8, /* GET_2BYTE_UINT(pa_length) */ pa_length_2b2:8; /* will get this value */ u_char pa_control:8; #elif __LITTLE_ENDIAN__ u_char pa_op_code:8; /* C6OP_PLAYAUDIO: x'C8' */ u_char pa_reserved1:5, pa_lun:3; u_char pa_lba_4b1:8, /* LBA to start playing */ pa_lba_4b2:8, /* use GET_4BYTE_UINT(pa_lba) */ pa_lba_4b3:8, /* to pick up this value */ pa_lba_4b4:8; u_char pa_reserved2:8; u_char pa_length_2b1:8, /* GET_2BYTE_UINT(pa_length) */ pa_length_2b2:8; /* will get this value */ u_char pa_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * play audio command */ #define C10OP_PLAYAUDIO_MSF_47 0x47 /* 10-byte SCSI cmd */ struct playaudio_msf_47_cmd { #if __BIG_ENDIAN__ u_char pam_op_code:8; /* C10OP_PLAYAUDIO_MSF: x'47' */ u_char pam_lun:3, pam_reserved1:5; u_char pam_reserved2:8; u_char pam_start_min:8; u_char pam_start_sec:8; u_char pam_start_frame:8; u_char pam_end_min:8; u_char pam_end_sec:8; u_char pam_end_frame:8; u_char pam_control:8; #elif __LITTLE_ENDIAN__ u_char pam_op_code:8; /* C10OP_PLAYAUDIO_MSF: x'47' */ u_char pam_reserved1:5, pam_lun:3; u_char pam_reserved2:8; u_char pam_start_min:8; u_char pam_start_sec:8; u_char pam_start_frame:8; u_char pam_end_min:8; u_char pam_end_sec:8; u_char pam_end_frame:8; u_char pam_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * read subchannel command */ #define C10OP_READSUBCHANNEL_42 0x42 /* 10-byte SCSI cmd */ struct read_subchannel_42_cmd { #if __BIG_ENDIAN__ u_char rsc_op_code:8; /* C10OP_READSUBCHANNEL: x'42' */ u_char rsc_lun:3, rsc_reserved1:3, rsc_msf:1, rsc_reserved2:1; u_char rsc_reserved3:1, rsc_subq:1, /* sub-channel data (vs header-only) */ rsc_reserved4:6; u_char rsc_dformat:8; u_char rsc_reserved5[2]; u_char rsc_track:8; /* * use SET_2BYTE_UINT(rsc_length,newvalue) to set the following two-byte * integer value */ u_char rsc_length_2b1:8, /* GET_2BYTE_UINT(rsc_length) */ rsc_length_2b2:8; /* will get this value */ u_char rsc_control:8; #elif __LITTLE_ENDIAN__ u_char rsc_op_code:8; /* C10OP_READSUBCHANNEL: x'42' */ u_char rsc_reserved2:1, rsc_msf:1, rsc_reserved1:3, rsc_lun:3; u_char rsc_reserved4:6; u_char rsc_subq:1, /* sub-channel data (vs header-only) */ rsc_reserved3:1; u_char rsc_dformat:8; u_char rsc_reserved5[2]; u_char rsc_track:8; /* * use SET_2BYTE_UINT(rsc_length,newvalue) to set the following two-byte * integer value */ u_char rsc_length_2b1:8, /* GET_2BYTE_UINT(rsc_length) */ rsc_length_2b2:8; /* will get this value */ u_char rsc_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /* sub-channel data header */ struct sc_header { u_char sch_reserved1:8; u_char sch_astatus:8; /* audio status */ /* * use SET_2BYTE_UINT(sch_length,newvalue) to set the following two-byte * integer value */ u_char sch_length_2b1:8, /* GET_2BYTE_UINT(sch_length) */ sch_length_2b2:8; /* will get this value */ }; /* sub-channel data format page 1: * CD-ROM current position data block */ struct sc_cur_pos { #if __BIG_ENDIAN__ u_char sc1_data_code:8; u_char sc1_reserved1:4, sc1_control:4; u_char sc1_track:8; u_char sc1_index:8; union cd_addr_fmt sc1_abs_addr; /* 4 bytes */ union cd_addr_fmt sc1_rel_addr; /* 4 bytes */ #elif __LITTLE_ENDIAN__ u_char sc1_data_code:8; u_char sc1_control:4, sc1_reserved1:4; u_char sc1_track:8; u_char sc1_index:8; union cd_addr_fmt sc1_abs_addr; /* 4 bytes */ union cd_addr_fmt sc1_rel_addr; /* 4 bytes */ #else #error SCSI command / data structures are compiler sensitive #endif }; /* sub-channel data format page 2: * Media Catalog Number Data Format */ struct sc_med_cat { #if __BIG_ENDIAN__ u_char sc2_data_code:8; u_char sc2_reserved1[3]; u_char sc2_mcval:1, sc2_reserved2:7; u_char sc2_med_cat[15]; #elif __LITTLE_ENDIAN__ u_char sc2_data_code:8; u_char sc2_reserved1[3]; u_char sc2_reserved2:7, sc2_mcval:1; u_char sc2_med_cat[15]; #else #error SCSI command / data structures are compiler sensitive #endif }; /* sub-channel data format page 3: * Track International Standard Recording Data Format */ struct sc_isrc { #if __BIG_ENDIAN__ u_char sc3_data_code:8; u_char sc3_reserved1:8; u_char sc3_track:8; u_char sc3_reserved2:8; u_char sc3_tcval:1, sc3_reserved3:7; u_char sc3_isrc[15]; #elif __LITTLE_ENDIAN__ u_char sc3_data_code:8; u_char sc3_reserved1:8; u_char sc3_track:8; u_char sc3_reserved2:8; u_char sc3_reserved3:7, sc3_tcval:1; u_char sc3_isrc[15]; #else #error SCSI command / data structures are compiler sensitive #endif }; /* ----------------------------------------- */ /* sub-channel reply, the union of all pages */ /* ----------------------------------------- */ struct sc_reply { struct sc_header scr_header; union { struct sc_cur_pos u_scr_cur_pos; struct sc_med_cat u_scr_med_cat; struct sc_isrc u_scr_isrc; } u; }; /* the routine almost no one calls: */ int do_readsubchannel_42(int fd, int msf, int subq, int page, int track, struct sc_reply * scrp, struct esense_reply * erp); /************************************************************************** * read Table-Of-Contents command */ #define C10OP_READTOC_43 0x43 /* 10-byte SCSI cmd */ struct readtoc_43_cmd { #if __BIG_ENDIAN__ u_char rt_op_code:8; /* C10OP_READTOC: x'43' */ u_char rt_lun:3, rt_reserved1:3, rt_msf:1, rt_reserved2:1; u_char rt_reserved3[4]; u_char rt_starttrack:8; /* * use SET_2BYTE_UINT(rt_length,newvalue) to set the following two-byte * integer value */ u_char rt_length_2b1:8, /* GET_2BYTE_UINT(rt_length) */ rt_length_2b2:8; /* will get this value */ u_char rt_control:8; #elif __LITTLE_ENDIAN__ u_char rt_op_code:8; /* C10OP_READTOC: x'43' */ u_char rt_reserved2:1, rt_msf:1, rt_reserved1:3, rt_lun:3; u_char rt_reserved3[4]; u_char rt_starttrack:8; /* * use SET_2BYTE_UINT(rt_length,newvalue) to set the following two-byte * integer value */ u_char rt_length_2b1:8, /* GET_2BYTE_UINT(rt_length) */ rt_length_2b2:8; /* will get this value */ u_char rt_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /* read toc reply header */ struct rtr_header { u_char rtr_datalen_2b1, /* GET_2BYTE_UINT(rtr_datalen) * */ rtr_datalen_2b2; /* will pick up this value */ u_char rtr_firsttrack; u_char rtr_lasttrack; }; /* read toc reply descriptor */ struct rtr_desc { #if __BIG_ENDIAN__ u_char rtrd_reserved1:8; u_char rtrd_reserved2:4, rtrd_control:4; u_char rtrd_track:8, rtrd_reserved3:8; union cd_addr_fmt rtrd_addr; /* 4 bytes */ #elif __LITTLE_ENDIAN__ u_char rtrd_reserved1:8; u_char rtrd_control:4, rtrd_reserved2:4; u_char rtrd_track:8, rtrd_reserved3:8; union cd_addr_fmt rtrd_addr; /* 4 bytes */ #else #error SCSI command / data structures are compiler sensitive #endif }; /* read toc reply with one descriptor, to read more than 1 descriptor blocks at a time, one must allocate sizeof(struct rtr_desc)*num_descriptrs+sizeof(struct rtr_header) bytes, and then traverse through the memory */ struct readtoc_43_reply { struct rtr_header h; struct rtr_desc d[101]; /* array of descriptor block's */ }; /************************************************************************** * declarations for playback-status and playback-control cmds * (both probably Sony-specific) */ #define C10OP_PLAYBACKSTATUS_C4 0xc4 /* 10-byte SCSI cmd */ #define C10OP_PLAYBACKCONTROL_C9 0xc9 /* 10-byte SCSI cmd */ struct playback_statuscontrol_cmd { #if __BIG_ENDIAN__ u_char pb_opcode:8; /* C10OP_PLAYBACKSTATUS: x'C4' or * C10OP_PLAYBACKCONTROL: x'C9' */ u_char pb_lun:3, pb_reserved1:5; u_char pb_reserved2[5]; /* * use SET_2BYTE_UINT(pb_length,newvalue) to set the following two-byte * integer value */ u_char pb_length_2b1:8, /* GET_2BYTE_UINT(pb_length) */ pb_length_2b2:8; /* will get this value */ u_char pb_control:8; #elif __LITTLE_ENDIAN__ u_char pb_opcode:8; /* C10OP_PLAYBACKSTATUS: x'C4' or * C10OP_PLAYBACKCONTROL: x'C9' */ u_char pb_reserved1:5, pb_lun:3; u_char pb_reserved2[5]; /* * use SET_2BYTE_UINT(pb_length,newvalue) to set the following two-byte * integer value */ u_char pb_length_2b1:8, /* GET_2BYTE_UINT(pb_length) */ pb_length_2b2:8; /* will get this value */ u_char pb_control:8; #else #error SCSI command / data structures are compiler sensitive #endif }; struct playback_c4c9_data { #if __BIG_ENDIAN__ u_char pbd_reserved1:8; u_char pbd_reserved2:7, pbd_lbamsf:1; u_char pbd_astatDataLength_2b1:8, /* GET_2BYTE_UINT(pbd_ast * atDataLength) */ pbd_astatDataLength_2b2:8; /* will get this value */ u_char pbd_audio_status:8; u_char pbd_reserved3:4, pbd_control:4; union cd_addr_fmt pbd_cd_addr; /* 4 bytes */ u_char pbd_reserved4:4, pbd_ch0_sel:4; u_char pbd_ch0_vol:8; u_char pbd_reserved5:4, pbd_ch1_sel:4; u_char pbd_ch1_vol:8; u_char pbd_reserved6:4, pbd_ch2_sel:4; u_char pbd_ch2_vol:8; u_char pbd_reserved7:4, pbd_ch3_sel:4; u_char pbd_ch3_vol:8; #elif __LITTLE_ENDIAN__ u_char pbd_reserved1:8; u_char pbd_lbamsf:1, pbd_reserved2:7; u_char pbd_astatDataLength_2b1:8, /* GET_2BYTE_UINT(pbd_ast * atDataLength) */ pbd_astatDataLength_2b2:8; /* will get this value */ u_char pbd_audio_status:8; u_char pbd_control:4, pbd_reserved3:4; union cd_addr_fmt pbd_cd_addr; /* 4 bytes */ u_char pbd_ch0_sel:4, pbd_reserved4:4; u_char pbd_ch0_vol:8; u_char pbd_ch1_sel:4, pbd_reserved5:4; u_char pbd_ch1_vol:8; u_char pbd_ch2_sel:4, pbd_reserved6:4; u_char pbd_ch2_vol:8; u_char pbd_ch3_sel:4, pbd_reserved7:4; u_char pbd_ch3_vol:8; #else #error SCSI command / data structures are compiler sensitive #endif }; /************************************************************************** * declarations for mode-sense and mode-select cmds */ struct mode_sense_select_cmd { #if __BIG_ENDIAN__ u_char msc_opcode; /* C6OP_MODESELECT: x'15' or * C6OP_MODESENSE: x'1A' */ u_char msc_lun:3, msc_pf:1, /* only used by MODESELECT */ msc_reserved1:3, msc_sp:1; /* only used by MODESELECT */ u_char msc_pcf:2, /* only used by MODESENSE */ msc_page:6; /* only used by MODESENSE */ u_char msc_reserved2:8; u_char msc_len; u_char msc_control; #elif __LITTLE_ENDIAN__ u_char msc_opcode; /* C6OP_MODESELECT: x'15' or * C6OP_MODESENSE: x'1A' */ u_char msc_sp:1, /* only used by MODESELECT */ msc_reserved1:3, msc_pf:1, /* only used by MODESELECT */ msc_lun:3; u_char msc_page:6, /* only used by MODESENSE */ msc_pcf:2; /* only used by MODESENSE */ u_char msc_reserved2:8; u_char msc_len; u_char msc_control; #else #error SCSI command / data structures are compiler sensitive #endif }; struct mode_sense_param_list_header { u_char plh_snslen; /* only used by MODESENSE */ u_char plh_medium; u_char plh_reserved; u_char plh_blkdesclen; /* either 0 or 8, usually 8 */ }; struct mode_sense_block_descriptor { u_char bd_density; u_char bd_nblk_3b1, /* use GET_3BYTE_UINT(bd_nblk) */ bd_nblk_3b2, /* to pick up this value */ bd_nblk_3b3; /* # of blocks, in 3 bytes */ u_char bd_reserved; u_char bd_blklen_3b1, /* use GET_3BYTE_UINT(bd_blklen) */ bd_blklen_3b2, /* to pick up this value */ bd_blklen_3b3; /* block-length, in 3 bytes */ }; struct mode_sense_pagecode_E { #if __BIG_ENDIAN__ u_char pce_reserved1:2, pce_pagecode:6; /* page code x'0E' */ u_char pce_parlen; /* length, always x'0E' */ u_char pce_reserved2:5, pce_immd:1, pce_reserved3:2; u_char pce_reserved4[5]; /* skip over a few bytes */ u_char pce_reserved5:4, pce_ch0_sel:4; u_char pce_ch0_vol; u_char pce_reserved6:4, pce_ch1_sel:4; u_char pce_ch1_vol; u_char pce_reserved7:4, pce_ch2_sel:4; u_char pce_ch2_vol; u_char pce_reserved8:4, pce_ch3_sel:4; u_char pce_ch3_vol; #elif __LITTLE_ENDIAN__ u_char pce_pagecode:6, /* page code x'0E' */ pce_reserved1:2; u_char pce_parlen; /* length, always x'0E' */ u_char pce_reserved3:2, pce_immd:1, pce_reserved2:5; u_char pce_reserved4[5]; /* skip over a few bytes */ u_char pce_ch0_sel:4, pce_reserved5:4; u_char pce_ch0_vol; u_char pce_ch1_sel:4, pce_reserved6:4; u_char pce_ch1_vol; u_char pce_ch2_sel:4, pce_reserved7:4; u_char pce_ch2_vol; u_char pce_ch3_sel:4, pce_reserved8:4; u_char pce_ch3_vol; #else #error SCSI command / data structures are compiler sensitive #endif }; struct mode_sense_select_reply { struct mode_sense_param_list_header msr_plh; struct mode_sense_block_descriptor msr_bd; /* * the following really should be declared as a union that included all the * structs used by any page-code */ union { struct mode_sense_pagecode_E u_msr_pcE; } u; }; struct mode_select_alt_reply { /* sans block descriptor */ struct mode_sense_param_list_header msar_plh; /* * the following really should be declared as a union that included all the * structs used by any page-code */ union { struct mode_sense_pagecode_E u_msar_pcE; } u; }; /************************************************************************** * prevent/allow medium removal command */ #define C6OP_PREVENT_REMOVAL_1E 0x1E /* 6-byte command */ struct prevent_removal_1e_cmd { #if __BIG_ENDIAN__ u_char par_op_code; /* C6OP_PREVENT_REMOVAL: x'1E' */ u_char par_lun:3, par_reserved1:5; u_char par_reserved2[2]; u_char par_reserved3:7, par_prevent:1; /* 0 = allow, 1 = prevent */ u_char par_control; #elif __LITTLE_ENDIAN__ u_char par_op_code; /* C6OP_PREVENT_REMOVAL: x'1E' */ u_char par_reserved1:5, par_lun:3; u_char par_reserved2[2]; u_char par_prevent:1, /* 0 = allow, 1 = prevent */ par_reserved3:7; u_char par_control; #else #error SCSI command / data structures are compiler sensitive #endif };
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.