scsi_da.h revision 58111
1/*
2 * Structures and definitions for SCSI commands to Direct Access Devices
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 * $FreeBSD: head/sys/cam/scsi/scsi_da.h 58111 2000-03-15 21:55:48Z n_hibma $
50 */
51
52#ifndef	_SCSI_SCSI_DA_H
53#define _SCSI_SCSI_DA_H 1
54
55#include <sys/cdefs.h>
56
57struct scsi_rezero_unit
58{
59	u_int8_t opcode;
60#define SRZU_LUN_MASK 0xE0
61	u_int8_t byte2;
62	u_int8_t reserved[3];
63	u_int8_t control;
64};
65
66struct scsi_reassign_blocks
67{
68	u_int8_t opcode;
69	u_int8_t byte2;
70	u_int8_t unused[3];
71	u_int8_t control;
72};
73
74struct scsi_read_defect_data_10
75{
76	u_int8_t opcode;
77
78	/*
79	 * The most significant 3 bits are the LUN, the other 5 are
80	 * reserved.
81	 */
82#define SRDD10_LUN_MASK 0xE0
83	u_int8_t byte2;
84#define SRDD10_GLIST 0x08
85#define SRDD10_PLIST 0x10
86#define SRDD10_DLIST_FORMAT_MASK 0x07
87#define SRDD10_BLOCK_FORMAT            0x00
88#define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04
89#define SRDD10_PHYSICAL_SECTOR_FORMAT  0x05
90	u_int8_t format;
91
92	u_int8_t reserved[4];
93
94	u_int8_t alloc_length[2];
95
96	u_int8_t control;
97};
98
99struct scsi_read_defect_data_12
100{
101	u_int8_t opcode;
102
103	/*
104	 * The most significant 3 bits are the LUN, the other 5 are
105	 * reserved.
106	 */
107#define SRDD12_LUN_MASK 0xE0
108	u_int8_t byte2;
109
110#define SRDD12_GLIST 0x08
111#define SRDD12_PLIST 0x10
112#define SRDD12_DLIST_FORMAT_MASK 0x07
113#define SRDD12_BLOCK_FORMAT            0x00
114#define SRDD12_BYTES_FROM_INDEX_FORMAT 0x04
115#define SRDD12_PHYSICAL_SECTOR_FORMAT  0x05
116	u_int8_t format;
117
118	u_int8_t reserved[4];
119
120	u_int8_t alloc_length[4];
121
122	u_int8_t control;
123
124};
125
126
127/*
128 * Opcodes
129 */
130#define REZERO_UNIT		0x01
131#define	REASSIGN_BLOCKS		0x07
132#define MODE_SELECT		0x15
133#define MODE_SENSE		0x1a
134#define READ_DEFECT_DATA_10	0x37
135#define READ_DEFECT_DATA_12	0xb7
136
137
138struct scsi_reassign_blocks_data
139{
140	u_int8_t reserved[2];
141	u_int8_t length[2];
142	struct {
143		u_int8_t dlbaddr[4];	/* defect logical block address */
144	} defect_descriptor[1];
145};
146
147
148/*
149 * This is the list header for the READ DEFECT DATA(10) command above.
150 * It may be a bit wrong to append the 10 at the end of the data structure,
151 * since it's only 4 bytes but it does tie it to the 10 byte command.
152 */
153struct scsi_read_defect_data_hdr_10
154{
155	u_int8_t reserved;
156#define SRDDH10_GLIST 0x08
157#define SRDDH10_PLIST 0x10
158#define SRDDH10_DLIST_FORMAT_MASK 0x07
159#define SRDDH10_BLOCK_FORMAT            0x00
160#define SRDDH10_BYTES_FROM_INDEX_FORMAT 0x04
161#define SRDDH10_PHYSICAL_SECTOR_FORMAT  0x05
162	u_int8_t format;
163	u_int8_t length[2];
164};
165
166struct scsi_defect_desc_block
167{
168	u_int8_t address[4];
169};
170
171struct scsi_defect_desc_bytes_from_index
172{
173	u_int8_t cylinder[3];
174	u_int8_t head;
175	u_int8_t bytes_from_index[4];
176};
177
178struct scsi_defect_desc_phys_sector
179{
180	u_int8_t cylinder[3];
181	u_int8_t head;
182	u_int8_t sector[4];
183};
184
185struct scsi_read_defect_data_hdr_12
186{
187	u_int8_t reserved;
188#define SRDDH12_GLIST 0x08
189#define SRDDH12_PLIST 0x10
190#define SRDDH12_DLIST_FORMAT_MASK 0x07
191#define SRDDH12_BLOCK_FORMAT            0x00
192#define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04
193#define SRDDH12_PHYSICAL_SECTOR_FORMAT  0x05
194	u_int8_t format;
195	u_int8_t length[4];
196};
197
198union	disk_pages /* this is the structure copied from osf */
199{
200	struct format_device_page {
201		u_int8_t pg_code;	/* page code (should be 3)	      */
202#define	SMS_FORMAT_DEVICE_PAGE	0x03	/* only 6 bits valid */
203		u_int8_t pg_length;	/* page length (should be 0x16)	      */
204#define	SMS_FORMAT_DEVICE_PLEN	0x16
205		u_int8_t trk_z_1;	/* tracks per zone (MSB)	      */
206		u_int8_t trk_z_0;	/* tracks per zone (LSB)	      */
207		u_int8_t alt_sec_1;	/* alternate sectors per zone (MSB)   */
208		u_int8_t alt_sec_0;	/* alternate sectors per zone (LSB)   */
209		u_int8_t alt_trk_z_1;	/* alternate tracks per zone (MSB)    */
210		u_int8_t alt_trk_z_0;	/* alternate tracks per zone (LSB)    */
211		u_int8_t alt_trk_v_1;	/* alternate tracks per volume (MSB)  */
212		u_int8_t alt_trk_v_0;	/* alternate tracks per volume (LSB)  */
213		u_int8_t ph_sec_t_1;	/* physical sectors per track (MSB)   */
214		u_int8_t ph_sec_t_0;	/* physical sectors per track (LSB)   */
215		u_int8_t bytes_s_1;	/* bytes per sector (MSB)	      */
216		u_int8_t bytes_s_0;	/* bytes per sector (LSB)	      */
217		u_int8_t interleave_1;	/* interleave (MSB)		      */
218		u_int8_t interleave_0;	/* interleave (LSB)		      */
219		u_int8_t trk_skew_1;	/* track skew factor (MSB)	      */
220		u_int8_t trk_skew_0;	/* track skew factor (LSB)	      */
221		u_int8_t cyl_skew_1;	/* cylinder skew (MSB)		      */
222		u_int8_t cyl_skew_0;	/* cylinder skew (LSB)		      */
223		u_int8_t flags;		/* various */
224#define			DISK_FMT_SURF	0x10
225#define	       		DISK_FMT_RMB	0x20
226#define			DISK_FMT_HSEC	0x40
227#define			DISK_FMT_SSEC	0x80
228		u_int8_t reserved21;
229		u_int8_t reserved22;
230		u_int8_t reserved23;
231	} format_device;
232	struct rigid_geometry_page {
233		u_int8_t pg_code;	/* page code (should be 4)	      */
234#define SMS_RIGID_GEOMETRY_PAGE 0x04
235		u_int8_t pg_length;	/* page length (should be 0x16)	      */
236#define SMS_RIGID_GEOMETRY_PLEN 0x16
237		u_int8_t ncyl_2;	/* number of cylinders (MSB)	      */
238		u_int8_t ncyl_1;	/* number of cylinders 		      */
239		u_int8_t ncyl_0;	/* number of cylinders (LSB)	      */
240		u_int8_t nheads;	/* number of heads 		      */
241		u_int8_t st_cyl_wp_2;	/* starting cyl., write precomp (MSB) */
242		u_int8_t st_cyl_wp_1;	/* starting cyl., write precomp	      */
243		u_int8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
244		u_int8_t st_cyl_rwc_2;	/* starting cyl., red. write cur (MSB)*/
245		u_int8_t st_cyl_rwc_1;	/* starting cyl., red. write cur      */
246		u_int8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/
247		u_int8_t driv_step_1;	/* drive step rate (MSB)	      */
248		u_int8_t driv_step_0;	/* drive step rate (LSB)	      */
249		u_int8_t land_zone_2;	/* landing zone cylinder (MSB)	      */
250		u_int8_t land_zone_1;	/* landing zone cylinder 	      */
251		u_int8_t land_zone_0;	/* landing zone cylinder (LSB)	      */
252		u_int8_t rpl;		/* rotational position locking (2 bits) */
253		u_int8_t rot_offset;	/* rotational offset */
254		u_int8_t reserved19;
255		u_int8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
256		u_int8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */
257		u_int8_t reserved22;
258		u_int8_t reserved23;
259    	} rigid_geometry;
260	struct flexible_disk_page {
261		u_int8_t pg_code;	/* page code (should be 5)	      */
262#define SMS_FLEXIBLE_GEOMETRY_PAGE 0x05
263		u_int8_t pg_length;	/* page length (should be 0x1E)	      */
264#define SMS_FLEXIBLE_GEOMETRY_PLEN 0x1E
265		u_int8_t xfr_rate_1;	/* transfer rate (MSB)		      */
266		u_int8_t xfr_rate_0;	/* transfer rate (LSB)		      */
267		u_int8_t nheads;	/* number of heads 		      */
268		u_int8_t sec_per_track;	/* Sectors per track		      */
269		u_int8_t bytes_s_1;	/* bytes per sector (MSB)	      */
270		u_int8_t bytes_s_0;	/* bytes per sector (LSB)	      */
271		u_int8_t ncyl_1;	/* number of cylinders (MSB)	      */
272		u_int8_t ncyl_0;	/* number of cylinders (LSB)	      */
273		u_int8_t st_cyl_wp_1;	/* starting cyl., write precomp (MSB) */
274		u_int8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
275		u_int8_t st_cyl_rwc_1;	/* starting cyl., red. write cur (MSB)*/
276		u_int8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/
277		u_int8_t driv_step_1;	/* drive step rate (MSB)	      */
278		u_int8_t driv_step_0;	/* drive step rate (LSB)	      */
279		u_int8_t driv_step_pw;	/* drive step pulse width	      */
280		u_int8_t head_stl_del_1;/* Head settle delay (MSB)	      */
281		u_int8_t head_stl_del_0;/* Head settle delay (LSB)	      */
282		u_int8_t motor_on_del;	/* Motor on delay		      */
283		u_int8_t motor_off_del;	/* Motor off delay		      */
284		u_int8_t trdy_ssn_mo;	/* XXX ??? */
285		u_int8_t spc;		/* XXX ??? */
286		u_int8_t write_comp;	/* Write compensation */
287		u_int8_t head_load_del; /* Head load delay */
288		u_int8_t head_uload_del;/* Head un-load delay */
289		u_int8_t pin32_pin2;
290		u_int8_t pin4_pint1;
291		u_int8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
292		u_int8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */
293		u_int8_t reserved30;
294		u_int8_t reserved31;
295    	} flexible_disk;
296};
297
298struct scsi_da_rw_recovery_page {
299	u_int8_t page_code;
300#define SMS_RW_ERROR_RECOVERY_PAGE	0x01
301	u_int8_t page_length;
302	u_int8_t byte3;
303#define SMS_RWER_AWRE			0x80
304#define SMS_RWER_ARRE			0x40
305#define SMS_RWER_TB			0x20
306#define SMS_RWER_RC			0x10
307#define SMS_RWER_EER			0x08
308#define SMS_RWER_PER			0x04
309#define SMS_RWER_DTE			0x02
310#define SMS_RWER_DCR			0x01
311	u_int8_t read_retry_count;
312	u_int8_t correction_span;
313	u_int8_t head_offset_count;
314	u_int8_t data_strobe_offset_cnt;
315	u_int8_t reserved;
316	u_int8_t write_retry_count;
317	u_int8_t reserved2;
318	u_int8_t recovery_time_limit[2];
319};
320
321#endif /* _SCSI_SCSI_DA_H */
322