xref: /original-bsd/sys/dev/scsi/disk.h (revision 088910ec)
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  *	@(#)disk.h	5.2 (Berkeley) 07/23/92
17  *
18  * from: $Header: disk.h,v 1.2 92/05/15 11:23:58 torek Exp $ (LBL)
19  */
20 
21 /*
22  * SCSI definitions for Direct Access Devices (disks).
23  * This includes WORMs and CD-ROMs (although a few commands, such as
24  * format or write, are nonsensical on some).
25  *
26  * Commands defined in the common header (scsi.h) appear here as comments.
27  */
28 
29 	/* group 0 */
30 /*	CMD_TEST_UNIT_READY	0x00	   test unit ready */
31 #define	CMD_REZERO		0x01	/* rezero unit */
32 /*	CMD_REQUEST_SENSE	0x03	/* request sense */
33 #define	CMD_FORMAT_UNIT		0x04	/* format unit (disk) */
34 #define	CMD_REASSIGN_BLOCKS	0x07	/* reassign blocks (disk, WORM) */
35 #define	CMD_READ6		0x08	/* read (6 byte cdb) */
36 #define	CMD_WRITE6		0x0a	/* write (6 byte cdb) */
37 #define	CMD_SEEK6		0x0b	/* seek (6 byte cdb) */
38 /*	CMD_INQUIRY		0x12	   inquiry */
39 #define	CMD_MODE_SELECT		0x15	/* mode select */
40 #define	CMD_RESERVE		0x16	/* reserve */
41 #define	CMD_RELEASE		0x17	/* release */
42 /*	CMD_COPY		0x18	   copy */
43 #define	CMD_MODE_SENSE		0x1a	/* mode sense */
44 #define	CMD_SSU			0x1b	/* start/stop unit */
45 /*	CMD_RECEIVE_DIAG	0x1c	   receive diagnostic results */
46 /*	CMD_SEND_DIAG		0x1d	   send diagnostic */
47 #define	CMD_PAMR		0x1e	/* prevent/allow medium removal */
48 
49 	/* group 1 */
50 #define	CMD_READ_CAPACITY	0x25	/* read capacity */
51 #define	CMD_READ10		0x28	/* read (10 byte cdb) */
52 #define	CMD_WRITE10		0x2a	/* write (10 byte cdb) */
53 #define	CMD_SEEK10		0x2b	/* write (10 byte cdb) */
54 #define	CMD_WRITE_VERIFY	0x2e	/* write and verify */
55 #define	CMD_VERIFY		0x2f	/* verify */
56 #define	CMD_SEARCH_H		0x30	/* search data high */
57 #define	CMD_SEARCH_E		0x31	/* search data equal */
58 #define	CMD_SEARCH_L		0x32	/* search data low */
59 #define	CMD_SET_LIMITS		0x33	/* set limits */
60 /*	CMD_COMPARE		0x39	   compare */
61 #define	CMD_COPY_VERIFY		0x3a	/* copy and verify */
62 
63 /* this one is in van's but not in my 17B documents */
64 #define	CMD_READ_DEFECT_DATA	0x37	/* read defect data */ /* ??? */
65 
66 /*
67  * Structure of a FORMAT UNIT command (i.e., the cdb):
68  *	byte 0: opcode<8>
69  *	byte 1: lun<3> format_data<1> complete_list<1> defect_list_format<3>
70  *	byte 2: vendor unique
71  *	byte 3: interleave (MSB)
72  *	byte 4: interleave (LSB)
73  *	byte 5: control
74  */
75 struct scsi_cdb_fu {
76 	u_char	cdb_cmd;		/* SCSI_CMD_FU */
77 	u_char	cdb_lun_etc;		/* lun+FD+CL+DLF */
78 	u_char	cdb_vu;			/* vendor unique */
79 	u_char	cdb_ilvh;		/* interleave (MSB) */
80 	u_char	cdb_ilvl;		/* interleave (LSB) */
81 	u_char	cdb_ctrl;		/* control byte */
82 };
83 
84 /*
85  * If format data are supplied, they give either additional (cl=0) or
86  * new (cl=1) defect list in one of the following formats.
87  * Formats 1, 2, and 3 are the same as 0; formats 6 and 7 are
88  * vendor unique and reserved, respectively.  (The `backwards'
89  * in `backwards compatible'...)
90  */
91 #define	SCSI_DLF_BLOCK	0		/* dlf = blocks */
92 #define	SCSI_DLF_BFI	4		/* dlf = bytes from index */
93 #define	SCSI_DLF_PS	5		/* dlf = physical sectors */
94 
95 /*
96  * Defect list header, block format (`defect block address').
97  *
98  * N.B.: this structure is also used for the Reassign Blocks command;
99  * there the `defect block address' becomes a `defect logical block address'.
100  */
101 struct scsi_dlf_dba {
102 	u_short	dlf_xxx;		/* reserved */
103 	u_char	dlf_lenh,		/* defect list length (MSB) */
104 		dlf_lenl;		/* defect list length (LSB) */
105 	struct scsi_dlf_dba_desc {
106 		u_char	dbah,		/* defect block address (MSB) */
107 			dbahm,		/* defect block address */
108 			dbalm,		/* defect block address */
109 			dbal;		/* defect block address (LSB) */
110 	} dlf_dba[1];			/* actually longer */
111 };
112 
113 /*
114  * Defect list header, Bytes From Index format.
115  */
116 struct scsi_dlf_bfi {
117 	u_short	dlf_xxx;		/* reserved */
118 	u_char	dlf_lenh,		/* defect list length (MSB) */
119 		dlf_lenl;		/* defect list length (LSB) */
120 	struct scsi_dlf_bfi_desc {
121 		u_char	cylh,		/* cylinder number of defect (MSB) */
122 			cylm,		/* cylinder number of defect */
123 			cyll,		/* cylinder number of defect (LSB) */
124 			head,		/* head number of defect */
125 			bfih,		/* defect bytes from index (MSB) */
126 			bfihm,		/* defect bytes from index */
127 			bfilm,		/* defect bytes from index */
128 			bfil;		/* defect bytes from index (LSB) */
129 	} dlf_bfi[1];			/* actually longer */
130 };
131 
132 /*
133  * Defect list header, Physical Sector format.
134  */
135 struct scsi_dlf_ps {
136 	u_short	dlf_xxx;		/* reserved */
137 	u_char	dlf_lenh,		/* defect list length (MSB) */
138 		dlf_lenl;		/* defect list length (LSB) */
139 	struct scsi_dlf_ps_desc {
140 		u_char	cylh,		/* cylinder number of defect (MSB) */
141 			cylm,		/* cylinder number of defect */
142 			cyll,		/* cylinder number of defect (LSB) */
143 			head,		/* head number of defect */
144 			dsnh,		/* defect sector number (MSB) */
145 			dsnhm,		/* defect sector number */
146 			dsnlm,		/* defect sector number */
147 			dsnl;		/* defect sector number (LSB) */
148 	} dlf_ps[1];			/* actually longer */
149 };
150 
151 /*
152  * Structure of data passed via a MODE SELECT command.
153  */
154 struct scsi_ms {
155 	u_char	ms_xxx0,		/* reserved */
156 		ms_mt,			/* medium type */
157 		ms_xxx1,		/* reserved */
158 		ms_bdl;			/* block descriptor length */
159 	struct scsi_ms_b_desc {
160 		u_char	dc,		/* density code */
161 			nbh,		/* number of blocks (MSB) */
162 			nbm,		/* number of blocks */
163 			nbl,		/* number of blocks (LSB) */
164 			xxx,		/* reserved */
165 			blh,		/* block length (MSB) */
166 			blm,		/* block length */
167 			bll;		/* block length (LSB) */
168 	} ms_bd[1];			/* actually longer */
169 	/* followed by vendor unique bytes */
170 };
171 
172 /* values for the Medium Type field - disks */
173 #define	SCSI_CMD_MS_MT_DEFAULT	0x00	/* whatever is current */
174 #define	SCSI_CMD_MS_MT_SS	0x01	/* single sided, unspecified medium */
175 #define	SCSI_CMD_MS_MT_DS	0x02	/* double sided, unspecified medium */
176 #define	SCSI_CMD_MS_MT_8SSSD	0x05	/* 8" floppy, SSSD (X3.73-1980) */
177 #define	SCSI_CMD_MS_MT_8DSSD	0x06	/* 8" floppy, DSSD (X3B8-140) */
178 #define	SCSI_CMD_MS_MT_8SSDD	0x09	/* 8" floppy, SSDD (X3B8/78-139) */
179 #define	SCSI_CMD_MS_MT_8DSDD	0x0a	/* 8" floppy, DSDD (X3.121-1984) */
180 #define	SCSI_CMD_MS_MT_5SSSD	0x0d	/* 5.25" floppy, SSSD (X3.82-1980) */
181 #define	SCSI_CMD_MS_MT_5DSDD	0x12	/* 5.25" floppy, DSDD (X3.125-1984) */
182 #define	SCSI_CMD_MS_MT_5DSDD96	0x16	/* 5.25", DSDD, 96tpi (X3.126-198X) */
183 #define	SCSI_CMD_MS_MT_5DSQD	0x1a	/* 5.25", DSQD, 96tpi (DIS 8630) */
184 #define	SCSI_CMD_MS_MT_3DS	0x1e	/* 3.5", double sided (X3.137-198X) */
185 
186 /* values for the Medium Type field - tapes */
187 #define	SCSI_CMD_MS_MT_QIC_12T	0x40	/* 0.25", 12 tracks */
188 #define	SCSI_CMD_MS_MT_QIC_24T	0x44	/* 0.25", 24 tracks */
189 
190 /*
191  * Bits in cdb_lenl for a READ CAPACITY command,
192  * and structure returned as data.
193  *
194  * If PMI is off, the lba in the cdb must be 0.
195  */
196 #define	SCSI_CMD_RC_PMI		0x01	/* Partial Medium Indicator */
197 
198 struct scsi_rc {
199 	u_char	rc_lbah;		/* logical block address (MSB) */
200 	u_char	rc_lbahm;		/* logical block address */
201 	u_char	rc_lbalm;		/* logical block address */
202 	u_char	rc_lbal;		/* logical block address (LSB) */
203 	u_char	rc_blh;			/* block length (MSB) */
204 	u_char	rc_blhm;		/* block length */
205 	u_char	rc_bllm;		/* block length */
206 	u_char	rc_bll;			/* block length (LSB) */
207 };
208