xref: /titanic_51/usr/src/cmd/cdrw/mmc.h (revision 3503b75edca6f6a52e9244b5d34dd593d08c4f76)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5b36bd5c0Szk194757  * Common Development and Distribution License (the "License").
6b36bd5c0Szk194757  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*3503b75eSec158148  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_MMC_H
277c478bd9Sstevel@tonic-gate #define	_MMC_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
3598584592Sarutz /* bytelengths for some SCSI data structures */
367c478bd9Sstevel@tonic-gate #define	SENSE_DATA_SIZE		16
377c478bd9Sstevel@tonic-gate #define	TRACK_INFO_SIZE		36
387c478bd9Sstevel@tonic-gate #define	DISC_INFO_BLOCK_SIZE	32
397c478bd9Sstevel@tonic-gate #define	INQUIRY_DATA_LENGTH	96
407c478bd9Sstevel@tonic-gate #define	GET_PERF_DATA_LEN	24
417c478bd9Sstevel@tonic-gate #define	SET_STREAM_DATA_LEN	28
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	DEFAULT_SCSI_TIMEOUT    60
447c478bd9Sstevel@tonic-gate 
45c9be8e69Sec158148 #define	MMC_FTR_HDR_LEN		8	/* byte len of Feature Header */
46c9be8e69Sec158148 /*
47c9be8e69Sec158148  * byte length of the static part of a Feature Descriptor
48c9be8e69Sec158148  */
49c9be8e69Sec158148 #define	MMC_FTR_DSCRPTR_BASE_LEN	4
50c9be8e69Sec158148 #define	MMC_PRFL_DSCRPTR_LEN	4	/* byte len of Profile Descriptor */
51c9be8e69Sec158148 /*
52c9be8e69Sec158148  * MMC Features; can be added to over time
53c9be8e69Sec158148  */
54c9be8e69Sec158148 #define	MMC_FTR_PRFL_LIST	0x0000	/* Profile List Feature */
55c9be8e69Sec158148 #define	MMC_FTR_CORE		0x0001	/* Core Feature */
56c9be8e69Sec158148 #define	MMC_FTR_MORPHING	0x0002	/* Morphing Feature */
57c9be8e69Sec158148 #define	MMC_FTR_REM_MED		0x0003	/* Removable Medium Feature */
58c9be8e69Sec158148 #define	MMC_FTR_WR_PROTECT	0x0004	/* Write Protect Feature */
59c9be8e69Sec158148 #define	MMC_FTR_RAND_READ	0x0010	/* Random Readable Feature */
60c9be8e69Sec158148 #define	MMC_FTR_MULTI_READ	0x001D	/* Multi-Read Feature */
61c9be8e69Sec158148 #define	MMC_FTR_CD_READ		0x001E	/* CD Read Feature */
62c9be8e69Sec158148 #define	MMC_FTR_DVD_READ	0x001F	/* DVD Read Feature */
63c9be8e69Sec158148 #define	MMC_FTR_RAND_WR		0x0020	/* Random Writable Feature */
64c9be8e69Sec158148 #define	MMC_FTR_INC_STR_WR	0x0021	/* Incremental Streaming Writable */
65c9be8e69Sec158148 #define	MMC_FTR_SCTR_ERSBL	0x0022	/* Sector Erasable Feature */
66c9be8e69Sec158148 #define	MMC_FTR_FORMATTABLE	0x0023	/* Formattable Feature */
67c9be8e69Sec158148 #define	MMC_FTR_DFCT_MNGMNT	0x0024	/* Hardware Defect Management Feature */
68c9be8e69Sec158148 #define	MMC_FTR_RT_STREAM	0x0107	/* Real Time Streaming Feature */
69c9be8e69Sec158148 
70*3503b75eSec158148 /* Constants for READ TOC/PMA/ATIP command */
71*3503b75eSec158148 #define	FORMAT_FORMATTED_TOC	0
72*3503b75eSec158148 #define	FORMAT_MULTISESS_INFO	1
73*3503b75eSec158148 #define	FORMAT_RAW_TOC		2
74*3503b75eSec158148 
75*3503b75eSec158148 /* size in bytes of raw TOC Data Length field */
76*3503b75eSec158148 #define	RTOC_DATA_LEN_SZ	2
77*3503b75eSec158148 
78*3503b75eSec158148 /* Point field values for Raw TOC Track Descriptor */
79*3503b75eSec158148 #define	POINT_SESS_FIRST_TRK	0xA0	/* 1st track in session */
80*3503b75eSec158148 #define	POINT_SESS_LAST_TRK	0xA1	/* Last track in session */
81*3503b75eSec158148 #define	POINT_LEADOUT_ADDR	0xA2	/* Starting leadout address */
82*3503b75eSec158148 
83*3503b75eSec158148 /* Q Sub-channel constants */
84*3503b75eSec158148 #define	Q_MODE_1		1	/* Mode-1 Q */
85*3503b75eSec158148 #define	Q_MODE_2		2	/* Mode-2 Q */
86*3503b75eSec158148 
87*3503b75eSec158148 /* Convert Minute,Second,Frame address into Logical Block Address */
88*3503b75eSec158148 #define	MSF2LBA(m, s, f)	(((m) * 60 + (s)) * 75 + (f) - 150)
89*3503b75eSec158148 
90*3503b75eSec158148 /*
91*3503b75eSec158148  * MMC Response Data structures.  Use the read_scsi[16,32] and load_scsi[16,32]
92*3503b75eSec158148  * routines when reading/writing fields > 1 byte in size.
93*3503b75eSec158148  */
94*3503b75eSec158148 /*
95*3503b75eSec158148  * Structures for the Raw TOC Response Format of the READ TOC/PMA/ATIP
96*3503b75eSec158148  * command.
97*3503b75eSec158148  */
98*3503b75eSec158148 typedef struct rtoc_hdr {	/* Raw TOC response format Header */
99*3503b75eSec158148 	uchar_t rh_data_len1;
100*3503b75eSec158148 	uchar_t rh_data_len0;
101*3503b75eSec158148 	uchar_t rh_first_sess_num;
102*3503b75eSec158148 	uchar_t rh_last_sess_num;
103*3503b75eSec158148 } rtoc_hdr_t;
104*3503b75eSec158148 
105*3503b75eSec158148 typedef struct rtoc_td {	/* Raw TOC response format Track Descriptor */
106*3503b75eSec158148 	uchar_t rt_session_num;
107*3503b75eSec158148 #if defined(_BIT_FIELDS_LTOH)
108*3503b75eSec158148 	uchar_t	rt_control	: 4;
109*3503b75eSec158148 	uchar_t rt_adr		: 4;
110*3503b75eSec158148 #elif defined(_BIT_FIELDS_HTOL)
111*3503b75eSec158148 	uchar_t rt_adr		: 4;
112*3503b75eSec158148 	uchar_t rt_control	: 4;
113*3503b75eSec158148 #else
114*3503b75eSec158148 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
115*3503b75eSec158148 #endif	/* _BIT_FIELDS_LTOH */
116*3503b75eSec158148 
117*3503b75eSec158148 	uchar_t rt_tno;
118*3503b75eSec158148 	uchar_t rt_point;
119*3503b75eSec158148 	uchar_t rt_min;
120*3503b75eSec158148 	uchar_t rt_sec;
121*3503b75eSec158148 	uchar_t rt_frame;
122*3503b75eSec158148 	uchar_t rt_zero;
123*3503b75eSec158148 	uchar_t	rt_pmin;
124*3503b75eSec158148 	uchar_t rt_psec;
125*3503b75eSec158148 	uchar_t rt_pframe;
126*3503b75eSec158148 } rtoc_td_t;
127*3503b75eSec158148 
1287c478bd9Sstevel@tonic-gate int test_unit_ready(int fd);
1297c478bd9Sstevel@tonic-gate int inquiry(int fd, uchar_t *inq);
1307c478bd9Sstevel@tonic-gate int read_capacity(int fd, uchar_t *capbuf);
1317c478bd9Sstevel@tonic-gate int read_track_info(int fd, int trackno, uchar_t *ti);
1327c478bd9Sstevel@tonic-gate int mode_sense(int fd, uchar_t pc, int dbd, int page_len, uchar_t *buffer);
1337c478bd9Sstevel@tonic-gate int mode_select(int fd, int page_len, uchar_t *buffer);
1347c478bd9Sstevel@tonic-gate int read_toc(int fd, int format, int trackno, int buflen, uchar_t *buf);
1357c478bd9Sstevel@tonic-gate int read_disc_info(int fd, uchar_t *di);
1367c478bd9Sstevel@tonic-gate int get_configuration(int fd, uint16_t feature, int bufsize, uchar_t *buf);
1377c478bd9Sstevel@tonic-gate int read10(int fd, uint32_t start_blk, uint16_t nblk, uchar_t *buf,
1387c478bd9Sstevel@tonic-gate     uint32_t bufsize);
1397c478bd9Sstevel@tonic-gate int write10(int fd, uint32_t start_blk, uint16_t nblk, uchar_t *buf,
1407c478bd9Sstevel@tonic-gate     uint32_t bufsize);
1417c478bd9Sstevel@tonic-gate int close_track(int fd, int trackno, int close_session, int immediate);
1427c478bd9Sstevel@tonic-gate int blank_disc(int fd, int type, int immediate);
1437c478bd9Sstevel@tonic-gate int read_cd(int fd, uint32_t start_blk, uint16_t nblk, uchar_t sector_type,
1447c478bd9Sstevel@tonic-gate     uchar_t *buf, uint32_t bufsize);
1457c478bd9Sstevel@tonic-gate int load_unload(int fd, int load);
1467c478bd9Sstevel@tonic-gate int prevent_allow_mr(int fd, int op);
1477c478bd9Sstevel@tonic-gate int read_header(int fd, uint32_t lba, uchar_t *buf);
1487c478bd9Sstevel@tonic-gate int set_cd_speed(int fd, uint16_t read_speed, uint16_t write_speed);
1497c478bd9Sstevel@tonic-gate int get_performance(int fd, int get_write_performance, uchar_t *perf);
1507c478bd9Sstevel@tonic-gate int set_streaming(int fd, uchar_t *buf);
1517c478bd9Sstevel@tonic-gate int rezero_unit(int fd);
1527c478bd9Sstevel@tonic-gate int start_stop(int fd, int start);
1537c478bd9Sstevel@tonic-gate int flush_cache(int fd);
1547c478bd9Sstevel@tonic-gate int set_reservation(int fd, ulong_t size);
1557c478bd9Sstevel@tonic-gate int format_media(int fd);
1567c478bd9Sstevel@tonic-gate uint32_t read_format_capacity(int fd, uint_t *bsize);
157b36bd5c0Szk194757 void reset_dev(int fd);
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate int uscsi_error;		/* used for debugging failed uscsi */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	REZERO_UNIT_CMD 	0x01
1627c478bd9Sstevel@tonic-gate #define	FORMAT_UNIT_CMD		0x04
1637c478bd9Sstevel@tonic-gate #define	INQUIRY_CMD		0x12
1647c478bd9Sstevel@tonic-gate #define	MODE_SELECT_6_CMD	0x15
1657c478bd9Sstevel@tonic-gate #define	MODE_SENSE_6_CMD	0x1A
1667c478bd9Sstevel@tonic-gate #define	START_STOP_CMD		0x1B
1677c478bd9Sstevel@tonic-gate #define	PREVENT_ALLOW_CMD	0x1E
1687c478bd9Sstevel@tonic-gate #define	READ_FORMAT_CAP_CMD	0x23
1697c478bd9Sstevel@tonic-gate #define	READ_CAP_CMD		0x25
1707c478bd9Sstevel@tonic-gate #define	READ_10_CMD		0x28
1717c478bd9Sstevel@tonic-gate #define	WRITE_10_CMD		0x2A
1727c478bd9Sstevel@tonic-gate #define	SYNC_CACHE_CMD		0x35
1737c478bd9Sstevel@tonic-gate #define	READ_TOC_CMD		0x43
1747c478bd9Sstevel@tonic-gate #define	MODE_SELECT_10_CMD	0x55
1757c478bd9Sstevel@tonic-gate #define	MODE_SENSE_10_CMD	0x5A
1767c478bd9Sstevel@tonic-gate #define	READ_HDR_CMD		0x44
1777c478bd9Sstevel@tonic-gate #define	GET_CONFIG_CMD		0x46
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #define	READ_INFO_CMD		0x51
1807c478bd9Sstevel@tonic-gate #define	READ_TRACK_CMD		0x52
1817c478bd9Sstevel@tonic-gate #define	SET_RESERVATION_CMD	0x53
1827c478bd9Sstevel@tonic-gate #define	CLOSE_TRACK_CMD		0x5B
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #define	BLANK_CMD		0xA1
1857c478bd9Sstevel@tonic-gate #define	GET_PERFORMANCE_CMD	0xAC
1867c478bd9Sstevel@tonic-gate #define	READ_DVD_STRUCTURE	0xAD
1877c478bd9Sstevel@tonic-gate #define	READ_CD_CMD		0xBE
1887c478bd9Sstevel@tonic-gate #define	SET_CD_SPEED		0xBB
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #define	STREAM_CMD		0xB6
1917c478bd9Sstevel@tonic-gate #define	READ_AUDIO_CMD		0xD8
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate #endif
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate #endif /* _MMC_H */
198