xref: /original-bsd/sys/dev/scsi/tape.h (revision b1dc0eed)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratories.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)tape.h	5.2 (Berkeley) 07/23/92
17  *
18  * from: $Header: tape.h,v 1.2 92/05/15 11:24:06 torek Exp $ (LBL)
19  */
20 
21 /*
22  * SCSI definitions for Sequential Access Devices (tapes).
23  */
24 #define	CMD_REWIND		0x01	/* rewind */
25 #define	CMD_READ_BLOCK_LIMITS	0x05	/* read block limits */
26 #define	CMD_READ		0x08	/* read */
27 #define	CMD_WRITE		0x0a	/* write */
28 #define	CMD_TRACK_SELECT	0x0b	/* track select */
29 #define	CMD_READ_REVERSE	0x0f	/* read reverse */
30 #define	CMD_WRITE_FILEMARK	0x10	/* write file marks */
31 #define	CMD_SPACE		0x11	/* space */
32 #define	CMD_VERIFY		0x13	/* verify */
33 #define	CMD_RBD			0x14	/* recover buffered data */
34 #define	CMD_MODE_SELECT		0x15	/* mode select */
35 #define	CMD_RESERVE_UNIT	0x16	/* reserve unit */
36 #define	CMD_RELEASE_UNIT	0x17	/* release unit */
37 /*	CMD_COPY		0x18	   copy (common to all scsi devs) */
38 #define	CMD_ERASE		0x19	/* erase */
39 #define	CMD_MODE_SENSE		0x1a	/* mode sense */
40 #define	CMD_LOAD_UNLOAD		0x1b	/* load/unload */
41 #define	CMD_PAMR		0x1e	/* prevent/allow medium removal */
42 
43 /*
44  * Structure of READ, WRITE, READ REVERSE, RECOVER BUFFERED DATA
45  * commands (i.e., the cdb).
46  * Also used for VERIFY commands.
47  */
48 struct scsi_cdb_rw {
49 	u_char	cdb_cmd,	/* 0x08 or 0x0a or 0x0f or 0x13 or 0x14 */
50 		cdb_lun:3,	/* logical unit number */
51 		cdb_xxx:3,	/* reserved */
52 		cdb_bytecmp:1,	/* byte-by-byte comparison (VERIFY only) */
53 		cdb_fixed:1,	/* fixed length blocks */
54 		cdb_lenh,	/* transfer length (MSB) */
55 		cdb_lenm,	/* transfer length */
56 		cdb_lenl,	/* transfer length (LSB) */
57 		cdb_ctrl;	/* control byte */
58 };
59 
60 /*
61  * Structure of a TRACK SELECT command.
62  */
63 struct scsi_cdb_ts {
64 	u_char	cdb_cmd,	/* 0x0b */
65 		cdb_lun:3,	/* logical unit number */
66 		cdb_xxx0:5,	/* reserved */
67 		cdb_xxx1,	/* reserved */
68 		cdb_xxx2,	/* reserved */
69 		cdb_track,	/* track value */
70 		cdb_ctrl;	/* control byte */
71 };
72 
73 /*
74  * Structure of a WRITE FILEMARKS command.
75  */
76 struct scsi_cdb_wfm {
77 	u_char	cdb_cmd,	/* 0x0b */
78 		cdb_lun:3,	/* logical unit number */
79 		cdb_xxx0:5,	/* reserved */
80 		cdb_nfh,	/* number of filemarks (MSB) */
81 		cdb_nfm,	/* number of filemarks */
82 		cdb_nfl,	/* number of filemarks (LSB) */
83 		cdb_ctrl;	/* control byte */
84 };
85 
86 /*
87  * Structure of a SPACE command.
88  */
89 struct scsi_cdb_space {
90 	u_char	cdb_cmd,	/* 0x0b */
91 		cdb_lun:3,	/* logical unit number */
92 		cdb_xxx0:3,	/* reserved */
93 		cdb_code:2,	/* code (see below) */
94 		cdb_counth,	/* count (MSB) */
95 		cdb_countm,	/* count */
96 		cdb_countl,	/* count (LSB) */
97 		cdb_ctrl;	/* control byte */
98 };
99 #define	SCSI_CMD_SPACE_BLOCKS	0	/* skip blocks */
100 #define	SCSI_CMD_SPACE_FMS	1	/* skip file marks */
101 #define	SCSI_CMD_SPACE_SFMS	2	/* skip sequential file marks */
102 #define	SCSI_CMD_SPACE_PEOD	3	/* skip to physical end of data */
103 
104 /*
105  * Mode Select parameters (data).
106  */
107 struct scsi_msel {
108 	u_short	msel_xxx0;	/* reserved */
109 	u_char	msel_xxx1:1,	/* reserved */
110 		msel_bm:3,	/* buffered mode */
111 		msel_speed:4,	/* speed */
112 		msel_bdl;	/* block descriptor length */
113 	struct scsi_msel_bdesc {
114 		u_char	dc,	/* density code */
115 			nbh,	/* number of blocks (MSB) */
116 			nbm,	/* number of blocks */
117 			nbl,	/* number of blocks (LSB) */
118 			xxx,	/* reserved */
119 			blh,	/* block length (MSB) */
120 			blm,	/* block length */
121 			bll;	/* block length (LSB) */
122 	} msel_bd[1];		/* actually longer */
123 	/* followed by Vendor Unique bytes */
124 };
125 
126 /* buffered mode and speed */
127 #define	SCSI_MSEL_BM_UNBUFFERED	0	/* unbuffered writes */
128 #define	SCSI_MSEL_BM_BUFFERED	1	/* buffered writes allowed */
129 #define	SCSI_MSEL_SPEED_DEFAULT	0	/* use device default speed */
130 #define	SCSI_MSEL_SPEED_LOW	1	/* use lowest speed */
131 #define	SCSI_MSEL_SPEED_HIGH	15	/* use highest speed */
132 
133 /* density codes */
134 #define	SCSI_MSEL_DC_DEFAULT	0	/* use device default density */
135 #define	SCSI_MSEL_DC_9T_800BPI	1	/* 9 track, 800 bpi */
136 #define	SCSI_MSEL_DC_9T_1600BPI	2	/* 9 track, 1600 bpi */
137 #define	SCSI_MSEL_DC_9T_6250BPI	3	/* 9 track, 6250 bpi */
138 #define	SCSI_MSEL_DC_QIC_XX1	4	/* QIC-11? 4 or 9 track, 8000 bpi */
139 #define	SCSI_MSEL_DC_QIC_XX2	5	/* QIC-11? 4 or 9 track, 8000 bpi */
140 #define	SCSI_MSEL_DC_9T_3200BPI	6	/* 9 track, 3200 bpi */
141 #define	SCSI_MSEL_DC_QIC_XX3	7	/* QIC, 4 track, 6400 bpi */
142 #define	SCSI_MSEL_DC_CS_XX4	8	/* cassette 4 track, 8000 bpi 8/
143 #define	SCSI_MSEL_DC_HIC_XX5	9	/* half inch cartridge, 18 track */
144 #define	SCSI_MSEL_DC_HIC_XX6	10	/* HIC, 22 track, 6667 bpi */
145 #define	SCSI_MSEL_DC_QIC_XX7	11	/* QIC, 4 track, 1600 bpi */
146 #define	SCSI_MSEL_DC_HIC_XX8	12	/* HIC, 24 track, 12690 bpi */
147 #define	SCSI_MSEL_DC_HIC_XX9	13	/* HIC, 24 track, 25380 bpi */
148 
149 /*
150  * Structure of an ERASE command.
151  */
152 struct scsi_cdb_erase {
153 	u_char	cdb_cmd,	/* 0x0b */
154 		cdb_lun:3,	/* logical unit number */
155 		cdb_xxx0:4,	/* reserved */
156 		cdb_long:1,	/* long erase */
157 		cdb_xxx1,	/* reserved */
158 		cdb_xxx2,	/* reserved */
159 		cdb_xxx3,	/* reserved */
160 		cdb_ctrl;	/* control byte */
161 };
162 
163 /*
164  * Structure of a LOAD/UNLOAD command.
165  */
166 struct scsi_cdb_lu {
167 	u_char	cdb_cmd,	/* 0x1b */
168 		cdb_lun:3,	/* logical unit number */
169 		cdb_xxx0:4,	/* reserved */
170 		cdb_immed:1,	/* return status immediately */
171 		cdb_xxx1,	/* reserved */
172 		cdb_xxx2,	/* reserved */
173 		cdb_xxx3:6,	/* reserved */
174 		cdb_reten:1,	/* retension tape */
175 		cdb_load:1,	/* load (else unload) */
176 		cdb_ctrl;	/* control byte */
177 };
178