xref: /illumos-gate/usr/src/cmd/cdrw/trackio.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _TRACKIO_H
28 #define	_TRACKIO_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 #include "bstream.h"
36 #include "misc_scsi.h"
37 
38 struct trackio_error {
39 	int	err_type;
40 /* File I/O errors */
41 	int	te_errno;
42 /* Transport Errors */
43 	uchar_t	status, key, asc, ascq;
44 };
45 
46 /*
47  * trackio error types
48  */
49 #define	TRACKIO_ERR_SYSTEM	1
50 #define	TRACKIO_ERR_TRANSPORT	2
51 #define	TRACKIO_ERR_USER_ABORT	3
52 
53 /*
54  * iob state
55  */
56 #define	IOBS_UNDER_FILE_IO	1
57 #define	IOBS_UNDER_DEVICE_IO	2
58 #define	IOBS_READY		3
59 #define	IOBS_EMPTY		4
60 
61 struct iobuf {
62 	uchar_t *iob_buf;
63 	uint32_t iob_total_size; /* total size of the buf */
64 	uint32_t iob_data_size;	 /* size of the data in buf */
65 	uint32_t iob_start_blk;	 /* starting block address on the device */
66 	uint16_t iob_nblks;	 /* number of data blocks in this buf */
67 	int iob_state;		 /* state of buf */
68 };
69 
70 /* Use small buffers. Some drives do not behave well with large buffers */
71 #define	NIOBS			8
72 #define	NBLKS_PER_BUF		24	/* < 64K in all cases */
73 #define	DATA_TRACK_BLKSIZE	2048
74 #define	AUDIO_TRACK_BLKSIZE	2352
75 
76 int write_track(cd_device *dev, struct track_info *ti, bstreamhandle h,
77 		int (*cb)(int64_t, int64_t), int64_t arg, struct
78 		trackio_error *te);
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif /* _TRACKIO_H */
85