1 /* @(#)scsisense.h 2.18 04/09/04 Copyright 1986 J. Schilling */ 2 /* 3 * Definitions for the SCSI status code and sense structure 4 * 5 * Copyright (c) 1986 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * The following exceptions apply: 18 * CDDL �3.6 needs to be replaced by: "You may create a Larger Work by 19 * combining Covered Software with other code if all other code is governed by 20 * the terms of a license that is OSI approved (see www.opensource.org) and 21 * you may distribute the Larger Work as a single product. In such a case, 22 * You must make sure the requirements of this License are fulfilled for 23 * the Covered Software." 24 * 25 * When distributing Covered Code, include this CDDL HEADER in each 26 * file and include the License file CDDL.Schily.txt from this distribution. 27 */ 28 29 #ifndef _SCG_SCSISENSE_H 30 #define _SCG_SCSISENSE_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * SCSI status completion block. 38 */ 39 #define SCSI_EXTENDED_STATUS 40 41 #if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */ 42 43 struct scsi_status { 44 Ucbit vu_00 : 1; /* vendor unique */ 45 Ucbit chk : 1; /* check condition: sense data available */ 46 Ucbit cm : 1; /* condition met */ 47 Ucbit busy : 1; /* device busy or reserved */ 48 Ucbit is : 1; /* intermediate status sent */ 49 Ucbit vu_05 : 1; /* vendor unique */ 50 #define st_scsi2 vu_05 /* SCSI-2 modifier bit */ 51 Ucbit vu_06 : 1; /* vendor unique */ 52 Ucbit st_rsvd : 1; /* reserved */ 53 54 #ifdef SCSI_EXTENDED_STATUS 55 #define ext_st1 st_rsvd /* extended status (next byte valid) */ 56 /* byte 1 */ 57 Ucbit ha_er : 1; /* host adapter detected error */ 58 Ucbit reserved: 6; /* reserved */ 59 Ucbit ext_st2 : 1; /* extended status (next byte valid) */ 60 /* byte 2 */ 61 Uchar byte2; /* third byte */ 62 #endif /* SCSI_EXTENDED_STATUS */ 63 }; 64 65 #else /* Motorola byteorder */ 66 67 struct scsi_status { 68 Ucbit st_rsvd : 1; /* reserved */ 69 Ucbit vu_06 : 1; /* vendor unique */ 70 Ucbit vu_05 : 1; /* vendor unique */ 71 #define st_scsi2 vu_05 /* SCSI-2 modifier bit */ 72 Ucbit is : 1; /* intermediate status sent */ 73 Ucbit busy : 1; /* device busy or reserved */ 74 Ucbit cm : 1; /* condition met */ 75 Ucbit chk : 1; /* check condition: sense data available */ 76 Ucbit vu_00 : 1; /* vendor unique */ 77 #ifdef SCSI_EXTENDED_STATUS 78 #define ext_st1 st_rsvd /* extended status (next byte valid) */ 79 /* byte 1 */ 80 Ucbit ext_st2 : 1; /* extended status (next byte valid) */ 81 Ucbit reserved: 6; /* reserved */ 82 Ucbit ha_er : 1; /* host adapter detected error */ 83 /* byte 2 */ 84 Uchar byte2; /* third byte */ 85 #endif /* SCSI_EXTENDED_STATUS */ 86 }; 87 #endif 88 89 /* 90 * OLD Standard (Non Extended) SCSI Sense. Used mainly by the 91 * Adaptec ACB 4000 which is the only controller that 92 * does not support the Extended sense format. 93 */ 94 #if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */ 95 96 struct scsi_sense { /* scsi sense for error classes 0-6 */ 97 Ucbit code : 7; /* error class/code */ 98 Ucbit adr_val : 1; /* sense data is valid */ 99 #ifdef comment 100 Ucbit high_addr:5; /* high byte of block addr */ 101 Ucbit rsvd : 3; 102 #else 103 Uchar high_addr; /* high byte of block addr */ 104 #endif 105 Uchar mid_addr; /* middle byte of block addr */ 106 Uchar low_addr; /* low byte of block addr */ 107 }; 108 109 #else /* Motorola byteorder */ 110 111 struct scsi_sense { /* scsi sense for error classes 0-6 */ 112 Ucbit adr_val : 1; /* sense data is valid */ 113 Ucbit code : 7; /* error class/code */ 114 #ifdef comment 115 Ucbit rsvd : 3; 116 Ucbit high_addr:5; /* high byte of block addr */ 117 #else 118 Uchar high_addr; /* high byte of block addr */ 119 #endif 120 Uchar mid_addr; /* middle byte of block addr */ 121 Uchar low_addr; /* low byte of block addr */ 122 }; 123 #endif 124 125 /* 126 * SCSI extended sense parameter block. 127 */ 128 #ifdef comment 129 #define SC_CLASS_EXTENDED_SENSE 0x7 /* indicates extended sense */ 130 #endif 131 132 #if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */ 133 134 struct scsi_ext_sense { /* scsi extended sense for error class 7 */ 135 /* byte 0 */ 136 Ucbit type : 7; /* fixed at 0x70 */ 137 Ucbit adr_val : 1; /* sense data is valid */ 138 /* byte 1 */ 139 Uchar seg_num; /* segment number, applies to copy cmd only */ 140 /* byte 2 */ 141 Ucbit key : 4; /* sense key, see below */ 142 Ucbit : 1; /* reserved */ 143 Ucbit ili : 1; /* incorrect length indicator */ 144 Ucbit eom : 1; /* end of media */ 145 Ucbit fil_mk : 1; /* file mark on device */ 146 /* bytes 3 through 7 */ 147 Uchar info_1; /* information byte 1 */ 148 Uchar info_2; /* information byte 2 */ 149 Uchar info_3; /* information byte 3 */ 150 Uchar info_4; /* information byte 4 */ 151 Uchar add_len; /* number of additional bytes */ 152 /* bytes 8 through 13, CCS additions */ 153 Uchar optional_8; /* CCS search and copy only */ 154 Uchar optional_9; /* CCS search and copy only */ 155 Uchar optional_10; /* CCS search and copy only */ 156 Uchar optional_11; /* CCS search and copy only */ 157 Uchar sense_code; /* sense code */ 158 Uchar qual_code; /* sense code qualifier */ 159 Uchar fru_code; /* Field replacable unit code */ 160 Ucbit bptr : 3; /* bit pointer for failure (if bpv) */ 161 Ucbit bpv : 1; /* bit pointer is valid */ 162 Ucbit : 2; 163 Ucbit cd : 1; /* pointers refer to command not data */ 164 Ucbit sksv : 1; /* sense key specific valid */ 165 Uchar field_ptr[2]; /* field pointer for failure */ 166 Uchar add_info[2]; /* round up to 20 bytes */ 167 }; 168 169 #else /* Motorola byteorder */ 170 171 struct scsi_ext_sense { /* scsi extended sense for error class 7 */ 172 /* byte 0 */ 173 Ucbit adr_val : 1; /* sense data is valid */ 174 Ucbit type : 7; /* fixed at 0x70 */ 175 /* byte 1 */ 176 Uchar seg_num; /* segment number, applies to copy cmd only */ 177 /* byte 2 */ 178 Ucbit fil_mk : 1; /* file mark on device */ 179 Ucbit eom : 1; /* end of media */ 180 Ucbit ili : 1; /* incorrect length indicator */ 181 Ucbit : 1; /* reserved */ 182 Ucbit key : 4; /* sense key, see below */ 183 /* bytes 3 through 7 */ 184 Uchar info_1; /* information byte 1 */ 185 Uchar info_2; /* information byte 2 */ 186 Uchar info_3; /* information byte 3 */ 187 Uchar info_4; /* information byte 4 */ 188 Uchar add_len; /* number of additional bytes */ 189 /* bytes 8 through 13, CCS additions */ 190 Uchar optional_8; /* CCS search and copy only */ 191 Uchar optional_9; /* CCS search and copy only */ 192 Uchar optional_10; /* CCS search and copy only */ 193 Uchar optional_11; /* CCS search and copy only */ 194 Uchar sense_code; /* sense code */ 195 Uchar qual_code; /* sense code qualifier */ 196 Uchar fru_code; /* Field replacable unit code */ 197 Ucbit sksv : 1; /* sense key specific valid */ 198 Ucbit cd : 1; /* pointers refer to command not data */ 199 Ucbit : 2; 200 Ucbit bpv : 1; /* bit pointer is valid */ 201 Ucbit bptr : 3; /* bit pointer for failure (if bpv) */ 202 Uchar field_ptr[2]; /* field pointer for failure */ 203 Uchar add_info[2]; /* round up to 20 bytes */ 204 }; 205 #endif 206 207 #ifdef __cplusplus 208 } 209 #endif 210 211 #endif /* _SCG_SCSISENSE_H */ 212