Home | History | Annotate | Line # | Download | only in scsipi
scsi_spc.h revision 1.1
      1  1.1  thorpej /*	$NetBSD: scsi_spc.h,v 1.1 2005/02/21 00:29:07 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 2005 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe.
      9  1.1  thorpej  *
     10  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.1  thorpej  * modification, are permitted provided that the following conditions
     12  1.1  thorpej  * are met:
     13  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     19  1.1  thorpej  *    must display the following acknowledgement:
     20  1.1  thorpej  *	This product includes software developed by the NetBSD
     21  1.1  thorpej  *	Foundation, Inc. and its contributors.
     22  1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  thorpej  *    contributors may be used to endorse or promote products derived
     24  1.1  thorpej  *    from this software without specific prior written permission.
     25  1.1  thorpej  *
     26  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  thorpej  */
     38  1.1  thorpej 
     39  1.1  thorpej /*
     40  1.1  thorpej  * SCSI Primary Commands (SPC) --
     41  1.1  thorpej  *	Commands for all device types
     42  1.1  thorpej  */
     43  1.1  thorpej 
     44  1.1  thorpej /*
     45  1.1  thorpej  * Largely written by Julian Elischer (julian (at) tfs.com)
     46  1.1  thorpej  * for TRW Financial Systems.
     47  1.1  thorpej  *
     48  1.1  thorpej  * TRW Financial Systems, in accordance with their agreement with Carnegie
     49  1.1  thorpej  * Mellon University, makes this software available to CMU to distribute
     50  1.1  thorpej  * or use in any manner that they see fit as long as this message is kept with
     51  1.1  thorpej  * the software. For this reason TFS also grants any other persons or
     52  1.1  thorpej  * organisations permission to use or modify this software.
     53  1.1  thorpej  *
     54  1.1  thorpej  * TFS supplies this software to be publicly redistributed
     55  1.1  thorpej  * on the understanding that TFS is not responsible for the correct
     56  1.1  thorpej  * functioning of this software in any circumstances.
     57  1.1  thorpej  *
     58  1.1  thorpej  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     59  1.1  thorpej  */
     60  1.1  thorpej 
     61  1.1  thorpej #ifndef _DEV_SCSIPI_SCSI_SPC_H_
     62  1.1  thorpej #define	_DEV_SCSIPI_SCSI_SPC_H_
     63  1.1  thorpej 
     64  1.1  thorpej /*
     65  1.1  thorpej  * EXTENDED COPY
     66  1.1  thorpej  */
     67  1.1  thorpej 
     68  1.1  thorpej /*
     69  1.1  thorpej  * INQUIRY
     70  1.1  thorpej  */
     71  1.1  thorpej 
     72  1.1  thorpej /*
     73  1.1  thorpej  * LOG SELECT
     74  1.1  thorpej  */
     75  1.1  thorpej 
     76  1.1  thorpej /*
     77  1.1  thorpej  * LOG SENSE
     78  1.1  thorpej  */
     79  1.1  thorpej 
     80  1.1  thorpej /*
     81  1.1  thorpej  * MODE SELECT
     82  1.1  thorpej  */
     83  1.1  thorpej 
     84  1.1  thorpej #define	SCSI_MODE_SELECT_6		0x15
     85  1.1  thorpej struct scsi_mode_select_6 {
     86  1.1  thorpej 	uint8_t opcode;
     87  1.1  thorpej 	uint8_t byte2;
     88  1.1  thorpej #define	SMS_SP		0x01	/* save page */
     89  1.1  thorpej #define	SMS_PF		0x10	/* page format (0 = SCSI-1, 1 = SCSI-2) */
     90  1.1  thorpej 	uint8_t reserved[2];
     91  1.1  thorpej 	uint8_t length;
     92  1.1  thorpej 	uint8_t control;
     93  1.1  thorpej };
     94  1.1  thorpej 
     95  1.1  thorpej #define	SCSI_MODE_SELECT_10		0x55
     96  1.1  thorpej struct scsi_mode_select_10 {
     97  1.1  thorpej 	uint8_t opcode;
     98  1.1  thorpej 	uint8_t byte2;		/* see MODE SELECT (6) */
     99  1.1  thorpej 	uint8_t reserved[5];
    100  1.1  thorpej 	uint8_t length[2];
    101  1.1  thorpej 	uint8_t control;
    102  1.1  thorpej };
    103  1.1  thorpej 
    104  1.1  thorpej /*
    105  1.1  thorpej  * MODE SENSE
    106  1.1  thorpej  */
    107  1.1  thorpej 
    108  1.1  thorpej #define	SCSI_MODE_SENSE_6		0x1a
    109  1.1  thorpej struct scsi_mode_sense_6 {
    110  1.1  thorpej 	uint8_t opcode;
    111  1.1  thorpej 	uint8_t byte2;
    112  1.1  thorpej #define	SMS_DBD				0x08 /* disable block descriptors */
    113  1.1  thorpej 	uint8_t page;
    114  1.1  thorpej #define	SMS_PAGE_MASK			0x3f
    115  1.1  thorpej #define	SMS_PCTRL_MASK			0xc0
    116  1.1  thorpej #define	SMS_PCTRL_CURRENT		0x00
    117  1.1  thorpej #define	SMS_PCTRL_CHANGEABLE		0x40
    118  1.1  thorpej #define	SMS_PCTRL_DEFAULT		0x80
    119  1.1  thorpej #define	SMS_PCTRL_SAVED			0xc0
    120  1.1  thorpej 	uint8_t reserved;
    121  1.1  thorpej 	uint8_t length;
    122  1.1  thorpej 	uint8_t control;
    123  1.1  thorpej };
    124  1.1  thorpej 
    125  1.1  thorpej #define	SCSI_MODE_SENSE_10		0x5a
    126  1.1  thorpej struct scsi_mode_sense_10 {
    127  1.1  thorpej 	uint8_t opcode;
    128  1.1  thorpej 	uint8_t byte2;			/* see MODE SENSE (6) */
    129  1.1  thorpej #define	SMS_LLBAA			0x10
    130  1.1  thorpej 	uint8_t page;			/* See MODE SENSE (6) */
    131  1.1  thorpej 	uint8_t reserved[4];
    132  1.1  thorpej 	uint8_t length[2];
    133  1.1  thorpej 	uint8_t control;
    134  1.1  thorpej };
    135  1.1  thorpej 
    136  1.1  thorpej /*
    137  1.1  thorpej  * Page code usage:
    138  1.1  thorpej  *	0x00		Vendor-specific (does not require page format)
    139  1.1  thorpej  *	0x01 - 0x1f	Device-type-specific pages
    140  1.1  thorpej  *	0x20 - 0x3e	Vendor-specific (page format required)
    141  1.1  thorpej  *	0x3f		Return all mode pages
    142  1.1  thorpej  */
    143  1.1  thorpej #define	SMS_PAGE_ALL_PAGES		0x3f
    144  1.1  thorpej 
    145  1.1  thorpej /*
    146  1.1  thorpej  * Mode parameters are returned in the following format:
    147  1.1  thorpej  *
    148  1.1  thorpej  *	Mode parameter header
    149  1.1  thorpej  *	Block descriptor(s)	[zero or more]
    150  1.1  thorpej  *	Page(s)			[zero or more, variable-length]
    151  1.1  thorpej  */
    152  1.1  thorpej 
    153  1.1  thorpej struct scsi_mode_parameter_header_6 {
    154  1.1  thorpej 	uint8_t data_length;
    155  1.1  thorpej 	uint8_t medium_type;
    156  1.1  thorpej 	uint8_t dev_spec;
    157  1.1  thorpej 	uint8_t blk_desc_len;		/* unused on ATAPI */
    158  1.1  thorpej };
    159  1.1  thorpej 
    160  1.1  thorpej struct scsi_mode_parameter_header_10 {
    161  1.1  thorpej 	uint8_t data_length[2];
    162  1.1  thorpej 	uint8_t medium_type;
    163  1.1  thorpej 	uint8_t dev_spec;
    164  1.1  thorpej 	uint8_t byte5;
    165  1.1  thorpej #define	SMPH_LONGLBA		0x01
    166  1.1  thorpej 	uint8_t reserved;
    167  1.1  thorpej 	uint8_t blk_desc_len[2];
    168  1.1  thorpej };
    169  1.1  thorpej 
    170  1.1  thorpej struct scsi_general_block_descriptor {
    171  1.1  thorpej 	uint8_t density;
    172  1.1  thorpej 	uint8_t nblocks[3];
    173  1.1  thorpej 	uint8_t reserved;
    174  1.1  thorpej 	uint8_t blklen[3];
    175  1.1  thorpej };
    176  1.1  thorpej 
    177  1.1  thorpej struct scsi_da_block_descriptor {
    178  1.1  thorpej 	uint8_t nblocks[4];
    179  1.1  thorpej 	uint8_t density;
    180  1.1  thorpej 	uint8_t blklen[3];
    181  1.1  thorpej };
    182  1.1  thorpej 
    183  1.1  thorpej struct scsi_longlba_block_descriptor {
    184  1.1  thorpej 	uint8_t nblocks[8];
    185  1.1  thorpej 	uint8_t density;
    186  1.1  thorpej 	uint8_t reserved[3];
    187  1.1  thorpej 	uint8_t blklen[4];
    188  1.1  thorpej };
    189  1.1  thorpej 
    190  1.1  thorpej /*
    191  1.1  thorpej  * Header common to all mode parameter pages.
    192  1.1  thorpej  */
    193  1.1  thorpej struct scsi_mode_page_header {
    194  1.1  thorpej 	uint8_t pg_code;
    195  1.1  thorpej #define	PGCODE_MASK	0x3f		/* page code mask */
    196  1.1  thorpej #define	PGCODE_PS	0x80		/* page is saveable */
    197  1.1  thorpej 	uint8_t pg_length;		/* page length (not including header) */
    198  1.1  thorpej };
    199  1.1  thorpej 
    200  1.1  thorpej /*
    201  1.1  thorpej  * Control mode page
    202  1.1  thorpej  */
    203  1.1  thorpej #define	SCSI_CONTROL_MODE_PAGE		0x0a
    204  1.1  thorpej struct scsi_control_mode_page {
    205  1.1  thorpej 	uint8_t pg_code;		/* 0x0a */
    206  1.1  thorpej 	uint8_t pg_length;		/* 0x0a */
    207  1.1  thorpej 	uint8_t byte3;
    208  1.1  thorpej #define	SCMP_RLEC		0x01	/* report log exception condition */
    209  1.1  thorpej #define	SCMP_GLTSD		0x02	/* global logging target save disable */
    210  1.1  thorpej #define	SCMP_TST_mask		0x7	/* task set type */
    211  1.1  thorpej #define	SCMP_TST_shift		5
    212  1.1  thorpej #define	SCMP_TST_ALL_INIT	0	/* per LU for all initiators */
    213  1.1  thorpej #define	SCMP_TST_PER_INIT	1	/* per initiator per LU */
    214  1.1  thorpej 	uint8_t queue_params;
    215  1.1  thorpej #define	SCMP_DQue		0x01	/* disable queueing */
    216  1.1  thorpej #define	SCMP_QErr_mask		0x3	/* queue error management */
    217  1.1  thorpej #define	SCMP_QErr_shift		1
    218  1.1  thorpej #define	SCMP_QAM_mask		0xf	/* queue algorithm modifier */
    219  1.1  thorpej #define	SCMP_QAM_shift		4
    220  1.1  thorpej #define	SCMP_QAM_RESTRICTED	0x0	/* restricted reordering allowed */
    221  1.1  thorpej #define	SCMP_QAM_UNRESTRICTED	0x1	/* unrestricted reordering allowed */
    222  1.1  thorpej 			/*	0x2 - 0x7	Reserved */
    223  1.1  thorpej 			/*	0x8 - 0xf	Vendor-specific */
    224  1.1  thorpej 	uint8_t byte5;
    225  1.1  thorpej #define	SCMP_EAERP		0x01
    226  1.1  thorpej #define	SCMP_UAAERP		0x02
    227  1.1  thorpej #define	SCMP_RAERP		0x04
    228  1.1  thorpej #define	SCMP_SWP		0x08
    229  1.1  thorpej #define	SCMP_RAC		0x40
    230  1.1  thorpej #define	SCMP_TAS		0x80
    231  1.1  thorpej 	uint8_t byte6;
    232  1.1  thorpej #define	SCMP_AM_mask		0x7	/* autload mode */
    233  1.1  thorpej #define	SCMP_AM_FULL		0
    234  1.1  thorpej #define	SCMP_AM_AUXMEM		1
    235  1.1  thorpej #define	SCMP_AM_NOLOAD		2
    236  1.1  thorpej 	uint8_t rahp[2];		/* ready aer holdoff period */
    237  1.1  thorpej 	uint8_t btp[2];			/* busy timeout period */
    238  1.1  thorpej 	uint8_t estct[2];		/* extended self-test completion time */
    239  1.1  thorpej };
    240  1.1  thorpej 
    241  1.1  thorpej /*
    242  1.1  thorpej  * Disconnect-reconnect page
    243  1.1  thorpej  */
    244  1.1  thorpej #define	SCSI_DISCONNECT_RECONNECT_PAGE	0x02
    245  1.1  thorpej struct scsi_disconnect_reconnect_page {
    246  1.1  thorpej 	uint8_t pg_code;		/* 0x02 */
    247  1.1  thorpej 	uint8_t pg_length;		/* 0x0e */
    248  1.1  thorpej 	uint8_t buffer_full_ratio;
    249  1.1  thorpej 	uint8_t buffer_empty_ratio;
    250  1.1  thorpej 	uint8_t bus_inactivity_limit[2];
    251  1.1  thorpej 	uint8_t disconnect_time_limit[2];
    252  1.1  thorpej 	uint8_t connect_time_limit[2];
    253  1.1  thorpej 	uint8_t maximum_burst_size[2];
    254  1.1  thorpej 	uint8_t flags;
    255  1.1  thorpej #define	SDRP_DTDC_mask		0x7	/* data transfer disconnect control */
    256  1.1  thorpej #define	SDRP_DImm		0x08
    257  1.1  thorpej #define	SDRP_FA_mask		0x7
    258  1.1  thorpej #define	SDRP_FA_shift		4
    259  1.1  thorpej #define	SDRP_EMDP		0x80
    260  1.1  thorpej 	uint8_t reserved;
    261  1.1  thorpej 	uint8_t first_burst_size[2];
    262  1.1  thorpej };
    263  1.1  thorpej 
    264  1.1  thorpej /*
    265  1.1  thorpej  * Informational exceptions control page
    266  1.1  thorpej  */
    267  1.1  thorpej #define	SCSI_INFORMATIONAL_EXCEPTIONS_CONTROL_PAGE 0x1c
    268  1.1  thorpej struct scsi_informational_exceptions_control_page {
    269  1.1  thorpej 	uint8_t pg_code;		/* 0x1c */
    270  1.1  thorpej 	uint8_t pg_length;		/* 0x0a */
    271  1.1  thorpej 	uint8_t byte3;
    272  1.1  thorpej #define	SIECP_LogErr		0x01
    273  1.1  thorpej #define	SIECP_TEST		0x04
    274  1.1  thorpej #define	SIECP_DExcpt		0x08
    275  1.1  thorpej #define	SIECP_EWasc		0x10
    276  1.1  thorpej #define	SIECP_EBF		0x20
    277  1.1  thorpej #define	SIECP_PERF		0x80
    278  1.1  thorpej 	uint8_t byte4;
    279  1.1  thorpej #define	SIECP_MRIE_mask			0xf	/* method of reporting
    280  1.1  thorpej 						   informational exceptions */
    281  1.1  thorpej #define	SIECP_MRIE_NO_REPORTING		0x00
    282  1.1  thorpej #define	SIECP_MRIE_ASYNC_EVENT		0x01
    283  1.1  thorpej #define	SIECP_MRIE_UNIT_ATN		0x02
    284  1.1  thorpej #define	SIECP_MRIE_COND_RECOV_ERR	0x03
    285  1.1  thorpej #define	SIECP_MRIE_UNCOND_RECOV_ERR	0x04
    286  1.1  thorpej #define	SIECP_MRIE_NO_SENSE		0x05
    287  1.1  thorpej #define	SIECP_MRIE_ON_REQUEST		0x06
    288  1.1  thorpej 				/*	0x07 - 0x0b reserved */
    289  1.1  thorpej 				/*	0x0c - 0x0f Vendor-specific */
    290  1.1  thorpej 	uint8_t interval_timer[2];
    291  1.1  thorpej 	uint8_t report_count[2];
    292  1.1  thorpej };
    293  1.1  thorpej 
    294  1.1  thorpej /*
    295  1.1  thorpej  * Power condition page
    296  1.1  thorpej  */
    297  1.1  thorpej #define	SCSI_POWER_CONDITION_PAGE	0x1a
    298  1.1  thorpej struct scsi_power_condition_page {
    299  1.1  thorpej 	uint8_t pg_code;		/* 0x1a */
    300  1.1  thorpej 	uint8_t pg_length;		/* 0x0a */
    301  1.1  thorpej 	uint8_t reserved;
    302  1.1  thorpej 	uint8_t byte4;
    303  1.1  thorpej #define	SPCP_STANDBY		0x01
    304  1.1  thorpej #define	SPCP_IDLE		0x02
    305  1.1  thorpej 	uint8_t idle_timer[2];		/* 100ms increments */
    306  1.1  thorpej 	uint8_t standby_timer[2];	/* 100ms increments */
    307  1.1  thorpej };
    308  1.1  thorpej 
    309  1.1  thorpej /*
    310  1.1  thorpej  * Protocol specific LUN page
    311  1.1  thorpej  */
    312  1.1  thorpej #define	SCSI_PROTOCOL_SPECIFIC_LUN_PAGE	0x18
    313  1.1  thorpej struct scsi_protocol_specific_lun_page {
    314  1.1  thorpej 	uint8_t pg_code;	/* 0x18 */
    315  1.1  thorpej 	uint8_t pg_length;	/* variable */
    316  1.1  thorpej 	uint8_t byte3;
    317  1.1  thorpej #define	SPSLP_PROTOCOL_mask	0xf
    318  1.1  thorpej #define	SPSLP_PROTOCOL_FCP	0x00	/* Fibre Channel */
    319  1.1  thorpej #define	SPSLP_PROTOCOL_SPI	0x01	/* parallel SCSI */
    320  1.1  thorpej #define	SPSLP_PROTOCOL_SSA	0x02	/* SSA-S2P or SSA-S3P */
    321  1.1  thorpej #define	SPSLP_PROTOCOL_SBP2	0x03	/* IEEE 1394 */
    322  1.1  thorpej #define	SPSLP_PROTOCOL_SRP	0x04	/* SCSI RDMA */
    323  1.1  thorpej #define	SPSLP_PROTOCOL_ISCSI	0x05	/* iSCSI */
    324  1.1  thorpej 	/* protocol specific mode parameters follow */
    325  1.1  thorpej };
    326  1.1  thorpej 
    327  1.1  thorpej /*
    328  1.1  thorpej  * Protocol specific port page
    329  1.1  thorpej  */
    330  1.1  thorpej #define	SCSI_PROTOCOL_SPECIFIC_PORT_PAGE 0x19
    331  1.1  thorpej struct scsi_protocol_specific_port_page {
    332  1.1  thorpej 	uint8_t pg_code;	/* 0x18 */
    333  1.1  thorpej 	uint8_t pg_length;	/* variable */
    334  1.1  thorpej 	uint8_t byte3;		/* see SCSI PROTOCOL SPECIFIC LUN PAGE */
    335  1.1  thorpej 	/* protocol specific mode parameters follow */
    336  1.1  thorpej };
    337  1.1  thorpej 
    338  1.1  thorpej /*
    339  1.1  thorpej  * PERSISTENT RESERVE IN
    340  1.1  thorpej  */
    341  1.1  thorpej 
    342  1.1  thorpej /*
    343  1.1  thorpej  * PERSISTENT RESERVE OUT
    344  1.1  thorpej  */
    345  1.1  thorpej 
    346  1.1  thorpej /*
    347  1.1  thorpej  * PREVENT ALLOW MEDIUM REMOVAL
    348  1.1  thorpej  */
    349  1.1  thorpej 
    350  1.1  thorpej #define	SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
    351  1.1  thorpej struct scsi_prevent_allow_medium_removal {
    352  1.1  thorpej 	uint8_t opcode;
    353  1.1  thorpej 	uint8_t byte2;
    354  1.1  thorpej 	uint8_t reserved[2];
    355  1.1  thorpej 	uint8_t how;
    356  1.1  thorpej #define	SPAMR_ALLOW		0x00
    357  1.1  thorpej #define	SPAMR_PREVENT_DT	0x01
    358  1.1  thorpej #define	SPAMR_PREVENT_MC	0x02
    359  1.1  thorpej #define	SPAMR_PREVENT_ALL	0x03
    360  1.1  thorpej 	uint8_t control;
    361  1.1  thorpej };
    362  1.1  thorpej 
    363  1.1  thorpej /*
    364  1.1  thorpej  * READ BUFFER
    365  1.1  thorpej  */
    366  1.1  thorpej 
    367  1.1  thorpej /*
    368  1.1  thorpej  * RECEIVE COPY RESULTS
    369  1.1  thorpej  */
    370  1.1  thorpej 
    371  1.1  thorpej /*
    372  1.1  thorpej  * RECEIVE DIAGNOSTIC RESULTS
    373  1.1  thorpej  */
    374  1.1  thorpej 
    375  1.1  thorpej /*
    376  1.1  thorpej  * RESERVE / RELEASE
    377  1.1  thorpej  */
    378  1.1  thorpej 
    379  1.1  thorpej #define	SCSI_RESERVE_6			0x16
    380  1.1  thorpej #define	SCSI_RELEASE_6			0x17
    381  1.1  thorpej struct scsi_reserve_release_6 {
    382  1.1  thorpej 	uint8_t opcode;
    383  1.1  thorpej 	uint8_t byte2;
    384  1.1  thorpej 	uint8_t obsolete;
    385  1.1  thorpej 	uint8_t reserved[2];
    386  1.1  thorpej 	uint8_t control;
    387  1.1  thorpej };
    388  1.1  thorpej 
    389  1.1  thorpej #define	SCSI_RESERVE_10			0x56
    390  1.1  thorpej #define	SCSI_RELEASE_10			0x57
    391  1.1  thorpej struct scsi_reserve_release_10 {
    392  1.1  thorpej 	uint8_t opcode;
    393  1.1  thorpej 	uint8_t byte2;
    394  1.1  thorpej #define	SR_LongID		0x02
    395  1.1  thorpej #define	SR_3rdPty		0x10
    396  1.1  thorpej 	uint8_t obsolete;
    397  1.1  thorpej 	uint8_t thirdpartyid;
    398  1.1  thorpej 	uint8_t reserved[3];
    399  1.1  thorpej 	uint8_t paramlen[2];
    400  1.1  thorpej 	uint8_t control;
    401  1.1  thorpej };
    402  1.1  thorpej 
    403  1.1  thorpej struct scsi_reserve_release_10_idparam {
    404  1.1  thorpej 	uint8_t thirdpartyid[8];
    405  1.1  thorpej };
    406  1.1  thorpej 
    407  1.1  thorpej /*
    408  1.1  thorpej  * REPORT DEVICE IDENTIFIER
    409  1.1  thorpej  */
    410  1.1  thorpej 
    411  1.1  thorpej /*
    412  1.1  thorpej  * REPORT LUNS
    413  1.1  thorpej  */
    414  1.1  thorpej 
    415  1.1  thorpej /*
    416  1.1  thorpej  * REQUEST SENSE
    417  1.1  thorpej  */
    418  1.1  thorpej 
    419  1.1  thorpej #define	SCSI_REQUEST_SENSE		0x03
    420  1.1  thorpej struct scsi_request_sense {
    421  1.1  thorpej 	uint8_t opcode;
    422  1.1  thorpej 	uint8_t byte2;
    423  1.1  thorpej 	uint8_t reserved[2];
    424  1.1  thorpej 	uint8_t length;
    425  1.1  thorpej 	uint8_t control;
    426  1.1  thorpej };
    427  1.1  thorpej 
    428  1.1  thorpej struct scsi_sense_data {
    429  1.1  thorpej /* 1*/	uint8_t response_code;
    430  1.1  thorpej #define	SSD_RCODE(x)		((x) & 0x7f)
    431  1.1  thorpej #define	SSD_RCODE_CURRENT	0x70
    432  1.1  thorpej #define	SSD_RCODE_DEFERRED	0x71
    433  1.1  thorpej #define	SSD_RCODE_VALID		0x80
    434  1.1  thorpej /* 2*/	uint8_t segment;	/* obsolete */
    435  1.1  thorpej /* 3*/	uint8_t flags;
    436  1.1  thorpej #define	SSD_SENSE_KEY(x)	((x) & 0x0f)
    437  1.1  thorpej #define	SSD_ILI			0x20
    438  1.1  thorpej #define	SSD_EOM			0x40
    439  1.1  thorpej #define	SSD_FILEMARK		0x80
    440  1.1  thorpej /* 7*/	uint8_t info[4];
    441  1.1  thorpej /* 8*/	uint8_t extra_len;
    442  1.1  thorpej /*12*/	uint8_t csi[4];
    443  1.1  thorpej /*13*/	uint8_t asc;
    444  1.1  thorpej /*14*/	uint8_t ascq;
    445  1.1  thorpej /*15*/	uint8_t fru;
    446  1.1  thorpej 	union {
    447  1.1  thorpej 		uint8_t sks_bytes[3];
    448  1.1  thorpej 
    449  1.1  thorpej 		/* ILLEGAL REQUEST */
    450  1.1  thorpej 		struct {
    451  1.1  thorpej 			uint8_t byte0;
    452  1.1  thorpej #define	SSD_SKS_FP_BIT(x)	((x) & 0x7)
    453  1.1  thorpej #define	SSD_SKS_FP_BPV		0x08
    454  1.1  thorpej #define	SSK_SKS_FP_CD		0x40	/* 1=command, 0=data */
    455  1.1  thorpej 			uint8_t val[2];
    456  1.1  thorpej 		} field_pointer;
    457  1.1  thorpej 
    458  1.1  thorpej 		/* RECOVERED ERROR, HARDWARE ERROR, MEDIUM ERROR */
    459  1.1  thorpej 		struct {
    460  1.1  thorpej 			uint8_t byte0;
    461  1.1  thorpej 			uint8_t val[2];
    462  1.1  thorpej 		} actual_retry_count;
    463  1.1  thorpej 
    464  1.1  thorpej 		/* NOT READY, NO SENSE */
    465  1.1  thorpej 		struct {
    466  1.1  thorpej 			uint8_t byte0;
    467  1.1  thorpej 			uint8_t val[2];
    468  1.1  thorpej 		} progress_indication;
    469  1.1  thorpej 
    470  1.1  thorpej 		/* COPY ABORTED */
    471  1.1  thorpej 		struct {
    472  1.1  thorpej 			uint8_t byte0;
    473  1.1  thorpej #define	SSD_SKS_SP_BIT(x)	((x) & 0x7)
    474  1.1  thorpej #define	SSD_SKS_SP_BPV		0x08
    475  1.1  thorpej #define	SSD_SKS_SP_SD		0x20	/* 0=param list, 1=segment desc */
    476  1.1  thorpej 			uint8_t val[2];
    477  1.1  thorpej 		} segment_pointer;
    478  1.1  thorpej /*18*/	} sks;
    479  1.1  thorpej #define	SSD_SKSV		0x80	/* byte0 of sks field */
    480  1.1  thorpej /*32*/	uint8_t extra_bytes[14];	/* really variable length */
    481  1.1  thorpej };
    482  1.1  thorpej 
    483  1.1  thorpej /*
    484  1.1  thorpej  * Sense bytes described by the extra_len field start at csi[], and can
    485  1.1  thorpej  * only continue up to the end of the 32-byte sense structure that we
    486  1.1  thorpej  * have defined (which might be too short for some cases).
    487  1.1  thorpej  */
    488  1.1  thorpej #define	SSD_ADD_BYTES_LIM(sp)						\
    489  1.1  thorpej 	((((int)(sp)->extra_len) < (int)sizeof(struct scsi_sense_data) - 8) ? \
    490  1.1  thorpej 	 (sp)->extra_len : sizeof(struct scsi_sense_data) - 8)
    491  1.1  thorpej 
    492  1.1  thorpej #define	SKEY_NO_SENSE		0x00
    493  1.1  thorpej #define	SKEY_RECOVERED_ERROR	0x01
    494  1.1  thorpej #define	SKEY_NOT_READY		0x02
    495  1.1  thorpej #define	SKEY_MEDIUM_ERROR	0x03
    496  1.1  thorpej #define	SKEY_HARDWARE_ERROR	0x04
    497  1.1  thorpej #define	SKEY_ILLEGAL_REQUEST	0x05
    498  1.1  thorpej #define	SKEY_UNIT_ATTENTION	0x06
    499  1.1  thorpej #define	SKEY_DATA_PROTECT	0x07
    500  1.1  thorpej #define	SKEY_BLANK_CHECK	0x08
    501  1.1  thorpej #define	SKEY_VENDOR_SPECIFIC	0x09
    502  1.1  thorpej #define	SKEY_COPY_ABORTED	0x0a
    503  1.1  thorpej #define	SKEY_ABORTED_COMMAND	0x0b
    504  1.1  thorpej #define	SKEY_EQUAL		0x0c	/* obsolete */
    505  1.1  thorpej #define	SKEY_VOLUME_OVERFLOW	0x0d
    506  1.1  thorpej #define	SKEY_MISCOMPARE		0x0e
    507  1.1  thorpej 			/*	0x0f	reserved */
    508  1.1  thorpej 
    509  1.1  thorpej /* XXX This is not described in SPC-2. */
    510  1.1  thorpej struct scsi_sense_data_unextended {
    511  1.1  thorpej 	uint8_t response_code;
    512  1.1  thorpej 	uint8_t block[3];
    513  1.1  thorpej };
    514  1.1  thorpej 
    515  1.1  thorpej /*
    516  1.1  thorpej  * SEND DIAGNOSTIC
    517  1.1  thorpej  */
    518  1.1  thorpej 
    519  1.1  thorpej #define	SCSI_SEND_DIAGNOSTIC		0x1d
    520  1.1  thorpej struct scsi_send_diagnostic {
    521  1.1  thorpej 	uint8_t opcode;
    522  1.1  thorpej 	uint8_t byte2;
    523  1.1  thorpej #define	SSD_UnitOffL		0x01
    524  1.1  thorpej #define	SSD_DevOffL		0x02
    525  1.1  thorpej #define	SSD_SelfTest		0x04	/* standard self-test */
    526  1.1  thorpej #define	SSD_PF			0x10	/* results in page format */
    527  1.1  thorpej #define	SSD_CODE(x)		((x) << 5)
    528  1.1  thorpej 	/*
    529  1.1  thorpej 	 * Codes:
    530  1.1  thorpej 	 *
    531  1.1  thorpej 	 *	0	This value shall be used when the SelfTest bit is
    532  1.1  thorpej 	 *		set to one or if the SEND DIAGNOSTIC command is not
    533  1.1  thorpej 	 *		invoking one of the other self-test functions such
    534  1.1  thorpej 	 *		as enclosure services or the Translate Address page.
    535  1.1  thorpej 	 *
    536  1.1  thorpej 	 *	1	Background short self-test.  Parameter length is 0.
    537  1.1  thorpej 	 *
    538  1.1  thorpej 	 *	2	Background extended self-test.  Parameter length is 0.
    539  1.1  thorpej 	 *
    540  1.1  thorpej 	 *	4	Abort background self-test.  Parameter length is 0.
    541  1.1  thorpej 	 *
    542  1.1  thorpej 	 *	5	Foreground short self-test.  Parameter length is 0.
    543  1.1  thorpej 	 *
    544  1.1  thorpej 	 *	6	Foreground extended self-test.  Parameter length is 0.
    545  1.1  thorpej 	 */
    546  1.1  thorpej 	uint8_t reserved;
    547  1.1  thorpej 	uint8_t paramlen[2];
    548  1.1  thorpej 	uint8_t control;
    549  1.1  thorpej };
    550  1.1  thorpej 
    551  1.1  thorpej /*
    552  1.1  thorpej  * SET DEVICE IDENTIFIER
    553  1.1  thorpej  */
    554  1.1  thorpej 
    555  1.1  thorpej /*
    556  1.1  thorpej  * TEST UNIT READY
    557  1.1  thorpej  */
    558  1.1  thorpej 
    559  1.1  thorpej #define	SCSI_TEST_UNIT_READY		0x00
    560  1.1  thorpej struct scsi_test_unit_ready {
    561  1.1  thorpej 	uint8_t opcode;
    562  1.1  thorpej 	uint8_t byte2;
    563  1.1  thorpej 	uint8_t reserved[3];
    564  1.1  thorpej 	uint8_t control;
    565  1.1  thorpej };
    566  1.1  thorpej 
    567  1.1  thorpej /*
    568  1.1  thorpej  * WRITE BUFFER
    569  1.1  thorpej  */
    570  1.1  thorpej 
    571  1.1  thorpej #endif /* _DEV_SCSIPI_SCSI_SPC_H_ */
    572