master
  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
 50#ifndef	_SCSI_SCSI_DA_H
 51#define _SCSI_SCSI_DA_H 1
 52
 53#include <sys/cdefs.h>
 54
 55struct scsi_rezero_unit
 56{
 57	uint8_t opcode;
 58#define SRZU_LUN_MASK 0xE0
 59	uint8_t byte2;
 60	uint8_t reserved[3];
 61	uint8_t control;
 62};
 63
 64/*
 65 * NOTE:  The lower three bits of byte2 of the format CDB are the same as
 66 * the lower three bits of byte2 of the read defect data CDB, below.
 67 */
 68struct scsi_format_unit
 69{
 70	uint8_t opcode;
 71	uint8_t byte2;
 72#define FU_FORMAT_MASK	SRDD10_DLIST_FORMAT_MASK
 73#define FU_BLOCK_FORMAT	SRDD10_BLOCK_FORMAT
 74#define FU_BFI_FORMAT	SRDD10_BYTES_FROM_INDEX_FORMAT
 75#define FU_PHYS_FORMAT	SRDD10_PHYSICAL_SECTOR_FORMAT
 76#define FU_CMPLST	0x08
 77#define FU_FMT_DATA	0x10
 78	uint8_t vendor_specific;
 79	uint8_t interleave[2];
 80	uint8_t control;
 81};
 82
 83struct scsi_reassign_blocks
 84{
 85	uint8_t opcode;
 86	uint8_t byte2;
 87	uint8_t unused[3];
 88	uint8_t control;
 89};
 90
 91struct scsi_read_defect_data_10
 92{
 93	uint8_t opcode;
 94	uint8_t byte2;
 95#define SRDD10_GLIST 0x08
 96#define SRDD10_PLIST 0x10
 97#define SRDD10_DLIST_FORMAT_MASK 0x07
 98#define SRDD10_BLOCK_FORMAT            0x00
 99#define SRDD10_EXT_BFI_FORMAT 	       0x01
100#define SRDD10_EXT_PHYS_FORMAT 	       0x02
101#define SRDD10_LONG_BLOCK_FORMAT       0x03
102#define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04
103#define SRDD10_PHYSICAL_SECTOR_FORMAT  0x05
104#define SRDD10_VENDOR_FORMAT	       0x06
105	uint8_t format;
106	uint8_t reserved[4];
107	uint8_t alloc_length[2];
108#define	SRDD10_MAX_LENGTH		0xffff
109	uint8_t control;
110};
111
112struct scsi_sanitize
113{
114	uint8_t opcode;
115	uint8_t byte2;
116#define SSZ_SERVICE_ACTION_OVERWRITE         0x01
117#define SSZ_SERVICE_ACTION_BLOCK_ERASE       0x02
118#define SSZ_SERVICE_ACTION_CRYPTO_ERASE      0x03
119#define SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE 0x1F
120#define SSZ_UNRESTRICTED_EXIT                0x20
121#define SSZ_IMMED                            0x80
122	uint8_t reserved[5];
123	uint8_t length[2];
124	uint8_t control;
125};
126
127struct scsi_sanitize_parameter_list
128{
129	uint8_t byte1;
130#define SSZPL_INVERT 0x80
131	uint8_t reserved;
132	uint8_t length[2];
133	/* Variable length initialization pattern. */
134#define SSZPL_MAX_PATTERN_LENGTH 65535
135};
136
137struct scsi_read_defect_data_12
138{
139	uint8_t opcode;
140#define SRDD12_GLIST 0x08
141#define SRDD12_PLIST 0x10
142#define SRDD12_DLIST_FORMAT_MASK 0x07
143#define SRDD12_BLOCK_FORMAT            SRDD10_BLOCK_FORMAT
144#define SRDD12_BYTES_FROM_INDEX_FORMAT SRDD10_BYTES_FROM_INDEX_FORMAT
145#define SRDD12_PHYSICAL_SECTOR_FORMAT  SRDD10_PHYSICAL_SECTOR_FORMAT
146	uint8_t format;
147	uint8_t address_descriptor_index[4];
148	uint8_t alloc_length[4];
149#define	SRDD12_MAX_LENGTH		0xffffffff
150	uint8_t reserved;
151	uint8_t control;
152};
153
154struct scsi_zbc_out
155{
156	uint8_t opcode;
157	uint8_t service_action;
158#define	ZBC_OUT_SA_CLOSE	0x01
159#define	ZBC_OUT_SA_FINISH	0x02
160#define	ZBC_OUT_SA_OPEN		0x03
161#define	ZBC_OUT_SA_RWP		0x04
162	uint8_t zone_id[8];
163	uint8_t reserved[4];
164	uint8_t zone_flags;
165#define	ZBC_OUT_ALL		0x01
166	uint8_t control;
167};
168
169struct scsi_zbc_in
170{
171	uint8_t opcode;
172	uint8_t service_action;
173#define	ZBC_IN_SA_REPORT_ZONES	0x00
174	uint8_t zone_start_lba[8];
175	uint8_t length[4];
176	uint8_t zone_options;
177#define	ZBC_IN_PARTIAL		0x80
178#define	ZBC_IN_REP_ALL_ZONES	0x00
179#define	ZBC_IN_REP_EMPTY	0x01
180#define	ZBC_IN_REP_IMP_OPEN	0x02
181#define	ZBC_IN_REP_EXP_OPEN	0x03
182#define	ZBC_IN_REP_CLOSED	0x04
183#define	ZBC_IN_REP_FULL		0x05
184#define	ZBC_IN_REP_READONLY	0x06
185#define	ZBC_IN_REP_OFFLINE	0x07
186#define	ZBC_IN_REP_RESET	0x10
187#define	ZBC_IN_REP_NON_SEQ	0x11
188#define	ZBC_IN_REP_NON_WP	0x3f
189#define	ZBC_IN_REP_MASK		0x3f
190	uint8_t control;
191};
192
193struct scsi_report_zones_desc {
194	uint8_t zone_type;
195#define	SRZ_TYPE_CONVENTIONAL	0x01
196#define	SRZ_TYPE_SEQ_REQUIRED	0x02
197#define	SRZ_TYPE_SEQ_PREFERRED	0x03
198#define	SRZ_TYPE_MASK		0x0f
199	uint8_t zone_flags;
200#define	SRZ_ZONE_COND_SHIFT	4
201#define	SRZ_ZONE_COND_MASK	0xf0
202#define	SRZ_ZONE_COND_NWP	0x00
203#define	SRZ_ZONE_COND_EMPTY	0x10
204#define	SRZ_ZONE_COND_IMP_OPEN	0x20
205#define	SRZ_ZONE_COND_EXP_OPEN	0x30
206#define	SRZ_ZONE_COND_CLOSED	0x40
207#define	SRZ_ZONE_COND_READONLY	0xd0
208#define	SRZ_ZONE_COND_FULL	0xe0
209#define	SRZ_ZONE_COND_OFFLINE	0xf0
210#define	SRZ_ZONE_NON_SEQ	0x02
211#define	SRZ_ZONE_RESET		0x01
212	uint8_t reserved[6];
213	uint8_t zone_length[8];
214	uint8_t zone_start_lba[8];
215	uint8_t write_pointer_lba[8];
216	uint8_t reserved2[32];
217};
218
219struct scsi_report_zones_hdr {
220	uint8_t length[4];
221	uint8_t byte4;
222#define	SRZ_SAME_ALL_DIFFERENT	 0x00 /* Lengths and types vary */
223#define	SRZ_SAME_ALL_SAME	 0x01 /* Lengths and types the same */
224#define	SRZ_SAME_LAST_DIFFERENT	 0x02 /* Types same, last length varies */
225#define SRZ_SAME_TYPES_DIFFERENT 0x03 /* Types vary, length the same */
226#define	SRZ_SAME_MASK		 0x0f
227	uint8_t reserved[3];
228	uint8_t maximum_lba[8];
229	uint8_t reserved2[48];
230	struct scsi_report_zones_desc desc_list[];
231};
232
233/*
234 * Opcodes
235 */
236#define REZERO_UNIT		0x01
237#define FORMAT_UNIT		0x04
238#define	REASSIGN_BLOCKS		0x07
239#define MODE_SELECT		0x15
240#define MODE_SENSE		0x1a
241#define	READ_FORMAT_CAPACITIES	0x23
242#define	WRITE_AND_VERIFY	0x2e
243#define	VERIFY			0x2f
244#define READ_DEFECT_DATA_10	0x37
245#define SANITIZE		0x48
246#define	ZBC_OUT			0x94
247#define	ZBC_IN			0x95
248#define READ_DEFECT_DATA_12	0xb7
249
250struct format_defect_list_header
251{
252	uint8_t reserved;
253	uint8_t byte2;
254#define FU_DLH_VS	0x01
255#define FU_DLH_IMMED	0x02
256#define FU_DLH_DSP	0x04
257#define FU_DLH_IP	0x08
258#define FU_DLH_STPF	0x10
259#define FU_DLH_DCRT	0x20
260#define FU_DLH_DPRY	0x40
261#define FU_DLH_FOV	0x80
262	uint8_t defect_list_length[2];
263};
264
265struct format_ipat_descriptor
266{
267	uint8_t byte1;
268#define	FU_INIT_NO_HDR		0x00
269#define FU_INIT_LBA_MSB		0x40
270#define FU_INIT_LBA_EACH	0x80
271#define FU_INIT_SI		0x20
272	uint8_t pattern_type;
273#define FU_INIT_PAT_DEFAULT	0x00
274#define FU_INIT_PAT_REPEAT	0x01
275	uint8_t pat_length[2];
276};
277
278struct scsi_read_format_capacities
279{
280	uint8_t	opcode;		/* READ_FORMAT_CAPACITIES */
281	uint8_t	byte2;
282#define	SRFC_LUN_MASK	0xE0
283	uint8_t	reserved0[5];
284	uint8_t	alloc_length[2];
285	uint8_t	reserved1[3];
286};
287
288struct scsi_verify_10
289{
290	uint8_t	opcode;		/* VERIFY(10) */
291	uint8_t	byte2;
292#define	SVFY_LUN_MASK	0xE0
293#define	SVFY_RELADR	0x01
294#define	SVFY_BYTCHK	0x02
295#define	SVFY_DPO	0x10
296	uint8_t	addr[4];	/* LBA to begin verification at */
297	uint8_t	group;
298	uint8_t	length[2];		/* number of blocks to verify */
299	uint8_t	control;
300};
301
302struct scsi_verify_12
303{
304	uint8_t	opcode;		/* VERIFY(12) */
305	uint8_t	byte2;
306	uint8_t	addr[4];	/* LBA to begin verification at */
307	uint8_t	length[4];		/* number of blocks to verify */
308	uint8_t	group;
309	uint8_t	control;
310};
311
312struct scsi_verify_16
313{
314	uint8_t	opcode;		/* VERIFY(16) */
315	uint8_t	byte2;
316	uint8_t	addr[8];	/* LBA to begin verification at */
317	uint8_t	length[4];		/* number of blocks to verify */
318	uint8_t	group;
319	uint8_t	control;
320};
321
322struct scsi_compare_and_write
323{
324	uint8_t	opcode;		/* COMPARE AND WRITE */
325	uint8_t	byte2;
326	uint8_t	addr[8];	/* LBA to begin verification at */
327	uint8_t	reserved[3];
328	uint8_t	length;		/* number of blocks */
329	uint8_t	group;
330	uint8_t	control;
331};
332
333struct scsi_write_and_verify
334{
335	uint8_t	opcode;		/* WRITE_AND_VERIFY */
336	uint8_t	byte2;
337#define	SWVY_LUN_MASK	0xE0
338#define	SWVY_RELADR	0x01
339#define	SWVY_BYTECHK	0x02
340#define	SWVY_DPO	0x10
341	uint8_t	addr[4];	/* LBA to begin verification at */
342	uint8_t	reserved0[1];
343	uint8_t	len[2];		/* number of blocks to write and verify */
344	uint8_t	reserved1[3];
345};
346
347/*
348 * Replies to READ_FORMAT_CAPACITIES look like this:
349 *
350 * struct format_capacity_list_header
351 * struct format_capacity_descriptor[1..n]
352 *
353 * These are similar, but not totally identical to, the
354 * defect list used to format a rigid disk.
355 *
356 * The appropriate csio_decode() format string looks like this:
357 * "{} *i3 {Len} i1 {Blocks} i4 {} *b6 {Code} b2 {Blocklen} i3"
358 *
359 * If the capacity_list_length is greater than
360 * sizeof(struct format_capacity_descriptor), then there are
361 * additional format capacity descriptors available which
362 * denote which format(s) the drive can handle.
363 *
364 * (Source: USB Mass Storage UFI Specification)
365 */
366
367struct format_capacity_list_header {
368	uint8_t	unused[3];
369	uint8_t	capacity_list_length;
370};
371
372struct format_capacity_descriptor {
373	uint8_t	nblocks[4];	/* total number of LBAs */
374	uint8_t	byte4;		/* only present in max/cur descriptor */
375#define FCD_CODE_MASK	0x03	/* mask for code field above */
376#define FCD_UNFORMATTED	0x01	/* unformatted media present,
377				 * maximum capacity returned */
378#define FCD_FORMATTED	0x02	/* formatted media present,
379				 * current capacity returned */
380#define FCD_NOMEDIA	0x03	/* no media present,
381				 * maximum device capacity returned */
382	uint8_t	block_length[3];	/* length of an LBA in bytes */
383};
384
385struct scsi_reassign_blocks_data
386{
387	uint8_t reserved[2];
388	uint8_t length[2];
389	struct {
390		uint8_t dlbaddr[4];	/* defect logical block address */
391	} defect_descriptor[1];
392};
393
394/*
395 * This is the list header for the READ DEFECT DATA(10) command above.
396 * It may be a bit wrong to append the 10 at the end of the data structure,
397 * since it's only 4 bytes but it does tie it to the 10 byte command.
398 */
399struct scsi_read_defect_data_hdr_10
400{
401	uint8_t reserved;
402#define SRDDH10_GLIST 0x08
403#define SRDDH10_PLIST 0x10
404#define SRDDH10_DLIST_FORMAT_MASK 0x07
405#define SRDDH10_BLOCK_FORMAT            0x00
406#define SRDDH10_BYTES_FROM_INDEX_FORMAT 0x04
407#define SRDDH10_PHYSICAL_SECTOR_FORMAT  0x05
408	uint8_t format;
409	uint8_t length[2];
410#define	SRDDH10_MAX_LENGTH	SRDD10_MAX_LENGTH -			     \
411				sizeof(struct scsi_read_defect_data_hdr_10) 
412};
413
414struct scsi_defect_desc_block
415{
416	uint8_t address[4];
417};
418
419struct scsi_defect_desc_long_block
420{
421	uint8_t address[8];
422};
423
424struct scsi_defect_desc_bytes_from_index
425{
426	uint8_t cylinder[3];
427	uint8_t head;
428#define	SDD_EXT_BFI_MADS		0x80000000
429#define	SDD_EXT_BFI_FLAG_MASK		0xf0000000
430#define	SDD_EXT_BFI_ENTIRE_TRACK	0x0fffffff
431	uint8_t bytes_from_index[4];
432};
433
434struct scsi_defect_desc_phys_sector
435{
436	uint8_t cylinder[3];
437	uint8_t head;
438#define	SDD_EXT_PHYS_MADS		0x80000000
439#define	SDD_EXT_PHYS_FLAG_MASK		0xf0000000
440#define	SDD_EXT_PHYS_ENTIRE_TRACK	0x0fffffff
441	uint8_t sector[4];
442};
443
444struct scsi_read_defect_data_hdr_12
445{
446	uint8_t reserved;
447#define SRDDH12_GLIST 0x08
448#define SRDDH12_PLIST 0x10
449#define SRDDH12_DLIST_FORMAT_MASK 0x07
450#define SRDDH12_BLOCK_FORMAT            0x00
451#define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04
452#define SRDDH12_PHYSICAL_SECTOR_FORMAT  0x05
453	uint8_t format;
454	uint8_t generation[2];
455	uint8_t length[4];
456#define	SRDDH12_MAX_LENGTH	SRDD12_MAX_LENGTH -			    \
457				sizeof(struct scsi_read_defect_data_hdr_12)
458};
459
460union	disk_pages /* this is the structure copied from osf */
461{
462	struct format_device_page {
463		uint8_t pg_code;	/* page code (should be 3)	      */
464#define	SMS_FORMAT_DEVICE_PAGE	0x03	/* only 6 bits valid */
465		uint8_t pg_length;	/* page length (should be 0x16)	      */
466#define	SMS_FORMAT_DEVICE_PLEN	0x16
467		uint8_t trk_z_1;	/* tracks per zone (MSB)	      */
468		uint8_t trk_z_0;	/* tracks per zone (LSB)	      */
469		uint8_t alt_sec_1;	/* alternate sectors per zone (MSB)   */
470		uint8_t alt_sec_0;	/* alternate sectors per zone (LSB)   */
471		uint8_t alt_trk_z_1;	/* alternate tracks per zone (MSB)    */
472		uint8_t alt_trk_z_0;	/* alternate tracks per zone (LSB)    */
473		uint8_t alt_trk_v_1;	/* alternate tracks per volume (MSB)  */
474		uint8_t alt_trk_v_0;	/* alternate tracks per volume (LSB)  */
475		uint8_t ph_sec_t_1;	/* physical sectors per track (MSB)   */
476		uint8_t ph_sec_t_0;	/* physical sectors per track (LSB)   */
477		uint8_t bytes_s_1;	/* bytes per sector (MSB)	      */
478		uint8_t bytes_s_0;	/* bytes per sector (LSB)	      */
479		uint8_t interleave_1;	/* interleave (MSB)		      */
480		uint8_t interleave_0;	/* interleave (LSB)		      */
481		uint8_t trk_skew_1;	/* track skew factor (MSB)	      */
482		uint8_t trk_skew_0;	/* track skew factor (LSB)	      */
483		uint8_t cyl_skew_1;	/* cylinder skew (MSB)		      */
484		uint8_t cyl_skew_0;	/* cylinder skew (LSB)		      */
485		uint8_t flags;		/* various */
486#define			DISK_FMT_SURF	0x10
487#define	       		DISK_FMT_RMB	0x20
488#define			DISK_FMT_HSEC	0x40
489#define			DISK_FMT_SSEC	0x80
490		uint8_t reserved21;
491		uint8_t reserved22;
492		uint8_t reserved23;
493	} format_device;
494	struct rigid_geometry_page {
495		uint8_t pg_code;	/* page code (should be 4)	      */
496#define SMS_RIGID_GEOMETRY_PAGE 0x04
497		uint8_t pg_length;	/* page length (should be 0x16)	      */
498#define SMS_RIGID_GEOMETRY_PLEN 0x16		
499		uint8_t ncyl_2;	/* number of cylinders (MSB)	      */
500		uint8_t ncyl_1;	/* number of cylinders 		      */
501		uint8_t ncyl_0;	/* number of cylinders (LSB)	      */
502		uint8_t nheads;	/* number of heads 		      */
503		uint8_t st_cyl_wp_2;	/* starting cyl., write precomp (MSB) */
504		uint8_t st_cyl_wp_1;	/* starting cyl., write precomp	      */
505		uint8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
506		uint8_t st_cyl_rwc_2;	/* starting cyl., red. write cur (MSB)*/
507		uint8_t st_cyl_rwc_1;	/* starting cyl., red. write cur      */
508		uint8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/
509		uint8_t driv_step_1;	/* drive step rate (MSB)	      */
510		uint8_t driv_step_0;	/* drive step rate (LSB)	      */
511		uint8_t land_zone_2;	/* landing zone cylinder (MSB)	      */
512		uint8_t land_zone_1;	/* landing zone cylinder 	      */
513		uint8_t land_zone_0;	/* landing zone cylinder (LSB)	      */
514		uint8_t rpl;		/* rotational position locking (2 bits) */
515		uint8_t rot_offset;	/* rotational offset */
516		uint8_t reserved19;
517		uint8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
518		uint8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */
519		uint8_t reserved22;
520		uint8_t reserved23;
521    	} rigid_geometry;
522	struct flexible_disk_page {
523		uint8_t pg_code;	/* page code (should be 5)	      */
524#define SMS_FLEXIBLE_GEOMETRY_PAGE 0x05
525		uint8_t pg_length;	/* page length (should be 0x1E)	      */
526#define SMS_FLEXIBLE_GEOMETRY_PLEN 0x1E
527		uint8_t xfr_rate_1;	/* transfer rate (MSB)		      */
528		uint8_t xfr_rate_0;	/* transfer rate (LSB)		      */
529		uint8_t nheads;	/* number of heads 		      */
530		uint8_t sec_per_track;	/* Sectors per track		      */
531		uint8_t bytes_s_1;	/* bytes per sector (MSB)	      */
532		uint8_t bytes_s_0;	/* bytes per sector (LSB)	      */
533		uint8_t ncyl_1;	/* number of cylinders (MSB)	      */
534		uint8_t ncyl_0;	/* number of cylinders (LSB)	      */
535		uint8_t st_cyl_wp_1;	/* starting cyl., write precomp (MSB) */
536		uint8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
537		uint8_t st_cyl_rwc_1;	/* starting cyl., red. write cur (MSB)*/
538		uint8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/		
539		uint8_t driv_step_1;	/* drive step rate (MSB)	      */
540		uint8_t driv_step_0;	/* drive step rate (LSB)	      */
541		uint8_t driv_step_pw;	/* drive step pulse width	      */
542		uint8_t head_stl_del_1;/* Head settle delay (MSB)	      */
543		uint8_t head_stl_del_0;/* Head settle delay (LSB)	      */
544		uint8_t motor_on_del;	/* Motor on delay		      */
545		uint8_t motor_off_del;	/* Motor off delay		      */
546		uint8_t trdy_ssn_mo;	/* XXX ??? */
547		uint8_t spc;		/* XXX ??? */
548		uint8_t write_comp;	/* Write compensation */
549		uint8_t head_load_del; /* Head load delay */
550		uint8_t head_uload_del;/* Head un-load delay */
551		uint8_t pin32_pin2;
552		uint8_t pin4_pint1;
553		uint8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
554		uint8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */		
555		uint8_t reserved30;
556		uint8_t reserved31;
557    	} flexible_disk;	
558};
559
560/*
561 * XXX KDM
562 * Here for CTL compatibility, reconcile this.
563 */
564struct scsi_format_page {
565	uint8_t page_code;
566	uint8_t page_length;
567	uint8_t tracks_per_zone[2];
568	uint8_t alt_sectors_per_zone[2];
569	uint8_t alt_tracks_per_zone[2];
570	uint8_t alt_tracks_per_lun[2];
571	uint8_t sectors_per_track[2];
572	uint8_t bytes_per_sector[2];
573	uint8_t interleave[2];
574	uint8_t track_skew[2];
575	uint8_t cylinder_skew[2];
576	uint8_t flags;
577#define	SFP_SSEC	0x80
578#define	SFP_HSEC	0x40
579#define	SFP_RMB		0x20
580#define	SFP_SURF	0x10
581	uint8_t reserved[3];
582};
583
584/*
585 * XXX KDM
586 * Here for CTL compatibility, reconcile this.
587 */
588struct scsi_rigid_disk_page {
589	uint8_t page_code;
590#define	SMS_RIGID_DISK_PAGE		0x04
591	uint8_t page_length;
592	uint8_t cylinders[3];
593	uint8_t heads;
594	uint8_t start_write_precomp[3];
595	uint8_t start_reduced_current[3];
596	uint8_t step_rate[2];
597	uint8_t landing_zone_cylinder[3];
598	uint8_t rpl;
599#define	SRDP_RPL_DISABLED	0x00
600#define	SRDP_RPL_SLAVE		0x01
601#define	SRDP_RPL_MASTER		0x02
602#define	SRDP_RPL_MASTER_CONTROL	0x03
603	uint8_t rotational_offset;
604	uint8_t reserved1;
605	uint8_t rotation_rate[2];
606	uint8_t reserved2[2];
607};
608
609struct scsi_da_rw_recovery_page {
610	uint8_t page_code;
611#define SMS_RW_ERROR_RECOVERY_PAGE	0x01
612	uint8_t page_length;
613	uint8_t byte3;
614#define SMS_RWER_AWRE			0x80
615#define SMS_RWER_ARRE			0x40
616#define SMS_RWER_TB			0x20
617#define SMS_RWER_RC			0x10
618#define SMS_RWER_EER			0x08
619#define SMS_RWER_PER			0x04
620#define SMS_RWER_DTE			0x02
621#define SMS_RWER_DCR			0x01
622	uint8_t read_retry_count;
623	uint8_t correction_span;
624	uint8_t head_offset_count;
625	uint8_t data_strobe_offset_cnt;
626	uint8_t byte8;
627#define SMS_RWER_LBPERE			0x80
628	uint8_t write_retry_count;
629	uint8_t reserved2;
630	uint8_t recovery_time_limit[2];
631};
632
633struct scsi_da_verify_recovery_page {
634	uint8_t page_code;
635#define SMS_VERIFY_ERROR_RECOVERY_PAGE	0x07
636	uint8_t page_length;
637	uint8_t byte3;
638#define SMS_VER_EER			0x08
639#define SMS_VER_PER			0x04
640#define SMS_VER_DTE			0x02
641#define SMS_VER_DCR			0x01
642	uint8_t read_retry_count;
643	uint8_t reserved[6];
644	uint8_t recovery_time_limit[2];
645};
646
647__BEGIN_DECLS
648/*
649 * XXX These are only left out of the kernel build to silence warnings.  If,
650 * for some reason these functions are used in the kernel, the ifdefs should
651 * be moved so they are included both in the kernel and userland.
652 */
653#ifndef _KERNEL
654void scsi_format_unit(struct ccb_scsiio *csio, uint32_t retries,
655		      void (*cbfcnp)(struct cam_periph *, union ccb *),
656		      uint8_t tag_action, uint8_t byte2, uint16_t ileave,
657		      uint8_t *data_ptr, uint32_t dxfer_len,
658		      uint8_t sense_len, uint32_t timeout);
659
660void scsi_read_defects(struct ccb_scsiio *csio, uint32_t retries,
661		       void (*cbfcnp)(struct cam_periph *, union ccb *),
662		       uint8_t tag_action, uint8_t list_format,
663		       uint32_t addr_desc_index, uint8_t *data_ptr,
664		       uint32_t dxfer_len, int minimum_cmd_size, 
665		       uint8_t sense_len, uint32_t timeout);
666
667void scsi_sanitize(struct ccb_scsiio *csio, uint32_t retries,
668		   void (*cbfcnp)(struct cam_periph *, union ccb *),
669		   uint8_t tag_action, uint8_t byte2, uint16_t control,
670		   uint8_t *data_ptr, uint32_t dxfer_len, uint8_t sense_len,
671		   uint32_t timeout);
672
673#endif /* !_KERNEL */
674
675void scsi_zbc_out(struct ccb_scsiio *csio, uint32_t retries, 
676		  void (*cbfcnp)(struct cam_periph *, union ccb *),
677		  uint8_t tag_action, uint8_t service_action, uint64_t zone_id,
678		  uint8_t zone_flags, uint8_t *data_ptr, uint32_t dxfer_len,
679		  uint8_t sense_len, uint32_t timeout);
680
681void scsi_zbc_in(struct ccb_scsiio *csio, uint32_t retries, 
682		 void (*cbfcnp)(struct cam_periph *, union ccb *),
683		 uint8_t tag_action, uint8_t service_action,
684		 uint64_t zone_start_lba, uint8_t zone_options,
685		 uint8_t *data_ptr, uint32_t dxfer_len, uint8_t sense_len,
686		 uint32_t timeout);
687
688int scsi_ata_zac_mgmt_out(struct ccb_scsiio *csio, uint32_t retries, 
689			  void (*cbfcnp)(struct cam_periph *, union ccb *),
690			  uint8_t tag_action, int use_ncq,
691			  uint8_t zm_action, uint64_t zone_id,
692			  uint8_t zone_flags, uint8_t *data_ptr,
693			  uint32_t dxfer_len, uint8_t *cdb_storage,
694			  size_t cdb_storage_len, uint8_t sense_len,
695			  uint32_t timeout);
696
697int scsi_ata_zac_mgmt_in(struct ccb_scsiio *csio, uint32_t retries, 
698			 void (*cbfcnp)(struct cam_periph *, union ccb *),
699			 uint8_t tag_action, int use_ncq,
700			 uint8_t zm_action, uint64_t zone_id,
701			 uint8_t zone_flags, uint8_t *data_ptr,
702			 uint32_t dxfer_len, uint8_t *cdb_storage,
703			 size_t cdb_storage_len, uint8_t sense_len,
704			 uint32_t timeout);
705
706__END_DECLS
707
708#endif /* _SCSI_SCSI_DA_H */