Annotation of Examples/UNIX/SCSI_CD/cd_commands.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * cd_commands.h: header file for cd_commands.c
        !             3:  *
        !             4:  * History
        !             5:  * -------
        !             6:  * Mon Sep 16 15:57:35 PDT 1991 James C. Lee at NeXT
        !             7:  *  Created
        !             8:  */
        !             9: 
        !            10: #ifndef CD_COMMANDS
        !            11: #define CD_COMMANDS
        !            12: 
        !            13: #import <sys/types.h>
        !            14: #import <libc.h>
        !            15: #import <bsd/dev/scsireg.h>
        !            16: #import <sys/time.h>
        !            17: 
        !            18: /* start/stop command (C6OP_STARTSTOP = 1Bh) */
        !            19: struct start_stop_cmd {
        !            20:        u_char  ssc_opcode;
        !            21:        u_char  ssc_lun:3,
        !            22:                        ssc_reserved:4,
        !            23:                        ssc_imm:1;
        !            24:        u_int   ssc_reserved2:22,
        !            25:                        ssc_loej:1,
        !            26:                        ssc_start:1,
        !            27:                        ssc_control:8;
        !            28: };
        !            29: 
        !            30: /* read toc reply header */
        !            31: struct rtr_header {
        !            32:        u_int   rtr_datalength:16,
        !            33:                        rtr_firsttrack:8,
        !            34:                        rtr_lasttrack:8;
        !            35: };
        !            36: 
        !            37: /* read toc reply descriptor */
        !            38: struct rtr10_desc {
        !            39:        u_int   t10d_reserved:12,
        !            40:                        t10d_control:4,
        !            41:                        t10d_track:8,
        !            42:                        t10d_reserved2:8;
        !            43:        u_int   t10d_hour:8,
        !            44:                        t10d_min:8,
        !            45:                        t10d_sec:8,
        !            46:                        t10d_frame:8;
        !            47: };
        !            48: 
        !            49: /* read toc reply with one descriptor, to read more than 1 descriptor
        !            50:    blocks at a time, one must allocate
        !            51:    sizeof(struct rtr10_desc)*num_descriptrs+sizeof(struct_rtr_header) bytes,
        !            52:    and then traverse through the memory */
        !            53: 
        !            54: struct toc10_reply {
        !            55:        struct rtr_header       h;
        !            56:        struct rtr10_desc       d;      /* one descriptor block */
        !            57: };
        !            58: 
        !            59: /* an entry to toc info */
        !            60: struct toc_info {
        !            61:        u_char  control;        /* control bits */
        !            62:        u_int   hour:8,         /* msf address */
        !            63:                        min:8,
        !            64:                        sec:8,
        !            65:                        frame;          /* not too sure what this byte is */
        !            66: };
        !            67: 
        !            68: /* control bits */
        !            69: #define PRE_EMPHASIS   0x1     /* pre-emphasis or not */
        !            70: #define DIGITAL_COPY   0x2     /* digital copy permitted (1) or not (0) */
        !            71: #define DATA_TRACK             0x4     /* data track (1) or autio track (0) */
        !            72: #define FOUR_CHANNEL   0x8     /* four channel (1) or two channel (0) */
        !            73: 
        !            74: /* entire table of contents */
        !            75: struct toc_all {
        !            76:        u_short                 firsttrack:8,
        !            77:                                        lasttrack:8;
        !            78:        int                             naudio, /* number of audio tracks */
        !            79:                                        ndata,  /* number of data tracks */
        !            80:                                        lastDataBlock;  /* very last data block */
        !            81:        struct toc_info info[101];      /* 0-99 + transition area (100) */
        !            82: };
        !            83: 
        !            84: #define C10OP_READTOC 0x43     /* read toc10 command */
        !            85: /* read toc10 command (C10OP_READTOC = 43h) */
        !            86: struct readtoc10_cmd {
        !            87:        u_char  rt10_op_code;
        !            88:        u_char  rt10_lun:3,
        !            89:                        rt10_reserved:3,
        !            90:                        rt10_msf:1,
        !            91:                        rt10_reserved2:1;
        !            92:        u_int   rt10_reserved3;
        !            93:        u_int   rt10_starttrack:8,
        !            94:                        rt10_length:16,
        !            95:                        rt10_control:8;
        !            96: };
        !            97: 
        !            98: #define C6OP_PLAYAUDIO 0xc8
        !            99: /* play audio command (C6OP_PLAYAUDIO = c8h) */
        !           100: struct playaudio_cmd {
        !           101:        u_char  pa_op_code;
        !           102:        u_char  pa_lun:3,
        !           103:                        pa_reserved:5;
        !           104:        u_int   pa_lba;         /* lba to start playing */
        !           105:        u_int   pa_reserved2:8,
        !           106:                        pa_length:16,
        !           107:                        pa_control:8;
        !           108: };
        !           109: 
        !           110: #define C10OP_PAUSE 0xc5
        !           111: /* pause audio commnad (C10OP_PAUSE = c5h) */
        !           112: struct pause_cmd {
        !           113:        u_char  p_op_code;
        !           114:        u_int   p_lun:3,
        !           115:                        p_pause:1,
        !           116:                        p_reserved:28;
        !           117:        u_int   p_reserved2;
        !           118:        u_char  p_control;
        !           119: };
        !           120: 
        !           121: /* msf data format */
        !           122: struct msf {
        !           123:        u_int   hour:8,
        !           124:                        min:8,
        !           125:                        sec:8,
        !           126:                        frame:8;
        !           127: };
        !           128: 
        !           129: #define C10OP_PLAYAUDIO_MSF 0x47
        !           130: /* play audio msf command (C6OP_PLAYAUDIO = 47h) */
        !           131: struct playaudio_msf_cmd {
        !           132:        u_char  pam_op_code;
        !           133:        u_char  pam_lun:3,
        !           134:                        pam_reserved:5;
        !           135:        u_int   pam_reserved2:8,
        !           136:                        pam_start_min:8,
        !           137:                        pam_start_sec:8,
        !           138:                        pam_start_frame:8;
        !           139:        u_int   pam_end_min:8,
        !           140:                        pam_end_sec:8,
        !           141:                        pam_end_frame:8,
        !           142:                        pam_control:8;
        !           143: };
        !           144: 
        !           145: /**********************************************************
        !           146:  * sub channel
        !           147:  **********************************************************/
        !           148: #define C10OP_READSUBHCANNEL 0x42
        !           149: /* read sub-channel (C10OP_READSUBHCANNEL = 42h) */
        !           150: struct readsc_cmd {
        !           151:        u_int   rsc_op_code:8,
        !           152:                        rsc_lun:3,
        !           153:                        rsc_reserved:3,
        !           154:                        rsc_msf:1,
        !           155:                        rsc_reserved2:2,
        !           156:                        rsc_subq:1,                     /* sub-channel data or not (not=just header) */
        !           157:                        rsc_reserved3:6,
        !           158:                        rsc_dformat:8;
        !           159:        u_short rsc_reserved4;
        !           160:        u_int   rsc_track:8,
        !           161:                        rsc_length:16,
        !           162:                        rsc_control:8;
        !           163: };
        !           164: 
        !           165: /* sub-channel data header */
        !           166: struct sc_header {
        !           167:        u_int   sch_reserved:8,
        !           168:                        sch_astatus:8,  /* audio status */
        !           169:                        sch_length:16;  /* sub-channel data length */
        !           170: };
        !           171: 
        !           172: /* sub-channel data format page 1: CD-ROM current position data block */
        !           173: struct sc_cur_pos {
        !           174:        u_int   sc1_data_code:8,
        !           175:                        sc1_reserved:4,
        !           176:                        sc1_control:4,
        !           177:                        sc1_track:8,
        !           178:                        sc1_index:8;
        !           179:        u_int   sc1_abs_addr;
        !           180:        u_int   sc1_rel_addr;
        !           181: };
        !           182: 
        !           183: /* sub-channel data format page 2: Media Catalog Number Data Format */
        !           184: struct sc_med_cat {
        !           185:        u_int   sc2_data_code:8,
        !           186:                        sc2_reserved:24;
        !           187:        u_char  sc2_mcval:1,
        !           188:                        sc2_reserved2:7;
        !           189:        u_char  sc2_med_cat[15];
        !           190: };
        !           191: 
        !           192: /* sub-channel data format page 3: Track International Standard Recording Data
        !           193:        Format */
        !           194: struct sc_isrc {
        !           195:        u_int   sc3_data_code:8,
        !           196:                        sc3_reserved:8,
        !           197:                        sc3_track:8,
        !           198:                        sc3_reserved2:8;
        !           199:        u_char  sc3_tcval:1,
        !           200:                        sc3_reserved3:7;
        !           201:        u_char  sc3_isrc[15];
        !           202: };
        !           203: 
        !           204: /* sub-channel reply */
        !           205: struct sc_reply {
        !           206:        struct sc_header        scr_header;
        !           207:        union {
        !           208:                struct sc_cur_pos       u_scr_cur_pos;
        !           209:                struct sc_med_cat       u_scr_med_cat;
        !           210:                struct sc_isrc          u_scr_isrc;
        !           211:        }u;
        !           212: };
        !           213: 
        !           214: /**********************************************************
        !           215:  * playback status & playback control
        !           216:  **********************************************************/
        !           217: #define C10OP_PLAYBACKCONTROL 0xc9
        !           218: #define C10OP_PLAYBACKSTATUS 0xc4
        !           219: struct playback_cmd {
        !           220:        u_char          pb_opcode;
        !           221:        u_int           pb_lun:3,
        !           222:                                pb_reserved:29;
        !           223:        u_int           pb_reserved2:16,
        !           224:                                pb_length:16;
        !           225:        u_char          pb_control;
        !           226: };
        !           227: 
        !           228: struct playback_data {
        !           229:        u_int           pbd_reserved;
        !           230:        u_int           pbd_reserved2;
        !           231:        u_short         pbd_reserved3;
        !           232:        u_int           pbd_reserved4:4,
        !           233:                                pbd_ch0_sel:4,
        !           234:                                pbd_ch0_vol:8,
        !           235:                                pbd_reserved5:4,
        !           236:                                pbd_ch1_sel:4,
        !           237:                                pbd_ch1_vol:8;
        !           238:        u_int           pbd_reserved6:4,
        !           239:                                pbd_ch2_sel:4,
        !           240:                                pbd_ch2_vol:8,
        !           241:                                pbd_reserved7:4,
        !           242:                                pbd_ch3_sel:4,
        !           243:                                pbd_ch3_vol:8;
        !           244: };
        !           245: 
        !           246: int    do_eject(int fd, struct timeval *tvp, struct esense_reply *erp);
        !           247: int    do_spinup(int fd, struct timeval *tvp, struct esense_reply *erp);
        !           248: int do_readtoc(int fd, int track, struct toc10_reply *tocr,
        !           249:        struct esense_reply *erp);
        !           250: int do_readtoc_all(int fd, struct toc_all *toc_all, struct esense_reply *erp);
        !           251: int do_playaudio(int fd, int lba, int length, struct esense_reply *erp);
        !           252: int do_pauseaudio(int fd, int pause, struct esense_reply *erp);
        !           253: int do_playaudio_msf(int fd, struct msf startmsf, struct msf endmsf,
        !           254:        struct esense_reply *erp);
        !           255: int    do_readsubchannel(int fd, int msf, int subq, int page, int track,
        !           256:        struct sc_reply *scrp, struct esense_reply *erp);
        !           257: int    do_playbackstatus(int fd, struct playback_data *pbdatap,
        !           258:        struct esense_reply *erp);
        !           259: int    do_playbackcontrol(int fd, struct playback_data *pbdatap,
        !           260:        struct esense_reply *erp);
        !           261: 
        !           262: 
        !           263: void printf_sc(int page, struct sc_reply *scrp);
        !           264: void printf_pb(struct playback_data *pbdatap);
        !           265: 
        !           266: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.