xref: /freebsd/sys/cam/scsi/scsi_da.h (revision 2ffd30f7ee15c87ee092cbac6a4438bcb3af923c)
176babe50SJustin T. Gibbs /*
276babe50SJustin T. Gibbs  * Structures and definitions for SCSI commands to Direct Access Devices
376babe50SJustin T. Gibbs  */
476babe50SJustin T. Gibbs 
5898b0535SWarner Losh /*-
676babe50SJustin T. Gibbs  * Some lines of this file come from a file of the name "scsi.h"
776babe50SJustin T. Gibbs  * distributed by OSF as part of mach2.5,
876babe50SJustin T. Gibbs  *  so the following disclaimer has been kept.
976babe50SJustin T. Gibbs  *
1076babe50SJustin T. Gibbs  * Copyright 1990 by Open Software Foundation,
1176babe50SJustin T. Gibbs  * Grenoble, FRANCE
1276babe50SJustin T. Gibbs  *
1376babe50SJustin T. Gibbs  * 		All Rights Reserved
1476babe50SJustin T. Gibbs  *
1576babe50SJustin T. Gibbs  *   Permission to use, copy, modify, and distribute this software and
1676babe50SJustin T. Gibbs  * its documentation for any purpose and without fee is hereby granted,
1776babe50SJustin T. Gibbs  * provided that the above copyright notice appears in all copies and
1876babe50SJustin T. Gibbs  * that both the copyright notice and this permission notice appear in
1976babe50SJustin T. Gibbs  * supporting documentation, and that the name of OSF or Open Software
2076babe50SJustin T. Gibbs  * Foundation not be used in advertising or publicity pertaining to
2176babe50SJustin T. Gibbs  * distribution of the software without specific, written prior
2276babe50SJustin T. Gibbs  * permission.
2376babe50SJustin T. Gibbs  *
2476babe50SJustin T. Gibbs  *   OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
2576babe50SJustin T. Gibbs  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
2676babe50SJustin T. Gibbs  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
2776babe50SJustin T. Gibbs  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2876babe50SJustin T. Gibbs  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
2976babe50SJustin T. Gibbs  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3076babe50SJustin T. Gibbs  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3176babe50SJustin T. Gibbs  */
3276babe50SJustin T. Gibbs 
33898b0535SWarner Losh /*-
3476babe50SJustin T. Gibbs  * Largely written by Julian Elischer (julian@tfs.com)
3576babe50SJustin T. Gibbs  * for TRW Financial Systems.
3676babe50SJustin T. Gibbs  *
3776babe50SJustin T. Gibbs  * TRW Financial Systems, in accordance with their agreement with Carnegie
3876babe50SJustin T. Gibbs  * Mellon University, makes this software available to CMU to distribute
3976babe50SJustin T. Gibbs  * or use in any manner that they see fit as long as this message is kept with
4076babe50SJustin T. Gibbs  * the software. For this reason TFS also grants any other persons or
4176babe50SJustin T. Gibbs  * organisations permission to use or modify this software.
4276babe50SJustin T. Gibbs  *
4376babe50SJustin T. Gibbs  * TFS supplies this software to be publicly redistributed
4476babe50SJustin T. Gibbs  * on the understanding that TFS is not responsible for the correct
4576babe50SJustin T. Gibbs  * functioning of this software in any circumstances.
4676babe50SJustin T. Gibbs  *
4776babe50SJustin T. Gibbs  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
4876babe50SJustin T. Gibbs  */
4976babe50SJustin T. Gibbs 
5076babe50SJustin T. Gibbs #ifndef	_SCSI_SCSI_DA_H
5176babe50SJustin T. Gibbs #define _SCSI_SCSI_DA_H 1
5276babe50SJustin T. Gibbs 
5376babe50SJustin T. Gibbs 
5476babe50SJustin T. Gibbs struct scsi_rezero_unit
5576babe50SJustin T. Gibbs {
56*7c5d20a6SWarner Losh 	uint8_t opcode;
5776babe50SJustin T. Gibbs #define SRZU_LUN_MASK 0xE0
58*7c5d20a6SWarner Losh 	uint8_t byte2;
59*7c5d20a6SWarner Losh 	uint8_t reserved[3];
60*7c5d20a6SWarner Losh 	uint8_t control;
6176babe50SJustin T. Gibbs };
6276babe50SJustin T. Gibbs 
6396a93c63SKenneth D. Merry /*
6496a93c63SKenneth D. Merry  * NOTE:  The lower three bits of byte2 of the format CDB are the same as
6596a93c63SKenneth D. Merry  * the lower three bits of byte2 of the read defect data CDB, below.
6696a93c63SKenneth D. Merry  */
6796a93c63SKenneth D. Merry struct scsi_format_unit
6896a93c63SKenneth D. Merry {
69*7c5d20a6SWarner Losh 	uint8_t opcode;
70*7c5d20a6SWarner Losh 	uint8_t byte2;
7196a93c63SKenneth D. Merry #define FU_FORMAT_MASK	SRDD10_DLIST_FORMAT_MASK
7296a93c63SKenneth D. Merry #define FU_BLOCK_FORMAT	SRDD10_BLOCK_FORMAT
7396a93c63SKenneth D. Merry #define FU_BFI_FORMAT	SRDD10_BYTES_FROM_INDEX_FORMAT
7496a93c63SKenneth D. Merry #define FU_PHYS_FORMAT	SRDD10_PHYSICAL_SECTOR_FORMAT
7596a93c63SKenneth D. Merry #define FU_CMPLST	0x08
7696a93c63SKenneth D. Merry #define FU_FMT_DATA	0x10
77*7c5d20a6SWarner Losh 	uint8_t vendor_specific;
78*7c5d20a6SWarner Losh 	uint8_t interleave[2];
79*7c5d20a6SWarner Losh 	uint8_t control;
8096a93c63SKenneth D. Merry };
8196a93c63SKenneth D. Merry 
8276babe50SJustin T. Gibbs struct scsi_reassign_blocks
8376babe50SJustin T. Gibbs {
84*7c5d20a6SWarner Losh 	uint8_t opcode;
85*7c5d20a6SWarner Losh 	uint8_t byte2;
86*7c5d20a6SWarner Losh 	uint8_t unused[3];
87*7c5d20a6SWarner Losh 	uint8_t control;
8876babe50SJustin T. Gibbs };
8976babe50SJustin T. Gibbs 
9076babe50SJustin T. Gibbs struct scsi_read_defect_data_10
9176babe50SJustin T. Gibbs {
92d70698b3SAlexander Motin 	uint8_t opcode;
93d70698b3SAlexander Motin 	uint8_t byte2;
9476babe50SJustin T. Gibbs #define SRDD10_GLIST 0x08
9576babe50SJustin T. Gibbs #define SRDD10_PLIST 0x10
9676babe50SJustin T. Gibbs #define SRDD10_DLIST_FORMAT_MASK 0x07
9776babe50SJustin T. Gibbs #define SRDD10_BLOCK_FORMAT            0x00
98a1736be3SKenneth D. Merry #define SRDD10_EXT_BFI_FORMAT 	       0x01
99a1736be3SKenneth D. Merry #define SRDD10_EXT_PHYS_FORMAT 	       0x02
100a1736be3SKenneth D. Merry #define SRDD10_LONG_BLOCK_FORMAT       0x03
10176babe50SJustin T. Gibbs #define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04
10276babe50SJustin T. Gibbs #define SRDD10_PHYSICAL_SECTOR_FORMAT  0x05
103a1736be3SKenneth D. Merry #define SRDD10_VENDOR_FORMAT	       0x06
104d70698b3SAlexander Motin 	uint8_t format;
105d70698b3SAlexander Motin 	uint8_t reserved[4];
106d70698b3SAlexander Motin 	uint8_t alloc_length[2];
1077027b9cdSKenneth D. Merry #define	SRDD10_MAX_LENGTH		0xffff
108d70698b3SAlexander Motin 	uint8_t control;
10976babe50SJustin T. Gibbs };
11076babe50SJustin T. Gibbs 
111ffead710SBryan Venteicher struct scsi_sanitize
112ffead710SBryan Venteicher {
113*7c5d20a6SWarner Losh 	uint8_t opcode;
114*7c5d20a6SWarner Losh 	uint8_t byte2;
115ffead710SBryan Venteicher #define SSZ_SERVICE_ACTION_OVERWRITE         0x01
116ffead710SBryan Venteicher #define SSZ_SERVICE_ACTION_BLOCK_ERASE       0x02
117ffead710SBryan Venteicher #define SSZ_SERVICE_ACTION_CRYPTO_ERASE      0x03
118ffead710SBryan Venteicher #define SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE 0x1F
119ffead710SBryan Venteicher #define SSZ_UNRESTRICTED_EXIT                0x20
120ffead710SBryan Venteicher #define SSZ_IMMED                            0x80
121*7c5d20a6SWarner Losh 	uint8_t reserved[5];
122*7c5d20a6SWarner Losh 	uint8_t length[2];
123*7c5d20a6SWarner Losh 	uint8_t control;
124ffead710SBryan Venteicher };
125ffead710SBryan Venteicher 
126ffead710SBryan Venteicher struct scsi_sanitize_parameter_list
127ffead710SBryan Venteicher {
128*7c5d20a6SWarner Losh 	uint8_t byte1;
129ffead710SBryan Venteicher #define SSZPL_INVERT 0x80
130*7c5d20a6SWarner Losh 	uint8_t reserved;
131*7c5d20a6SWarner Losh 	uint8_t length[2];
132ffead710SBryan Venteicher 	/* Variable length initialization pattern. */
133ffead710SBryan Venteicher #define SSZPL_MAX_PATTERN_LENGTH 65535
134ffead710SBryan Venteicher };
135ffead710SBryan Venteicher 
13676babe50SJustin T. Gibbs struct scsi_read_defect_data_12
13776babe50SJustin T. Gibbs {
138d70698b3SAlexander Motin 	uint8_t opcode;
13976babe50SJustin T. Gibbs #define SRDD12_GLIST 0x08
14076babe50SJustin T. Gibbs #define SRDD12_PLIST 0x10
14176babe50SJustin T. Gibbs #define SRDD12_DLIST_FORMAT_MASK 0x07
142a1736be3SKenneth D. Merry #define SRDD12_BLOCK_FORMAT            SRDD10_BLOCK_FORMAT
143a1736be3SKenneth D. Merry #define SRDD12_BYTES_FROM_INDEX_FORMAT SRDD10_BYTES_FROM_INDEX_FORMAT
144a1736be3SKenneth D. Merry #define SRDD12_PHYSICAL_SECTOR_FORMAT  SRDD10_PHYSICAL_SECTOR_FORMAT
145d70698b3SAlexander Motin 	uint8_t format;
146d70698b3SAlexander Motin 	uint8_t address_descriptor_index[4];
147d70698b3SAlexander Motin 	uint8_t alloc_length[4];
148a1736be3SKenneth D. Merry #define	SRDD12_MAX_LENGTH		0xffffffff
149d70698b3SAlexander Motin 	uint8_t reserved;
150d70698b3SAlexander Motin 	uint8_t control;
15176babe50SJustin T. Gibbs };
15276babe50SJustin T. Gibbs 
1539a6844d5SKenneth D. Merry struct scsi_zbc_out
1549a6844d5SKenneth D. Merry {
1559a6844d5SKenneth D. Merry 	uint8_t opcode;
1569a6844d5SKenneth D. Merry 	uint8_t service_action;
1579a6844d5SKenneth D. Merry #define	ZBC_OUT_SA_CLOSE	0x01
1589a6844d5SKenneth D. Merry #define	ZBC_OUT_SA_FINISH	0x02
1599a6844d5SKenneth D. Merry #define	ZBC_OUT_SA_OPEN		0x03
1609a6844d5SKenneth D. Merry #define	ZBC_OUT_SA_RWP		0x04
1619a6844d5SKenneth D. Merry 	uint8_t zone_id[8];
1629a6844d5SKenneth D. Merry 	uint8_t reserved[4];
1639a6844d5SKenneth D. Merry 	uint8_t zone_flags;
1649a6844d5SKenneth D. Merry #define	ZBC_OUT_ALL		0x01
1659a6844d5SKenneth D. Merry 	uint8_t control;
1669a6844d5SKenneth D. Merry };
1679a6844d5SKenneth D. Merry 
1689a6844d5SKenneth D. Merry struct scsi_zbc_in
1699a6844d5SKenneth D. Merry {
1709a6844d5SKenneth D. Merry 	uint8_t opcode;
1719a6844d5SKenneth D. Merry 	uint8_t service_action;
1729a6844d5SKenneth D. Merry #define	ZBC_IN_SA_REPORT_ZONES	0x00
1739a6844d5SKenneth D. Merry 	uint8_t zone_start_lba[8];
1749a6844d5SKenneth D. Merry 	uint8_t length[4];
1759a6844d5SKenneth D. Merry 	uint8_t zone_options;
1769a6844d5SKenneth D. Merry #define	ZBC_IN_PARTIAL		0x80
1779a6844d5SKenneth D. Merry #define	ZBC_IN_REP_ALL_ZONES	0x00
1789a6844d5SKenneth D. Merry #define	ZBC_IN_REP_EMPTY	0x01
1799a6844d5SKenneth D. Merry #define	ZBC_IN_REP_IMP_OPEN	0x02
1809a6844d5SKenneth D. Merry #define	ZBC_IN_REP_EXP_OPEN	0x03
1819a6844d5SKenneth D. Merry #define	ZBC_IN_REP_CLOSED	0x04
1829a6844d5SKenneth D. Merry #define	ZBC_IN_REP_FULL		0x05
1839a6844d5SKenneth D. Merry #define	ZBC_IN_REP_READONLY	0x06
1849a6844d5SKenneth D. Merry #define	ZBC_IN_REP_OFFLINE	0x07
1859a6844d5SKenneth D. Merry #define	ZBC_IN_REP_RESET	0x10
1869a6844d5SKenneth D. Merry #define	ZBC_IN_REP_NON_SEQ	0x11
1879a6844d5SKenneth D. Merry #define	ZBC_IN_REP_NON_WP	0x3f
1889a6844d5SKenneth D. Merry #define	ZBC_IN_REP_MASK		0x3f
1899a6844d5SKenneth D. Merry 	uint8_t control;
1909a6844d5SKenneth D. Merry };
1919a6844d5SKenneth D. Merry 
1929a6844d5SKenneth D. Merry struct scsi_report_zones_desc {
1939a6844d5SKenneth D. Merry 	uint8_t zone_type;
1949a6844d5SKenneth D. Merry #define	SRZ_TYPE_CONVENTIONAL	0x01
1959a6844d5SKenneth D. Merry #define	SRZ_TYPE_SEQ_REQUIRED	0x02
1969a6844d5SKenneth D. Merry #define	SRZ_TYPE_SEQ_PREFERRED	0x03
1979a6844d5SKenneth D. Merry #define	SRZ_TYPE_MASK		0x0f
1989a6844d5SKenneth D. Merry 	uint8_t zone_flags;
1999a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_SHIFT	4
2009a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_MASK	0xf0
2019a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_NWP	0x00
2029a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_EMPTY	0x10
2039a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_IMP_OPEN	0x20
2049a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_EXP_OPEN	0x30
2059a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_CLOSED	0x40
2069a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_READONLY	0xd0
2079a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_FULL	0xe0
2089a6844d5SKenneth D. Merry #define	SRZ_ZONE_COND_OFFLINE	0xf0
2099a6844d5SKenneth D. Merry #define	SRZ_ZONE_NON_SEQ	0x02
2109a6844d5SKenneth D. Merry #define	SRZ_ZONE_RESET		0x01
2119a6844d5SKenneth D. Merry 	uint8_t reserved[6];
2129a6844d5SKenneth D. Merry 	uint8_t zone_length[8];
2139a6844d5SKenneth D. Merry 	uint8_t zone_start_lba[8];
2149a6844d5SKenneth D. Merry 	uint8_t write_pointer_lba[8];
2159a6844d5SKenneth D. Merry 	uint8_t reserved2[32];
2169a6844d5SKenneth D. Merry };
2179a6844d5SKenneth D. Merry 
2189a6844d5SKenneth D. Merry struct scsi_report_zones_hdr {
2199a6844d5SKenneth D. Merry 	uint8_t length[4];
2209a6844d5SKenneth D. Merry 	uint8_t byte4;
2219a6844d5SKenneth D. Merry #define	SRZ_SAME_ALL_DIFFERENT	 0x00 /* Lengths and types vary */
2229a6844d5SKenneth D. Merry #define	SRZ_SAME_ALL_SAME	 0x01 /* Lengths and types the same */
2239a6844d5SKenneth D. Merry #define	SRZ_SAME_LAST_DIFFERENT	 0x02 /* Types same, last length varies */
2249a6844d5SKenneth D. Merry #define SRZ_SAME_TYPES_DIFFERENT 0x03 /* Types vary, length the same */
2259a6844d5SKenneth D. Merry #define	SRZ_SAME_MASK		 0x0f
2269a6844d5SKenneth D. Merry 	uint8_t reserved[3];
2279a6844d5SKenneth D. Merry 	uint8_t maximum_lba[8];
2289a6844d5SKenneth D. Merry 	uint8_t reserved2[48];
2299a6844d5SKenneth D. Merry 	struct scsi_report_zones_desc desc_list[];
2309a6844d5SKenneth D. Merry };
23176babe50SJustin T. Gibbs 
23276babe50SJustin T. Gibbs /*
23376babe50SJustin T. Gibbs  * Opcodes
23476babe50SJustin T. Gibbs  */
23576babe50SJustin T. Gibbs #define REZERO_UNIT		0x01
23696a93c63SKenneth D. Merry #define FORMAT_UNIT		0x04
23776babe50SJustin T. Gibbs #define	REASSIGN_BLOCKS		0x07
23876babe50SJustin T. Gibbs #define MODE_SELECT		0x15
23976babe50SJustin T. Gibbs #define MODE_SENSE		0x1a
240c68a9309SBruce M Simpson #define	READ_FORMAT_CAPACITIES	0x23
241c68a9309SBruce M Simpson #define	WRITE_AND_VERIFY	0x2e
242c68a9309SBruce M Simpson #define	VERIFY			0x2f
24376babe50SJustin T. Gibbs #define READ_DEFECT_DATA_10	0x37
244ffead710SBryan Venteicher #define SANITIZE		0x48
2459a6844d5SKenneth D. Merry #define	ZBC_OUT			0x94
2469a6844d5SKenneth D. Merry #define	ZBC_IN			0x95
24776babe50SJustin T. Gibbs #define READ_DEFECT_DATA_12	0xb7
24876babe50SJustin T. Gibbs 
24996a93c63SKenneth D. Merry struct format_defect_list_header
25096a93c63SKenneth D. Merry {
251*7c5d20a6SWarner Losh 	uint8_t reserved;
252*7c5d20a6SWarner Losh 	uint8_t byte2;
25396a93c63SKenneth D. Merry #define FU_DLH_VS	0x01
25496a93c63SKenneth D. Merry #define FU_DLH_IMMED	0x02
25596a93c63SKenneth D. Merry #define FU_DLH_DSP	0x04
25696a93c63SKenneth D. Merry #define FU_DLH_IP	0x08
25796a93c63SKenneth D. Merry #define FU_DLH_STPF	0x10
25896a93c63SKenneth D. Merry #define FU_DLH_DCRT	0x20
25996a93c63SKenneth D. Merry #define FU_DLH_DPRY	0x40
26096a93c63SKenneth D. Merry #define FU_DLH_FOV	0x80
261*7c5d20a6SWarner Losh 	uint8_t defect_list_length[2];
26296a93c63SKenneth D. Merry };
26396a93c63SKenneth D. Merry 
26496a93c63SKenneth D. Merry struct format_ipat_descriptor
26596a93c63SKenneth D. Merry {
266*7c5d20a6SWarner Losh 	uint8_t byte1;
26796a93c63SKenneth D. Merry #define	FU_INIT_NO_HDR		0x00
26896a93c63SKenneth D. Merry #define FU_INIT_LBA_MSB		0x40
26996a93c63SKenneth D. Merry #define FU_INIT_LBA_EACH	0x80
27096a93c63SKenneth D. Merry #define FU_INIT_SI		0x20
271*7c5d20a6SWarner Losh 	uint8_t pattern_type;
27296a93c63SKenneth D. Merry #define FU_INIT_PAT_DEFAULT	0x00
27396a93c63SKenneth D. Merry #define FU_INIT_PAT_REPEAT	0x01
274*7c5d20a6SWarner Losh 	uint8_t pat_length[2];
27596a93c63SKenneth D. Merry };
27676babe50SJustin T. Gibbs 
277c68a9309SBruce M Simpson struct scsi_read_format_capacities
278c68a9309SBruce M Simpson {
279c68a9309SBruce M Simpson 	uint8_t	opcode;		/* READ_FORMAT_CAPACITIES */
28023e0012dSBruce M Simpson 	uint8_t	byte2;
281c68a9309SBruce M Simpson #define	SRFC_LUN_MASK	0xE0
282c68a9309SBruce M Simpson 	uint8_t	reserved0[5];
283c68a9309SBruce M Simpson 	uint8_t	alloc_length[2];
284c68a9309SBruce M Simpson 	uint8_t	reserved1[3];
285c68a9309SBruce M Simpson };
286c68a9309SBruce M Simpson 
28711b569f7SAlexander Motin struct scsi_verify_10
288c68a9309SBruce M Simpson {
28911b569f7SAlexander Motin 	uint8_t	opcode;		/* VERIFY(10) */
29023e0012dSBruce M Simpson 	uint8_t	byte2;
29123e0012dSBruce M Simpson #define	SVFY_LUN_MASK	0xE0
292c68a9309SBruce M Simpson #define	SVFY_RELADR	0x01
29311b569f7SAlexander Motin #define	SVFY_BYTCHK	0x02
294c68a9309SBruce M Simpson #define	SVFY_DPO	0x10
295c68a9309SBruce M Simpson 	uint8_t	addr[4];	/* LBA to begin verification at */
29611b569f7SAlexander Motin 	uint8_t	group;
29711b569f7SAlexander Motin 	uint8_t	length[2];		/* number of blocks to verify */
29811b569f7SAlexander Motin 	uint8_t	control;
29911b569f7SAlexander Motin };
30011b569f7SAlexander Motin 
30111b569f7SAlexander Motin struct scsi_verify_12
30211b569f7SAlexander Motin {
30311b569f7SAlexander Motin 	uint8_t	opcode;		/* VERIFY(12) */
30411b569f7SAlexander Motin 	uint8_t	byte2;
30511b569f7SAlexander Motin 	uint8_t	addr[4];	/* LBA to begin verification at */
30611b569f7SAlexander Motin 	uint8_t	length[4];		/* number of blocks to verify */
30711b569f7SAlexander Motin 	uint8_t	group;
30811b569f7SAlexander Motin 	uint8_t	control;
30911b569f7SAlexander Motin };
31011b569f7SAlexander Motin 
31111b569f7SAlexander Motin struct scsi_verify_16
31211b569f7SAlexander Motin {
31311b569f7SAlexander Motin 	uint8_t	opcode;		/* VERIFY(16) */
31411b569f7SAlexander Motin 	uint8_t	byte2;
31511b569f7SAlexander Motin 	uint8_t	addr[8];	/* LBA to begin verification at */
31611b569f7SAlexander Motin 	uint8_t	length[4];		/* number of blocks to verify */
31711b569f7SAlexander Motin 	uint8_t	group;
31811b569f7SAlexander Motin 	uint8_t	control;
31911b569f7SAlexander Motin };
32011b569f7SAlexander Motin 
32111b569f7SAlexander Motin struct scsi_compare_and_write
32211b569f7SAlexander Motin {
32311b569f7SAlexander Motin 	uint8_t	opcode;		/* COMPARE AND WRITE */
32411b569f7SAlexander Motin 	uint8_t	byte2;
32511b569f7SAlexander Motin 	uint8_t	addr[8];	/* LBA to begin verification at */
32611b569f7SAlexander Motin 	uint8_t	reserved[3];
32711b569f7SAlexander Motin 	uint8_t	length;		/* number of blocks */
32811b569f7SAlexander Motin 	uint8_t	group;
32911b569f7SAlexander Motin 	uint8_t	control;
330c68a9309SBruce M Simpson };
331c68a9309SBruce M Simpson 
332c68a9309SBruce M Simpson struct scsi_write_and_verify
333c68a9309SBruce M Simpson {
334c68a9309SBruce M Simpson 	uint8_t	opcode;		/* WRITE_AND_VERIFY */
33523e0012dSBruce M Simpson 	uint8_t	byte2;
336c68a9309SBruce M Simpson #define	SWVY_LUN_MASK	0xE0
337c68a9309SBruce M Simpson #define	SWVY_RELADR	0x01
338c68a9309SBruce M Simpson #define	SWVY_BYTECHK	0x02
339c68a9309SBruce M Simpson #define	SWVY_DPO	0x10
340c68a9309SBruce M Simpson 	uint8_t	addr[4];	/* LBA to begin verification at */
341c68a9309SBruce M Simpson 	uint8_t	reserved0[1];
342c68a9309SBruce M Simpson 	uint8_t	len[2];		/* number of blocks to write and verify */
343c68a9309SBruce M Simpson 	uint8_t	reserved1[3];
344c68a9309SBruce M Simpson };
345c68a9309SBruce M Simpson 
346c68a9309SBruce M Simpson /*
347c68a9309SBruce M Simpson  * Replies to READ_FORMAT_CAPACITIES look like this:
348c68a9309SBruce M Simpson  *
349c68a9309SBruce M Simpson  * struct format_capacity_list_header
350c68a9309SBruce M Simpson  * struct format_capacity_descriptor[1..n]
351c68a9309SBruce M Simpson  *
352c68a9309SBruce M Simpson  * These are similar, but not totally identical to, the
353c68a9309SBruce M Simpson  * defect list used to format a rigid disk.
354c68a9309SBruce M Simpson  *
355c68a9309SBruce M Simpson  * The appropriate csio_decode() format string looks like this:
356c68a9309SBruce M Simpson  * "{} *i3 {Len} i1 {Blocks} i4 {} *b6 {Code} b2 {Blocklen} i3"
357c68a9309SBruce M Simpson  *
358c68a9309SBruce M Simpson  * If the capacity_list_length is greater than
359c68a9309SBruce M Simpson  * sizeof(struct format_capacity_descriptor), then there are
360c68a9309SBruce M Simpson  * additional format capacity descriptors available which
361c68a9309SBruce M Simpson  * denote which format(s) the drive can handle.
362c68a9309SBruce M Simpson  *
363c68a9309SBruce M Simpson  * (Source: USB Mass Storage UFI Specification)
364c68a9309SBruce M Simpson  */
365c68a9309SBruce M Simpson 
366c68a9309SBruce M Simpson struct format_capacity_list_header {
367c68a9309SBruce M Simpson 	uint8_t	unused[3];
368c68a9309SBruce M Simpson 	uint8_t	capacity_list_length;
369c68a9309SBruce M Simpson };
370c68a9309SBruce M Simpson 
371c68a9309SBruce M Simpson struct format_capacity_descriptor {
372c68a9309SBruce M Simpson 	uint8_t	nblocks[4];	/* total number of LBAs */
373c68a9309SBruce M Simpson 	uint8_t	byte4;		/* only present in max/cur descriptor */
374c68a9309SBruce M Simpson #define FCD_CODE_MASK	0x03	/* mask for code field above */
375c68a9309SBruce M Simpson #define FCD_UNFORMATTED	0x01	/* unformatted media present,
376c68a9309SBruce M Simpson 				 * maximum capacity returned */
377c68a9309SBruce M Simpson #define FCD_FORMATTED	0x02	/* formatted media present,
378c68a9309SBruce M Simpson 				 * current capacity returned */
379c68a9309SBruce M Simpson #define FCD_NOMEDIA	0x03	/* no media present,
380c68a9309SBruce M Simpson 				 * maximum device capacity returned */
381c68a9309SBruce M Simpson 	uint8_t	block_length[3];	/* length of an LBA in bytes */
382c68a9309SBruce M Simpson };
383c68a9309SBruce M Simpson 
38476babe50SJustin T. Gibbs struct scsi_reassign_blocks_data
38576babe50SJustin T. Gibbs {
386*7c5d20a6SWarner Losh 	uint8_t reserved[2];
387*7c5d20a6SWarner Losh 	uint8_t length[2];
38876babe50SJustin T. Gibbs 	struct {
389*7c5d20a6SWarner Losh 		uint8_t dlbaddr[4];	/* defect logical block address */
39076babe50SJustin T. Gibbs 	} defect_descriptor[1];
39176babe50SJustin T. Gibbs };
39276babe50SJustin T. Gibbs 
39376babe50SJustin T. Gibbs /*
39476babe50SJustin T. Gibbs  * This is the list header for the READ DEFECT DATA(10) command above.
39576babe50SJustin T. Gibbs  * It may be a bit wrong to append the 10 at the end of the data structure,
39676babe50SJustin T. Gibbs  * since it's only 4 bytes but it does tie it to the 10 byte command.
39776babe50SJustin T. Gibbs  */
39876babe50SJustin T. Gibbs struct scsi_read_defect_data_hdr_10
39976babe50SJustin T. Gibbs {
400*7c5d20a6SWarner Losh 	uint8_t reserved;
40176babe50SJustin T. Gibbs #define SRDDH10_GLIST 0x08
40276babe50SJustin T. Gibbs #define SRDDH10_PLIST 0x10
40376babe50SJustin T. Gibbs #define SRDDH10_DLIST_FORMAT_MASK 0x07
40476babe50SJustin T. Gibbs #define SRDDH10_BLOCK_FORMAT            0x00
40576babe50SJustin T. Gibbs #define SRDDH10_BYTES_FROM_INDEX_FORMAT 0x04
40676babe50SJustin T. Gibbs #define SRDDH10_PHYSICAL_SECTOR_FORMAT  0x05
407*7c5d20a6SWarner Losh 	uint8_t format;
408*7c5d20a6SWarner Losh 	uint8_t length[2];
409a1736be3SKenneth D. Merry #define	SRDDH10_MAX_LENGTH	SRDD10_MAX_LENGTH -			     \
410a1736be3SKenneth D. Merry 				sizeof(struct scsi_read_defect_data_hdr_10)
41176babe50SJustin T. Gibbs };
41276babe50SJustin T. Gibbs 
41376babe50SJustin T. Gibbs struct scsi_defect_desc_block
41476babe50SJustin T. Gibbs {
415*7c5d20a6SWarner Losh 	uint8_t address[4];
41676babe50SJustin T. Gibbs };
41776babe50SJustin T. Gibbs 
418a1736be3SKenneth D. Merry struct scsi_defect_desc_long_block
419a1736be3SKenneth D. Merry {
420*7c5d20a6SWarner Losh 	uint8_t address[8];
421a1736be3SKenneth D. Merry };
422a1736be3SKenneth D. Merry 
42376babe50SJustin T. Gibbs struct scsi_defect_desc_bytes_from_index
42476babe50SJustin T. Gibbs {
425*7c5d20a6SWarner Losh 	uint8_t cylinder[3];
426*7c5d20a6SWarner Losh 	uint8_t head;
427a1736be3SKenneth D. Merry #define	SDD_EXT_BFI_MADS		0x80000000
428a1736be3SKenneth D. Merry #define	SDD_EXT_BFI_FLAG_MASK		0xf0000000
429a1736be3SKenneth D. Merry #define	SDD_EXT_BFI_ENTIRE_TRACK	0x0fffffff
430*7c5d20a6SWarner Losh 	uint8_t bytes_from_index[4];
43176babe50SJustin T. Gibbs };
43276babe50SJustin T. Gibbs 
43376babe50SJustin T. Gibbs struct scsi_defect_desc_phys_sector
43476babe50SJustin T. Gibbs {
435*7c5d20a6SWarner Losh 	uint8_t cylinder[3];
436*7c5d20a6SWarner Losh 	uint8_t head;
437a1736be3SKenneth D. Merry #define	SDD_EXT_PHYS_MADS		0x80000000
438a1736be3SKenneth D. Merry #define	SDD_EXT_PHYS_FLAG_MASK		0xf0000000
439a1736be3SKenneth D. Merry #define	SDD_EXT_PHYS_ENTIRE_TRACK	0x0fffffff
440*7c5d20a6SWarner Losh 	uint8_t sector[4];
44176babe50SJustin T. Gibbs };
44276babe50SJustin T. Gibbs 
44376babe50SJustin T. Gibbs struct scsi_read_defect_data_hdr_12
44476babe50SJustin T. Gibbs {
445*7c5d20a6SWarner Losh 	uint8_t reserved;
44676babe50SJustin T. Gibbs #define SRDDH12_GLIST 0x08
44776babe50SJustin T. Gibbs #define SRDDH12_PLIST 0x10
44876babe50SJustin T. Gibbs #define SRDDH12_DLIST_FORMAT_MASK 0x07
44976babe50SJustin T. Gibbs #define SRDDH12_BLOCK_FORMAT            0x00
45076babe50SJustin T. Gibbs #define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04
45176babe50SJustin T. Gibbs #define SRDDH12_PHYSICAL_SECTOR_FORMAT  0x05
452*7c5d20a6SWarner Losh 	uint8_t format;
453*7c5d20a6SWarner Losh 	uint8_t generation[2];
454*7c5d20a6SWarner Losh 	uint8_t length[4];
455a1736be3SKenneth D. Merry #define	SRDDH12_MAX_LENGTH	SRDD12_MAX_LENGTH -			    \
456a1736be3SKenneth D. Merry 				sizeof(struct scsi_read_defect_data_hdr_12)
45776babe50SJustin T. Gibbs };
45876babe50SJustin T. Gibbs 
45976babe50SJustin T. Gibbs union	disk_pages /* this is the structure copied from osf */
46076babe50SJustin T. Gibbs {
46176babe50SJustin T. Gibbs 	struct format_device_page {
462*7c5d20a6SWarner Losh 		uint8_t pg_code;	/* page code (should be 3)	      */
46376babe50SJustin T. Gibbs #define	SMS_FORMAT_DEVICE_PAGE	0x03	/* only 6 bits valid */
464*7c5d20a6SWarner Losh 		uint8_t pg_length;	/* page length (should be 0x16)	      */
46576babe50SJustin T. Gibbs #define	SMS_FORMAT_DEVICE_PLEN	0x16
466*7c5d20a6SWarner Losh 		uint8_t trk_z_1;	/* tracks per zone (MSB)	      */
467*7c5d20a6SWarner Losh 		uint8_t trk_z_0;	/* tracks per zone (LSB)	      */
468*7c5d20a6SWarner Losh 		uint8_t alt_sec_1;	/* alternate sectors per zone (MSB)   */
469*7c5d20a6SWarner Losh 		uint8_t alt_sec_0;	/* alternate sectors per zone (LSB)   */
470*7c5d20a6SWarner Losh 		uint8_t alt_trk_z_1;	/* alternate tracks per zone (MSB)    */
471*7c5d20a6SWarner Losh 		uint8_t alt_trk_z_0;	/* alternate tracks per zone (LSB)    */
472*7c5d20a6SWarner Losh 		uint8_t alt_trk_v_1;	/* alternate tracks per volume (MSB)  */
473*7c5d20a6SWarner Losh 		uint8_t alt_trk_v_0;	/* alternate tracks per volume (LSB)  */
474*7c5d20a6SWarner Losh 		uint8_t ph_sec_t_1;	/* physical sectors per track (MSB)   */
475*7c5d20a6SWarner Losh 		uint8_t ph_sec_t_0;	/* physical sectors per track (LSB)   */
476*7c5d20a6SWarner Losh 		uint8_t bytes_s_1;	/* bytes per sector (MSB)	      */
477*7c5d20a6SWarner Losh 		uint8_t bytes_s_0;	/* bytes per sector (LSB)	      */
478*7c5d20a6SWarner Losh 		uint8_t interleave_1;	/* interleave (MSB)		      */
479*7c5d20a6SWarner Losh 		uint8_t interleave_0;	/* interleave (LSB)		      */
480*7c5d20a6SWarner Losh 		uint8_t trk_skew_1;	/* track skew factor (MSB)	      */
481*7c5d20a6SWarner Losh 		uint8_t trk_skew_0;	/* track skew factor (LSB)	      */
482*7c5d20a6SWarner Losh 		uint8_t cyl_skew_1;	/* cylinder skew (MSB)		      */
483*7c5d20a6SWarner Losh 		uint8_t cyl_skew_0;	/* cylinder skew (LSB)		      */
484*7c5d20a6SWarner Losh 		uint8_t flags;		/* various */
48576babe50SJustin T. Gibbs #define			DISK_FMT_SURF	0x10
48676babe50SJustin T. Gibbs #define	       		DISK_FMT_RMB	0x20
48776babe50SJustin T. Gibbs #define			DISK_FMT_HSEC	0x40
48876babe50SJustin T. Gibbs #define			DISK_FMT_SSEC	0x80
489*7c5d20a6SWarner Losh 		uint8_t reserved21;
490*7c5d20a6SWarner Losh 		uint8_t reserved22;
491*7c5d20a6SWarner Losh 		uint8_t reserved23;
49276babe50SJustin T. Gibbs 	} format_device;
49376babe50SJustin T. Gibbs 	struct rigid_geometry_page {
494*7c5d20a6SWarner Losh 		uint8_t pg_code;	/* page code (should be 4)	      */
49576babe50SJustin T. Gibbs #define SMS_RIGID_GEOMETRY_PAGE 0x04
496*7c5d20a6SWarner Losh 		uint8_t pg_length;	/* page length (should be 0x16)	      */
49776babe50SJustin T. Gibbs #define SMS_RIGID_GEOMETRY_PLEN 0x16
498*7c5d20a6SWarner Losh 		uint8_t ncyl_2;	/* number of cylinders (MSB)	      */
499*7c5d20a6SWarner Losh 		uint8_t ncyl_1;	/* number of cylinders 		      */
500*7c5d20a6SWarner Losh 		uint8_t ncyl_0;	/* number of cylinders (LSB)	      */
501*7c5d20a6SWarner Losh 		uint8_t nheads;	/* number of heads 		      */
502*7c5d20a6SWarner Losh 		uint8_t st_cyl_wp_2;	/* starting cyl., write precomp (MSB) */
503*7c5d20a6SWarner Losh 		uint8_t st_cyl_wp_1;	/* starting cyl., write precomp	      */
504*7c5d20a6SWarner Losh 		uint8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
505*7c5d20a6SWarner Losh 		uint8_t st_cyl_rwc_2;	/* starting cyl., red. write cur (MSB)*/
506*7c5d20a6SWarner Losh 		uint8_t st_cyl_rwc_1;	/* starting cyl., red. write cur      */
507*7c5d20a6SWarner Losh 		uint8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/
508*7c5d20a6SWarner Losh 		uint8_t driv_step_1;	/* drive step rate (MSB)	      */
509*7c5d20a6SWarner Losh 		uint8_t driv_step_0;	/* drive step rate (LSB)	      */
510*7c5d20a6SWarner Losh 		uint8_t land_zone_2;	/* landing zone cylinder (MSB)	      */
511*7c5d20a6SWarner Losh 		uint8_t land_zone_1;	/* landing zone cylinder 	      */
512*7c5d20a6SWarner Losh 		uint8_t land_zone_0;	/* landing zone cylinder (LSB)	      */
513*7c5d20a6SWarner Losh 		uint8_t rpl;		/* rotational position locking (2 bits) */
514*7c5d20a6SWarner Losh 		uint8_t rot_offset;	/* rotational offset */
515*7c5d20a6SWarner Losh 		uint8_t reserved19;
516*7c5d20a6SWarner Losh 		uint8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
517*7c5d20a6SWarner Losh 		uint8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */
518*7c5d20a6SWarner Losh 		uint8_t reserved22;
519*7c5d20a6SWarner Losh 		uint8_t reserved23;
52076babe50SJustin T. Gibbs     	} rigid_geometry;
52176babe50SJustin T. Gibbs 	struct flexible_disk_page {
522*7c5d20a6SWarner Losh 		uint8_t pg_code;	/* page code (should be 5)	      */
52376babe50SJustin T. Gibbs #define SMS_FLEXIBLE_GEOMETRY_PAGE 0x05
524*7c5d20a6SWarner Losh 		uint8_t pg_length;	/* page length (should be 0x1E)	      */
5250cdabce0SNick Hibma #define SMS_FLEXIBLE_GEOMETRY_PLEN 0x1E
526*7c5d20a6SWarner Losh 		uint8_t xfr_rate_1;	/* transfer rate (MSB)		      */
527*7c5d20a6SWarner Losh 		uint8_t xfr_rate_0;	/* transfer rate (LSB)		      */
528*7c5d20a6SWarner Losh 		uint8_t nheads;	/* number of heads 		      */
529*7c5d20a6SWarner Losh 		uint8_t sec_per_track;	/* Sectors per track		      */
530*7c5d20a6SWarner Losh 		uint8_t bytes_s_1;	/* bytes per sector (MSB)	      */
531*7c5d20a6SWarner Losh 		uint8_t bytes_s_0;	/* bytes per sector (LSB)	      */
532*7c5d20a6SWarner Losh 		uint8_t ncyl_1;	/* number of cylinders (MSB)	      */
533*7c5d20a6SWarner Losh 		uint8_t ncyl_0;	/* number of cylinders (LSB)	      */
534*7c5d20a6SWarner Losh 		uint8_t st_cyl_wp_1;	/* starting cyl., write precomp (MSB) */
535*7c5d20a6SWarner Losh 		uint8_t st_cyl_wp_0;	/* starting cyl., write precomp (LSB) */
536*7c5d20a6SWarner Losh 		uint8_t st_cyl_rwc_1;	/* starting cyl., red. write cur (MSB)*/
537*7c5d20a6SWarner Losh 		uint8_t st_cyl_rwc_0;	/* starting cyl., red. write cur (LSB)*/
538*7c5d20a6SWarner Losh 		uint8_t driv_step_1;	/* drive step rate (MSB)	      */
539*7c5d20a6SWarner Losh 		uint8_t driv_step_0;	/* drive step rate (LSB)	      */
540*7c5d20a6SWarner Losh 		uint8_t driv_step_pw;	/* drive step pulse width	      */
541*7c5d20a6SWarner Losh 		uint8_t head_stl_del_1;/* Head settle delay (MSB)	      */
542*7c5d20a6SWarner Losh 		uint8_t head_stl_del_0;/* Head settle delay (LSB)	      */
543*7c5d20a6SWarner Losh 		uint8_t motor_on_del;	/* Motor on delay		      */
544*7c5d20a6SWarner Losh 		uint8_t motor_off_del;	/* Motor off delay		      */
545*7c5d20a6SWarner Losh 		uint8_t trdy_ssn_mo;	/* XXX ??? */
546*7c5d20a6SWarner Losh 		uint8_t spc;		/* XXX ??? */
547*7c5d20a6SWarner Losh 		uint8_t write_comp;	/* Write compensation */
548*7c5d20a6SWarner Losh 		uint8_t head_load_del; /* Head load delay */
549*7c5d20a6SWarner Losh 		uint8_t head_uload_del;/* Head un-load delay */
550*7c5d20a6SWarner Losh 		uint8_t pin32_pin2;
551*7c5d20a6SWarner Losh 		uint8_t pin4_pint1;
552*7c5d20a6SWarner Losh 		uint8_t medium_rot_rate_1; /* medium rotation rate (RPM) (MSB) */
553*7c5d20a6SWarner Losh 		uint8_t medium_rot_rate_0; /* medium rotation rate (RPM) (LSB) */
554*7c5d20a6SWarner Losh 		uint8_t reserved30;
555*7c5d20a6SWarner Losh 		uint8_t reserved31;
55676babe50SJustin T. Gibbs     	} flexible_disk;
55776babe50SJustin T. Gibbs };
55876babe50SJustin T. Gibbs 
559130f4520SKenneth D. Merry /*
560130f4520SKenneth D. Merry  * XXX KDM
561130f4520SKenneth D. Merry  * Here for CTL compatibility, reconcile this.
562130f4520SKenneth D. Merry  */
563130f4520SKenneth D. Merry struct scsi_format_page {
564130f4520SKenneth D. Merry 	uint8_t page_code;
565130f4520SKenneth D. Merry 	uint8_t page_length;
566130f4520SKenneth D. Merry 	uint8_t tracks_per_zone[2];
567130f4520SKenneth D. Merry 	uint8_t alt_sectors_per_zone[2];
568130f4520SKenneth D. Merry 	uint8_t alt_tracks_per_zone[2];
569130f4520SKenneth D. Merry 	uint8_t alt_tracks_per_lun[2];
570130f4520SKenneth D. Merry 	uint8_t sectors_per_track[2];
571130f4520SKenneth D. Merry 	uint8_t bytes_per_sector[2];
572130f4520SKenneth D. Merry 	uint8_t interleave[2];
573130f4520SKenneth D. Merry 	uint8_t track_skew[2];
574130f4520SKenneth D. Merry 	uint8_t cylinder_skew[2];
575130f4520SKenneth D. Merry 	uint8_t flags;
576130f4520SKenneth D. Merry #define	SFP_SSEC	0x80
577130f4520SKenneth D. Merry #define	SFP_HSEC	0x40
578130f4520SKenneth D. Merry #define	SFP_RMB		0x20
579130f4520SKenneth D. Merry #define	SFP_SURF	0x10
580130f4520SKenneth D. Merry 	uint8_t reserved[3];
581130f4520SKenneth D. Merry };
582130f4520SKenneth D. Merry 
583130f4520SKenneth D. Merry /*
584130f4520SKenneth D. Merry  * XXX KDM
585130f4520SKenneth D. Merry  * Here for CTL compatibility, reconcile this.
586130f4520SKenneth D. Merry  */
587130f4520SKenneth D. Merry struct scsi_rigid_disk_page {
588130f4520SKenneth D. Merry 	uint8_t page_code;
589130f4520SKenneth D. Merry #define	SMS_RIGID_DISK_PAGE		0x04
590130f4520SKenneth D. Merry 	uint8_t page_length;
591130f4520SKenneth D. Merry 	uint8_t cylinders[3];
592130f4520SKenneth D. Merry 	uint8_t heads;
593130f4520SKenneth D. Merry 	uint8_t start_write_precomp[3];
594130f4520SKenneth D. Merry 	uint8_t start_reduced_current[3];
595130f4520SKenneth D. Merry 	uint8_t step_rate[2];
596130f4520SKenneth D. Merry 	uint8_t landing_zone_cylinder[3];
597130f4520SKenneth D. Merry 	uint8_t rpl;
598130f4520SKenneth D. Merry #define	SRDP_RPL_DISABLED	0x00
599130f4520SKenneth D. Merry #define	SRDP_RPL_SLAVE		0x01
600130f4520SKenneth D. Merry #define	SRDP_RPL_MASTER		0x02
601130f4520SKenneth D. Merry #define	SRDP_RPL_MASTER_CONTROL	0x03
602130f4520SKenneth D. Merry 	uint8_t rotational_offset;
603130f4520SKenneth D. Merry 	uint8_t reserved1;
604130f4520SKenneth D. Merry 	uint8_t rotation_rate[2];
605130f4520SKenneth D. Merry 	uint8_t reserved2[2];
606130f4520SKenneth D. Merry };
607130f4520SKenneth D. Merry 
60876babe50SJustin T. Gibbs struct scsi_da_rw_recovery_page {
609*7c5d20a6SWarner Losh 	uint8_t page_code;
61076babe50SJustin T. Gibbs #define SMS_RW_ERROR_RECOVERY_PAGE	0x01
611*7c5d20a6SWarner Losh 	uint8_t page_length;
612*7c5d20a6SWarner Losh 	uint8_t byte3;
61376babe50SJustin T. Gibbs #define SMS_RWER_AWRE			0x80
61476babe50SJustin T. Gibbs #define SMS_RWER_ARRE			0x40
61576babe50SJustin T. Gibbs #define SMS_RWER_TB			0x20
61676babe50SJustin T. Gibbs #define SMS_RWER_RC			0x10
61776babe50SJustin T. Gibbs #define SMS_RWER_EER			0x08
61876babe50SJustin T. Gibbs #define SMS_RWER_PER			0x04
61976babe50SJustin T. Gibbs #define SMS_RWER_DTE			0x02
62076babe50SJustin T. Gibbs #define SMS_RWER_DCR			0x01
621*7c5d20a6SWarner Losh 	uint8_t read_retry_count;
622*7c5d20a6SWarner Losh 	uint8_t correction_span;
623*7c5d20a6SWarner Losh 	uint8_t head_offset_count;
624*7c5d20a6SWarner Losh 	uint8_t data_strobe_offset_cnt;
625*7c5d20a6SWarner Losh 	uint8_t byte8;
626ec05088bSAlexander Motin #define SMS_RWER_LBPERE			0x80
627*7c5d20a6SWarner Losh 	uint8_t write_retry_count;
628*7c5d20a6SWarner Losh 	uint8_t reserved2;
629*7c5d20a6SWarner Losh 	uint8_t recovery_time_limit[2];
63076babe50SJustin T. Gibbs };
63176babe50SJustin T. Gibbs 
632d9ba4eefSAlexander Motin struct scsi_da_verify_recovery_page {
633*7c5d20a6SWarner Losh 	uint8_t page_code;
634d9ba4eefSAlexander Motin #define SMS_VERIFY_ERROR_RECOVERY_PAGE	0x07
635*7c5d20a6SWarner Losh 	uint8_t page_length;
636*7c5d20a6SWarner Losh 	uint8_t byte3;
637d9ba4eefSAlexander Motin #define SMS_VER_EER			0x08
638d9ba4eefSAlexander Motin #define SMS_VER_PER			0x04
639d9ba4eefSAlexander Motin #define SMS_VER_DTE			0x02
640d9ba4eefSAlexander Motin #define SMS_VER_DCR			0x01
641*7c5d20a6SWarner Losh 	uint8_t read_retry_count;
642*7c5d20a6SWarner Losh 	uint8_t reserved[6];
643*7c5d20a6SWarner Losh 	uint8_t recovery_time_limit[2];
644d9ba4eefSAlexander Motin };
645d9ba4eefSAlexander Motin 
64696a93c63SKenneth D. Merry __BEGIN_DECLS
64796a93c63SKenneth D. Merry /*
648a1736be3SKenneth D. Merry  * XXX These are only left out of the kernel build to silence warnings.  If,
649a1736be3SKenneth D. Merry  * for some reason these functions are used in the kernel, the ifdefs should
650a1736be3SKenneth D. Merry  * be moved so they are included both in the kernel and userland.
65196a93c63SKenneth D. Merry  */
65296a93c63SKenneth D. Merry #ifndef _KERNEL
653*7c5d20a6SWarner Losh void scsi_format_unit(struct ccb_scsiio *csio, uint32_t retries,
65496a93c63SKenneth D. Merry 		      void (*cbfcnp)(struct cam_periph *, union ccb *),
655*7c5d20a6SWarner Losh 		      uint8_t tag_action, uint8_t byte2, uint16_t ileave,
656*7c5d20a6SWarner Losh 		      uint8_t *data_ptr, uint32_t dxfer_len,
657*7c5d20a6SWarner Losh 		      uint8_t sense_len, uint32_t timeout);
65896a93c63SKenneth D. Merry 
659a1736be3SKenneth D. Merry void scsi_read_defects(struct ccb_scsiio *csio, uint32_t retries,
660a1736be3SKenneth D. Merry 		       void (*cbfcnp)(struct cam_periph *, union ccb *),
661a1736be3SKenneth D. Merry 		       uint8_t tag_action, uint8_t list_format,
662a1736be3SKenneth D. Merry 		       uint32_t addr_desc_index, uint8_t *data_ptr,
663a1736be3SKenneth D. Merry 		       uint32_t dxfer_len, int minimum_cmd_size,
664a1736be3SKenneth D. Merry 		       uint8_t sense_len, uint32_t timeout);
665a1736be3SKenneth D. Merry 
666*7c5d20a6SWarner Losh void scsi_sanitize(struct ccb_scsiio *csio, uint32_t retries,
667ffead710SBryan Venteicher 		   void (*cbfcnp)(struct cam_periph *, union ccb *),
668*7c5d20a6SWarner Losh 		   uint8_t tag_action, uint8_t byte2, uint16_t control,
669*7c5d20a6SWarner Losh 		   uint8_t *data_ptr, uint32_t dxfer_len, uint8_t sense_len,
670*7c5d20a6SWarner Losh 		   uint32_t timeout);
671ffead710SBryan Venteicher 
67296a93c63SKenneth D. Merry #endif /* !_KERNEL */
6739a6844d5SKenneth D. Merry 
6749a6844d5SKenneth D. Merry void scsi_zbc_out(struct ccb_scsiio *csio, uint32_t retries,
6759a6844d5SKenneth D. Merry 		  void (*cbfcnp)(struct cam_periph *, union ccb *),
6769a6844d5SKenneth D. Merry 		  uint8_t tag_action, uint8_t service_action, uint64_t zone_id,
6779a6844d5SKenneth D. Merry 		  uint8_t zone_flags, uint8_t *data_ptr, uint32_t dxfer_len,
6789a6844d5SKenneth D. Merry 		  uint8_t sense_len, uint32_t timeout);
6799a6844d5SKenneth D. Merry 
6809a6844d5SKenneth D. Merry void scsi_zbc_in(struct ccb_scsiio *csio, uint32_t retries,
6819a6844d5SKenneth D. Merry 		 void (*cbfcnp)(struct cam_periph *, union ccb *),
6829a6844d5SKenneth D. Merry 		 uint8_t tag_action, uint8_t service_action,
6839a6844d5SKenneth D. Merry 		 uint64_t zone_start_lba, uint8_t zone_options,
6849a6844d5SKenneth D. Merry 		 uint8_t *data_ptr, uint32_t dxfer_len, uint8_t sense_len,
6859a6844d5SKenneth D. Merry 		 uint32_t timeout);
6869a6844d5SKenneth D. Merry 
6879a6844d5SKenneth D. Merry int scsi_ata_zac_mgmt_out(struct ccb_scsiio *csio, uint32_t retries,
6889a6844d5SKenneth D. Merry 			  void (*cbfcnp)(struct cam_periph *, union ccb *),
6899a6844d5SKenneth D. Merry 			  uint8_t tag_action, int use_ncq,
6909a6844d5SKenneth D. Merry 			  uint8_t zm_action, uint64_t zone_id,
6919a6844d5SKenneth D. Merry 			  uint8_t zone_flags, uint8_t *data_ptr,
6929a6844d5SKenneth D. Merry 			  uint32_t dxfer_len, uint8_t *cdb_storage,
6939a6844d5SKenneth D. Merry 			  size_t cdb_storage_len, uint8_t sense_len,
6949a6844d5SKenneth D. Merry 			  uint32_t timeout);
6959a6844d5SKenneth D. Merry 
6969a6844d5SKenneth D. Merry int scsi_ata_zac_mgmt_in(struct ccb_scsiio *csio, uint32_t retries,
6979a6844d5SKenneth D. Merry 			 void (*cbfcnp)(struct cam_periph *, union ccb *),
6989a6844d5SKenneth D. Merry 			 uint8_t tag_action, int use_ncq,
6999a6844d5SKenneth D. Merry 			 uint8_t zm_action, uint64_t zone_id,
7009a6844d5SKenneth D. Merry 			 uint8_t zone_flags, uint8_t *data_ptr,
7019a6844d5SKenneth D. Merry 			 uint32_t dxfer_len, uint8_t *cdb_storage,
7029a6844d5SKenneth D. Merry 			 size_t cdb_storage_len, uint8_t sense_len,
7039a6844d5SKenneth D. Merry 			 uint32_t timeout);
7049a6844d5SKenneth D. Merry 
70596a93c63SKenneth D. Merry __END_DECLS
70696a93c63SKenneth D. Merry 
70776babe50SJustin T. Gibbs #endif /* _SCSI_SCSI_DA_H */
708