xref: /netbsd-src/sys/dev/scsipi/scsi_disk.h (revision d9158b13b5dfe46201430699a3f7a235ecf28df3)
1 /*
2  * SCSI interface description
3  */
4 
5 /*
6  * Some lines of this file come from a file of the name "scsi.h"
7  * distributed by OSF as part of mach2.5,
8  *  so the following disclaimer has been kept.
9  *
10  * Copyright 1990 by Open Software Foundation,
11  * Grenoble, FRANCE
12  *
13  * 		All Rights Reserved
14  *
15  *   Permission to use, copy, modify, and distribute this software and
16  * its documentation for any purpose and without fee is hereby granted,
17  * provided that the above copyright notice appears in all copies and
18  * that both the copyright notice and this permission notice appear in
19  * supporting documentation, and that the name of OSF or Open Software
20  * Foundation not be used in advertising or publicity pertaining to
21  * distribution of the software without specific, written prior
22  * permission.
23  *
24  *   OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
25  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
26  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
27  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
29  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
30  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31  */
32 
33 /*
34  * Largely written by Julian Elischer (julian@tfs.com)
35  * for TRW Financial Systems.
36  *
37  * TRW Financial Systems, in accordance with their agreement with Carnegie
38  * Mellon University, makes this software available to CMU to distribute
39  * or use in any manner that they see fit as long as this message is kept with
40  * the software. For this reason TFS also grants any other persons or
41  * organisations permission to use or modify this software.
42  *
43  * TFS supplies this software to be publicly redistributed
44  * on the understanding that TFS is not responsible for the correct
45  * functioning of this software in any circumstances.
46  *
47  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
48  *
49  *	$Id: scsi_disk.h,v 1.4 1994/03/29 04:29:32 mycroft Exp $
50  */
51 
52 /*
53  * SCSI command format
54  */
55 
56 #ifndef	_SCSI_SCSI_DISK_H
57 #define _SCSI_SCSI_DISK_H 1
58 
59 struct scsi_reassign_blocks
60 {
61 	u_char	op_code;
62 	u_char	byte2;
63 	u_char	unused[3];
64 	u_char	control;
65 };
66 
67 struct scsi_rw
68 {
69 	u_char	op_code;
70 	u_char	addr_2;		/* Most significant */
71 #define	SRW_TOPADDR	0x1F	/* only 5 bits here */
72 	u_char	addr_1;
73 	u_char	addr_0;		/* least significant */
74 	u_char	length;
75 	u_char	control;
76 };
77 
78 struct scsi_rw_big
79 {
80 	u_char	op_code;
81 	u_char	byte2;
82 #define	SRWB_RELADDR	0x01
83 	u_char	addr_3;		/* Most significant */
84 	u_char	addr_2;
85 	u_char	addr_1;
86 	u_char	addr_0;		/* least significant */
87 	u_char	reserved;;
88 	u_char	length2;
89 	u_char	length1;
90 	u_char	control;
91 };
92 
93 struct scsi_read_capacity
94 {
95 	u_char	op_code;
96 	u_char	byte2;
97 	u_char	addr_3;	/* Most Significant */
98 	u_char	addr_2;
99 	u_char	addr_1;
100 	u_char	addr_0;	/* Least Significant */
101 	u_char	unused[3];
102 	u_char	control;
103 };
104 
105 struct scsi_start_stop
106 {
107 	u_char	op_code;
108 	u_char	byte2;
109 	u_char	unused[2];
110 	u_char	how;
111 #define	SSS_STOP		0x00
112 #define	SSS_START		0x01
113 #define	SSS_LOEJ		0x02
114 	u_char	control;
115 };
116 
117 
118 
119 /*
120  * Opcodes
121  */
122 
123 #define	REASSIGN_BLOCKS		0x07
124 #define	READ_COMMAND		0x08
125 #define WRITE_COMMAND		0x0a
126 #define MODE_SELECT		0x15
127 #define MODE_SENSE		0x1a
128 #define START_STOP		0x1b
129 #define PREVENT_ALLOW		0x1e
130 #define	READ_CAPACITY		0x25
131 #define	READ_BIG		0x28
132 #define WRITE_BIG		0x2a
133 
134 
135 
136 struct scsi_read_cap_data
137 {
138 	u_char	addr_3;	/* Most significant */
139 	u_char	addr_2;
140 	u_char	addr_1;
141 	u_char	addr_0;	/* Least significant */
142 	u_char	length_3;	/* Most significant */
143 	u_char	length_2;
144 	u_char	length_1;
145 	u_char	length_0;	/* Least significant */
146 };
147 
148 struct scsi_reassign_blocks_data
149 {
150 	u_char	reserved[2];
151 	u_char	length_msb;
152 	u_char	length_lsb;
153 	struct
154 	{
155 		u_char	dlbaddr_3;	/* defect logical block address (MSB) */
156 		u_char	dlbaddr_2;
157 		u_char	dlbaddr_1;
158 		u_char	dlbaddr_0;	/* defect logical block address (LSB) */
159 	} defect_descriptor[1];
160 };
161 
162 union	disk_pages /* this is the structure copied from osf */
163 {
164 	struct page_disk_format {
165 	   u_char pg_code;	/* page code (should be 3)	      */
166 #define	DISK_PGCODE	0x3F	/* only 6 bits valid */
167 	   u_char pg_length;	/* page length (should be 0x16)	      */
168 	   u_char trk_z_1;	/* tracks per zone (MSB)	      */
169 	   u_char trk_z_0;	/* tracks per zone (LSB)	      */
170 	   u_char alt_sec_1;	/* alternate sectors per zone (MSB)   */
171 	   u_char alt_sec_0;	/* alternate sectors per zone (LSB)   */
172 	   u_char alt_trk_z_1;	/* alternate tracks per zone (MSB)    */
173 	   u_char alt_trk_z_0;	/* alternate tracks per zone (LSB)    */
174 	   u_char alt_trk_v_1;	/* alternate tracks per volume (MSB)  */
175 	   u_char alt_trk_v_0;	/* alternate tracks per volume (LSB)  */
176 	   u_char ph_sec_t_1;	/* physical sectors per track (MSB)   */
177 	   u_char ph_sec_t_0;	/* physical sectors per track (LSB)   */
178 	   u_char bytes_s_1;	/* bytes per sector (MSB)	      */
179 	   u_char bytes_s_0;	/* bytes per sector (LSB)	      */
180 	   u_char interleave_1;/* interleave (MSB)		      */
181 	   u_char interleave_0;/* interleave (LSB)		      */
182 	   u_char trk_skew_1;	/* track skew factor (MSB)	      */
183 	   u_char trk_skew_0;	/* track skew factor (LSB)	      */
184 	   u_char cyl_skew_1;	/* cylinder skew (MSB)		      */
185 	   u_char cyl_skew_0;	/* cylinder skew (LSB)		      */
186 	   u_char flags;	/* various */
187 #define		DISK_FMT_SURF	0x10
188 #define		DISK_FMT_RMB	0x20
189 #define		DISK_FMT_HSEC	0x40
190 #define		DISK_FMT_SSEC	0x80
191 	   u_char reserved2;
192 	   u_char reserved3;
193 	} disk_format;
194 	struct page_rigid_geometry {
195 	   u_char pg_code;	/* page code (should be 4)	      */
196 	   u_char pg_length;	/* page length (should be 0x16)	      */
197 	   u_char ncyl_2;	/* number of cylinders (MSB)	      */
198 	   u_char ncyl_1;	/* number of cylinders 		      */
199 	   u_char ncyl_0;	/* number of cylinders (LSB)	      */
200 	   u_char nheads;	/* number of heads 		      */
201 	   u_char st_cyl_wp_2;	/* starting cyl., write precomp (MSB) */
202 	   u_char st_cyl_wp_1;	/* starting cyl., write precomp	      */
203 	   u_char st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
204 	   u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/
205 	   u_char st_cyl_rwc_1;/* starting cyl., red. write cur      */
206 	   u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/
207 	   u_char driv_step_1;	/* drive step rate (MSB)	      */
208 	   u_char driv_step_0;	/* drive step rate (LSB)	      */
209 	   u_char land_zone_2;	/* landing zone cylinder (MSB)	      */
210 	   u_char land_zone_1;	/* landing zone cylinder 	      */
211 	   u_char land_zone_0;	/* landing zone cylinder (LSB)	      */
212 	   u_char reserved1;
213 	   u_char reserved2;
214 	   u_char reserved3;
215     	} rigid_geometry;
216 } ;
217 #endif /* _SCSI_SCSI_DISK_H*/
218