xref: /titanic_50/usr/src/cmd/cdrw/misc_scsi.h (revision 4d218355460e094792d6bcc161b586d7389d0d83)
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
57d7a4f21Szk194757  * Common Development and Distribution License (the "License").
67d7a4f21Szk194757  * 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*4d218355Szk194757  * 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	_MISC_SCSI_H
277c478bd9Sstevel@tonic-gate #define	_MISC_SCSI_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 
357c478bd9Sstevel@tonic-gate #include "device.h"
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate struct track_info {
387c478bd9Sstevel@tonic-gate 	uint32_t ti_flags;		/* flags, see below */
397c478bd9Sstevel@tonic-gate 	int ti_track_no;		/* Track number */
407c478bd9Sstevel@tonic-gate 	int ti_session_no;		/* session no. 0 if cannot find that */
417c478bd9Sstevel@tonic-gate 	uchar_t ti_track_mode;		/* track ctrl nibble, see READ TOC */
427c478bd9Sstevel@tonic-gate 	uchar_t ti_data_mode;		/* Mode 0,1,2 or FF */
437c478bd9Sstevel@tonic-gate 	uint32_t ti_start_address;	/* Start LBA */
447c478bd9Sstevel@tonic-gate 	uint32_t ti_track_size;		/* Size in blocks */
457c478bd9Sstevel@tonic-gate 	uint32_t ti_packet_size;	/* If a packet written track */
467c478bd9Sstevel@tonic-gate 	uint32_t ti_free_blocks;	/* For an incomplete track */
477c478bd9Sstevel@tonic-gate 	uint32_t ti_lra;		/* LBA of Last written user datablock */
487c478bd9Sstevel@tonic-gate 	uint32_t ti_nwa;		/* Next writable address */
497c478bd9Sstevel@tonic-gate };
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * track_info_flags
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate #define	TI_FIXED_PACKET		1
557c478bd9Sstevel@tonic-gate #define	TI_PACKET_MODE		2
567c478bd9Sstevel@tonic-gate #define	TI_BLANK_TRACK		4
577c478bd9Sstevel@tonic-gate #define	TI_RESERVED_TRACK	8
587c478bd9Sstevel@tonic-gate #define	TI_COPY			0x10
597c478bd9Sstevel@tonic-gate #define	TI_DAMAGED_TRACK	0x20
607c478bd9Sstevel@tonic-gate #define	TI_NWA_VALID		0x100
617c478bd9Sstevel@tonic-gate #define	TI_LRA_VALID		0x200
627c478bd9Sstevel@tonic-gate #define	TI_SESSION_NO_VALID	0x1000
637c478bd9Sstevel@tonic-gate #define	TI_FREE_BLOCKS_VALID	0x2000
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Track mode nibble
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	TRACK_MODE_DATA		0x06
697c478bd9Sstevel@tonic-gate #define	TRACK_MODE_AUDIO	0x02
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /* 74 minutes, each second is 75 blocks */
727c478bd9Sstevel@tonic-gate #define	MAX_CD_BLKS		(74*60*75)
737c478bd9Sstevel@tonic-gate #define	MAX_DVD_BLKS		2295100
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /*
7698584592Sarutz  * Macros to translate between a bandwidth ("RATE") and a Speed ("X")
7798584592Sarutz  * for CDs.  Eg, "1X == 176,400 bytes/second".
7898584592Sarutz  *
797c478bd9Sstevel@tonic-gate  * Some devices just multiply speed by 176. But more accurate ones
807c478bd9Sstevel@tonic-gate  * multiply speed by 176.4.
817c478bd9Sstevel@tonic-gate  */
827d7a4f21Szk194757 #define	CD_RATE_TO_X(r) ((r) % 176 ? ((uint_t)(((double)(r)*10)/1764 + 0.5)) :\
837d7a4f21Szk194757 		(r) / 176)
8498584592Sarutz #define	CD_X_TO_RATE(s)	((((s)*1764)+5)/10)
8598584592Sarutz 
8698584592Sarutz /*
8798584592Sarutz  * Macros to translate between a bandwidth ("RATE") and a Speed ("X")
8898584592Sarutz  * for DVDs. Eg, "1X == 1,385,000 bytes/second".
8998584592Sarutz  */
9098584592Sarutz #define	DVD_RATE_TO_X(r)	(((ulong_t)(r)*1000)/1385000)
9198584592Sarutz #define	DVD_X_TO_RATE(s)	(((s)*1385000)/1000)
9298584592Sarutz 
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	FINALIZE_TIMEOUT		(6 * 12)	/* Six minutes */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate uint32_t read_scsi32(void *addr);
977c478bd9Sstevel@tonic-gate uint16_t read_scsi16(void *addr);
987c478bd9Sstevel@tonic-gate void load_scsi32(void *addr, uint32_t val);
997c478bd9Sstevel@tonic-gate void load_scsi16(void *addr, uint16_t val);
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate int get_mode_page(int fd, int page_no, int pc, int buf_len, uchar_t *buffer);
1027c478bd9Sstevel@tonic-gate int set_mode_page(int fd, uchar_t *buffer);
1037c478bd9Sstevel@tonic-gate int build_track_info(cd_device *dev, int trackno, struct track_info *t_info);
1047c478bd9Sstevel@tonic-gate uchar_t get_data_mode(int fd, uint32_t lba);
1057c478bd9Sstevel@tonic-gate int prepare_for_write(cd_device *dev, int track_mode, int test_write,
1067c478bd9Sstevel@tonic-gate     int keep_disc_open);
1077c478bd9Sstevel@tonic-gate int finalize(cd_device *dev);
108*4d218355Szk194757 uint32_t get_last_possible_lba(cd_device *dev);
1097c478bd9Sstevel@tonic-gate int read_audio_through_read_cd(cd_device *dev, uint_t start_lba, uint_t nblks,
1107c478bd9Sstevel@tonic-gate     uchar_t *buf);
1117c478bd9Sstevel@tonic-gate int eject_media(cd_device *dev);
1127c478bd9Sstevel@tonic-gate int cd_speed_ctrl(cd_device *dev, int cmd, int speed);
1137c478bd9Sstevel@tonic-gate int rt_streaming_ctrl(cd_device *dev, int cmd, int speed);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate void tao_init(int mode);
1167c478bd9Sstevel@tonic-gate void tao_fini(void);
1177c478bd9Sstevel@tonic-gate void write_init(int mode);
1187c478bd9Sstevel@tonic-gate void write_fini(void);
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate #endif
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #endif /* _MISC_SCSI_H */
125