xref: /titanic_52/usr/src/cmd/cdrw/misc_scsi.h (revision 84ab085a13f931bc78e7415e7ce921dbaa14fcb3)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_MISC_SCSI_H
28 #define	_MISC_SCSI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include "device.h"
37 
38 struct track_info {
39 	uint32_t ti_flags;		/* flags, see below */
40 	int ti_track_no;		/* Track number */
41 	int ti_session_no;		/* session no. 0 if cannot find that */
42 	uchar_t ti_track_mode;		/* track ctrl nibble, see READ TOC */
43 	uchar_t ti_data_mode;		/* Mode 0,1,2 or FF */
44 	uint32_t ti_start_address;	/* Start LBA */
45 	uint32_t ti_track_size;		/* Size in blocks */
46 	uint32_t ti_packet_size;	/* If a packet written track */
47 	uint32_t ti_free_blocks;	/* For an incomplete track */
48 	uint32_t ti_lra;		/* LBA of Last written user datablock */
49 	uint32_t ti_nwa;		/* Next writable address */
50 };
51 
52 /*
53  * track_info_flags
54  */
55 #define	TI_FIXED_PACKET		1
56 #define	TI_PACKET_MODE		2
57 #define	TI_BLANK_TRACK		4
58 #define	TI_RESERVED_TRACK	8
59 #define	TI_COPY			0x10
60 #define	TI_DAMAGED_TRACK	0x20
61 #define	TI_NWA_VALID		0x100
62 #define	TI_LRA_VALID		0x200
63 #define	TI_SESSION_NO_VALID	0x1000
64 #define	TI_FREE_BLOCKS_VALID	0x2000
65 
66 /*
67  * Track mode nibble
68  */
69 #define	TRACK_MODE_DATA		0x06
70 #define	TRACK_MODE_AUDIO	0x02
71 
72 /* 74 minutes, each second is 75 blocks */
73 #define	MAX_CD_BLKS		(74*60*75)
74 #define	MAX_DVD_BLKS		2295100
75 
76 /*
77  * Some devices just multiply speed by 176. But more accurate ones
78  * multiply speed by 176.4.
79  */
80 #define	XFER_RATE_TO_SPEED(r)	((r) % 176 ? ((((r)*10)+5)/1764) : (r) / 176)
81 #define	SPEED_TO_XFER_RATE(s)	((((s)*1764)+5)/10)
82 
83 #define	FINALIZE_TIMEOUT		(6 * 12)	/* Six minutes */
84 
85 uint32_t read_scsi32(void *addr);
86 uint16_t read_scsi16(void *addr);
87 void load_scsi32(void *addr, uint32_t val);
88 void load_scsi16(void *addr, uint16_t val);
89 
90 int get_mode_page(int fd, int page_no, int pc, int buf_len, uchar_t *buffer);
91 int set_mode_page(int fd, uchar_t *buffer);
92 int build_track_info(cd_device *dev, int trackno, struct track_info *t_info);
93 uchar_t get_data_mode(int fd, uint32_t lba);
94 int prepare_for_write(cd_device *dev, int track_mode, int test_write,
95     int keep_disc_open);
96 int finalize(cd_device *dev);
97 int get_last_possible_lba(cd_device *dev);
98 int read_audio_through_read_cd(cd_device *dev, uint_t start_lba, uint_t nblks,
99     uchar_t *buf);
100 int eject_media(cd_device *dev);
101 int cd_speed_ctrl(cd_device *dev, int cmd, int speed);
102 int rt_streaming_ctrl(cd_device *dev, int cmd, int speed);
103 
104 void tao_init(int mode);
105 void tao_fini(void);
106 void write_init(int mode);
107 void write_fini(void);
108 
109 #ifdef	__cplusplus
110 }
111 #endif
112 
113 #endif /* _MISC_SCSI_H */
114