scsipi_verbose.c revision 1.10 1 1.10 jwise /* $NetBSD: scsipi_verbose.c,v 1.10 1999/02/24 18:54:03 jwise Exp $ */
2 1.1 christos
3 1.8 mycroft /*-
4 1.8 mycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.8 mycroft * All rights reserved.
6 1.8 mycroft *
7 1.8 mycroft * This code is derived from software contributed to The NetBSD Foundation
8 1.8 mycroft * by Charles M. Hannum.
9 1.1 christos *
10 1.1 christos * Redistribution and use in source and binary forms, with or without
11 1.1 christos * modification, are permitted provided that the following conditions
12 1.1 christos * are met:
13 1.1 christos * 1. Redistributions of source code must retain the above copyright
14 1.1 christos * notice, this list of conditions and the following disclaimer.
15 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 christos * notice, this list of conditions and the following disclaimer in the
17 1.1 christos * documentation and/or other materials provided with the distribution.
18 1.1 christos * 3. All advertising materials mentioning features or use of this software
19 1.1 christos * must display the following acknowledgement:
20 1.8 mycroft * This product includes software developed by the NetBSD
21 1.8 mycroft * Foundation, Inc. and its contributors.
22 1.8 mycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.8 mycroft * contributors may be used to endorse or promote products derived
24 1.8 mycroft * from this software without specific prior written permission.
25 1.1 christos *
26 1.8 mycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.8 mycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.8 mycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.8 mycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.8 mycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.8 mycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.8 mycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.8 mycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.8 mycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.8 mycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.8 mycroft * POSSIBILITY OF SUCH DAMAGE.
37 1.1 christos */
38 1.1 christos
39 1.1 christos #include <sys/types.h>
40 1.1 christos #include <sys/param.h>
41 1.1 christos #include <sys/time.h>
42 1.1 christos #include <sys/proc.h>
43 1.1 christos #include <sys/device.h>
44 1.1 christos
45 1.1 christos #ifdef _KERNEL
46 1.1 christos #include <sys/systm.h>
47 1.1 christos
48 1.7 mjacob #include "opt_scsi.h"
49 1.1 christos #else
50 1.1 christos #include <stdio.h>
51 1.1 christos #endif
52 1.1 christos #include <dev/scsipi/scsipi_all.h>
53 1.1 christos #include <dev/scsipi/scsipiconf.h>
54 1.1 christos #include <dev/scsipi/scsiconf.h>
55 1.1 christos
56 1.1 christos static const char *sense_keys[16] = {
57 1.1 christos "No Additional Sense",
58 1.6 mjacob "Recovered Error",
59 1.1 christos "Not Ready",
60 1.1 christos "Media Error",
61 1.1 christos "Hardware Error",
62 1.1 christos "Illegal Request",
63 1.1 christos "Unit Attention",
64 1.1 christos "Write Protected",
65 1.1 christos "Blank Check",
66 1.1 christos "Vendor Unique",
67 1.1 christos "Copy Aborted",
68 1.1 christos "Aborted Command",
69 1.1 christos "Equal Error",
70 1.1 christos "Volume Overflow",
71 1.1 christos "Miscompare Error",
72 1.1 christos "Reserved"
73 1.1 christos };
74 1.1 christos
75 1.1 christos static const struct {
76 1.1 christos unsigned char asc;
77 1.1 christos unsigned char ascq;
78 1.1 christos char *description;
79 1.1 christos } adesc[] = {
80 1.1 christos { 0x00, 0x00, "No Additional Sense Information" },
81 1.1 christos { 0x00, 0x01, "Filemark Detected" },
82 1.1 christos { 0x00, 0x02, "End-Of-Partition/Medium Detected" },
83 1.1 christos { 0x00, 0x03, "Setmark Detected" },
84 1.1 christos { 0x00, 0x04, "Beginning-Of-Partition/Medium Detected" },
85 1.1 christos { 0x00, 0x05, "End-Of-Data Detected" },
86 1.1 christos { 0x00, 0x06, "I/O Process Terminated" },
87 1.1 christos { 0x00, 0x11, "Audio Play Operation In Progress" },
88 1.1 christos { 0x00, 0x12, "Audio Play Operation Paused" },
89 1.1 christos { 0x00, 0x13, "Audio Play Operation Successfully Completed" },
90 1.1 christos { 0x00, 0x14, "Audio Play Operation Stopped Due to Error" },
91 1.1 christos { 0x00, 0x15, "No Current Audio Status To Return" },
92 1.1 christos { 0x01, 0x00, "No Index/Sector Signal" },
93 1.1 christos { 0x02, 0x00, "No Seek Complete" },
94 1.1 christos { 0x03, 0x00, "Peripheral Device Write Fault" },
95 1.1 christos { 0x03, 0x01, "No Write Current" },
96 1.1 christos { 0x03, 0x02, "Excessive Write Errors" },
97 1.1 christos { 0x04, 0x00, "Logical Unit Not Ready, Cause Not Reportable" },
98 1.1 christos { 0x04, 0x01, "Logical Unit Is in Process Of Becoming Ready" },
99 1.1 christos { 0x04, 0x02, "Logical Unit Not Ready, Initialization Command Required" },
100 1.1 christos { 0x04, 0x03, "Logical Unit Not Ready, Manual Intervention Required" },
101 1.1 christos { 0x04, 0x04, "Logical Unit Not Ready, Format In Progress" },
102 1.1 christos { 0x05, 0x00, "Logical Unit Does Not Respond To Selection" },
103 1.1 christos { 0x06, 0x00, "No Reference Position Found" },
104 1.1 christos { 0x07, 0x00, "Multiple Peripheral Devices Selected" },
105 1.1 christos { 0x08, 0x00, "Logical Unit Communication Failure" },
106 1.1 christos { 0x08, 0x01, "Logical Unit Communication Timeout" },
107 1.1 christos { 0x08, 0x02, "Logical Unit Communication Parity Error" },
108 1.1 christos { 0x09, 0x00, "Track Following Error" },
109 1.1 christos { 0x09, 0x01, "Tracking Servo Failure" },
110 1.1 christos { 0x09, 0x02, "Focus Servo Failure" },
111 1.1 christos { 0x09, 0x03, "Spindle Servo Failure" },
112 1.1 christos { 0x0A, 0x00, "Error Log Overflow" },
113 1.1 christos { 0x0C, 0x00, "Write Error" },
114 1.1 christos { 0x0C, 0x01, "Write Error Recovered with Auto Reallocation" },
115 1.1 christos { 0x0C, 0x02, "Write Error - Auto Reallocate Failed" },
116 1.1 christos { 0x10, 0x00, "ID CRC Or ECC Error" },
117 1.1 christos { 0x11, 0x00, "Unrecovered Read Error" },
118 1.1 christos { 0x11, 0x01, "Read Retried Exhausted" },
119 1.1 christos { 0x11, 0x02, "Error Too Long To Correct" },
120 1.1 christos { 0x11, 0x03, "Multiple Read Errors" },
121 1.1 christos { 0x11, 0x04, "Unrecovered Read Error - Auto Reallocate Failed" },
122 1.1 christos { 0x11, 0x05, "L-EC Uncorrectable Error" },
123 1.1 christos { 0x11, 0x06, "CIRC Unrecovered Error" },
124 1.1 christos { 0x11, 0x07, "Data Resynchronization Error" },
125 1.1 christos { 0x11, 0x08, "Incomplete Block Found" },
126 1.1 christos { 0x11, 0x09, "No Gap Found" },
127 1.1 christos { 0x11, 0x0A, "Miscorrected Error" },
128 1.1 christos { 0x11, 0x0B, "Uncorrected Read Error - Recommend Reassignment" },
129 1.1 christos { 0x11, 0x0C, "Uncorrected Read Error - Recommend Rewrite the Data" },
130 1.1 christos { 0x12, 0x00, "Address Mark Not Found for ID Field" },
131 1.1 christos { 0x13, 0x00, "Address Mark Not Found for Data Field" },
132 1.1 christos { 0x14, 0x00, "Recorded Entity Not Found" },
133 1.1 christos { 0x14, 0x01, "Record Not Found" },
134 1.1 christos { 0x14, 0x02, "Filemark or Setmark Not Found" },
135 1.1 christos { 0x14, 0x03, "End-Of-Data Not Found" },
136 1.1 christos { 0x14, 0x04, "Block Sequence Error" },
137 1.1 christos { 0x15, 0x00, "Random Positioning Error" },
138 1.1 christos { 0x15, 0x01, "Mechanical Positioning Error" },
139 1.1 christos { 0x15, 0x02, "Positioning Error Detected By Read of Medium" },
140 1.1 christos { 0x16, 0x00, "Data Synchronization Mark Error" },
141 1.1 christos { 0x17, 0x00, "Recovered Data With No Error Correction Applied" },
142 1.1 christos { 0x17, 0x01, "Recovered Data With Retries" },
143 1.1 christos { 0x17, 0x02, "Recovered Data With Positive Head Offset" },
144 1.1 christos { 0x17, 0x03, "Recovered Data With Negative Head Offset" },
145 1.1 christos { 0x17, 0x04, "Recovered Data With Retries and/or CIRC Applied" },
146 1.1 christos { 0x17, 0x05, "Recovered Data Using Previous Sector ID" },
147 1.1 christos { 0x17, 0x06, "Recovered Data Without ECC - Data Auto-Reallocated" },
148 1.1 christos { 0x17, 0x07, "Recovered Data Without ECC - Recommend Reassignment" },
149 1.1 christos { 0x17, 0x08, "Recovered Data Without ECC - Recommend Rewrite" },
150 1.1 christos { 0x18, 0x00, "Recovered Data With Error Correction Applied" },
151 1.1 christos { 0x18, 0x01, "Recovered Data With Error Correction & Retries Applied" },
152 1.1 christos { 0x18, 0x02, "Recovered Data - Data Auto-Reallocated" },
153 1.1 christos { 0x18, 0x03, "Recovered Data With CIRC" },
154 1.1 christos { 0x18, 0x04, "Recovered Data With LEC" },
155 1.1 christos { 0x18, 0x05, "Recovered Data - Recommend Reassignment" },
156 1.1 christos { 0x18, 0x06, "Recovered Data - Recommend Rewrite" },
157 1.1 christos { 0x19, 0x00, "Defect List Error" },
158 1.1 christos { 0x19, 0x01, "Defect List Not Available" },
159 1.1 christos { 0x19, 0x02, "Defect List Error in Primary List" },
160 1.1 christos { 0x19, 0x03, "Defect List Error in Grown List" },
161 1.1 christos { 0x1A, 0x00, "Parameter List Length Error" },
162 1.1 christos { 0x1B, 0x00, "Synchronous Data Transfer Error" },
163 1.1 christos { 0x1C, 0x00, "Defect List Not Found" },
164 1.1 christos { 0x1C, 0x01, "Primary Defect List Not Found" },
165 1.1 christos { 0x1C, 0x02, "Grown Defect List Not Found" },
166 1.1 christos { 0x1D, 0x00, "Miscompare During Verify Operation" },
167 1.1 christos { 0x1E, 0x00, "Recovered ID with ECC" },
168 1.1 christos { 0x20, 0x00, "Invalid Command Operation Code" },
169 1.1 christos { 0x21, 0x00, "Logical Block Address Out of Range" },
170 1.1 christos { 0x21, 0x01, "Invalid Element Address" },
171 1.1 christos { 0x22, 0x00, "Illegal Function (Should 20 00, 24 00, or 26 00)" },
172 1.1 christos { 0x24, 0x00, "Illegal Field in CDB" },
173 1.1 christos { 0x25, 0x00, "Logical Unit Not Supported" },
174 1.1 christos { 0x26, 0x00, "Invalid Field In Parameter List" },
175 1.1 christos { 0x26, 0x01, "Parameter Not Supported" },
176 1.1 christos { 0x26, 0x02, "Parameter Value Invalid" },
177 1.1 christos { 0x26, 0x03, "Threshold Parameters Not Supported" },
178 1.1 christos { 0x27, 0x00, "Write Protected" },
179 1.1 christos { 0x28, 0x00, "Not Ready To Ready Transition (Medium May Have Changed)" },
180 1.1 christos { 0x28, 0x01, "Import Or Export Element Accessed" },
181 1.1 christos { 0x29, 0x00, "Power On, Reset, or Bus Device Reset Occurred" },
182 1.1 christos { 0x2A, 0x00, "Parameters Changed" },
183 1.1 christos { 0x2A, 0x01, "Mode Parameters Changed" },
184 1.1 christos { 0x2A, 0x02, "Log Parameters Changed" },
185 1.1 christos { 0x2B, 0x00, "Copy Cannot Execute Since Host Cannot Disconnect" },
186 1.1 christos { 0x2C, 0x00, "Command Sequence Error" },
187 1.1 christos { 0x2C, 0x01, "Too Many Windows Specified" },
188 1.1 christos { 0x2C, 0x02, "Invalid Combination of Windows Specified" },
189 1.1 christos { 0x2D, 0x00, "Overwrite Error On Update In Place" },
190 1.1 christos { 0x2F, 0x00, "Commands Cleared By Another Initiator" },
191 1.1 christos { 0x30, 0x00, "Incompatible Medium Installed" },
192 1.1 christos { 0x30, 0x01, "Cannot Read Medium - Unknown Format" },
193 1.1 christos { 0x30, 0x02, "Cannot Read Medium - Incompatible Format" },
194 1.1 christos { 0x30, 0x03, "Cleaning Cartridge Installed" },
195 1.1 christos { 0x31, 0x00, "Medium Format Corrupted" },
196 1.1 christos { 0x31, 0x01, "Format Command Failed" },
197 1.1 christos { 0x32, 0x00, "No Defect Spare Location Available" },
198 1.1 christos { 0x32, 0x01, "Defect List Update Failure" },
199 1.1 christos { 0x33, 0x00, "Tape Length Error" },
200 1.1 christos { 0x36, 0x00, "Ribbon, Ink, or Toner Failure" },
201 1.1 christos { 0x37, 0x00, "Rounded Parameter" },
202 1.1 christos { 0x39, 0x00, "Saving Parameters Not Supported" },
203 1.1 christos { 0x3A, 0x00, "Medium Not Present" },
204 1.1 christos { 0x3B, 0x00, "Positioning Error" },
205 1.1 christos { 0x3B, 0x01, "Tape Position Error At Beginning-of-Medium" },
206 1.1 christos { 0x3B, 0x02, "Tape Position Error At End-of-Medium" },
207 1.1 christos { 0x3B, 0x03, "Tape or Electronic Vertical Forms Unit Not Ready" },
208 1.1 christos { 0x3B, 0x04, "Slew Failure" },
209 1.1 christos { 0x3B, 0x05, "Paper Jam" },
210 1.1 christos { 0x3B, 0x06, "Failed To Sense Top-Of-Form" },
211 1.1 christos { 0x3B, 0x07, "Failed To Sense Bottom-Of-Form" },
212 1.1 christos { 0x3B, 0x08, "Reposition Error" },
213 1.1 christos { 0x3B, 0x09, "Read Past End Of Medium" },
214 1.1 christos { 0x3B, 0x0A, "Read Past Begining Of Medium" },
215 1.1 christos { 0x3B, 0x0B, "Position Past End Of Medium" },
216 1.1 christos { 0x3B, 0x0C, "Position Past Beginning Of Medium" },
217 1.1 christos { 0x3B, 0x0D, "Medium Destination Element Full" },
218 1.1 christos { 0x3B, 0x0E, "Medium Source Element Empty" },
219 1.10 jwise { 0x3D, 0x00, "Invalid Bits In IDENTIFY Message" },
220 1.1 christos { 0x3E, 0x00, "Logical Unit Has Not Self-Configured Yet" },
221 1.1 christos { 0x3F, 0x00, "Target Operating Conditions Have Changed" },
222 1.1 christos { 0x3F, 0x01, "Microcode Has Changed" },
223 1.1 christos { 0x3F, 0x02, "Changed Operating Definition" },
224 1.1 christos { 0x3F, 0x03, "INQUIRY Data Has Changed" },
225 1.1 christos { 0x40, 0x00, "RAM FAILURE (Should Use 40 NN)" },
226 1.1 christos { 0x41, 0x00, "Data Path FAILURE (Should Use 40 NN)" },
227 1.1 christos { 0x42, 0x00, "Power-On or Self-Test FAILURE (Should Use 40 NN)" },
228 1.1 christos { 0x43, 0x00, "Message Error" },
229 1.1 christos { 0x44, 0x00, "Internal Target Failure" },
230 1.1 christos { 0x45, 0x00, "Select Or Reselect Failure" },
231 1.1 christos { 0x46, 0x00, "Unsuccessful Soft Reset" },
232 1.1 christos { 0x47, 0x00, "SCSI Parity Error" },
233 1.1 christos { 0x48, 0x00, "INITIATOR DETECTED ERROR Message Received" },
234 1.1 christos { 0x49, 0x00, "Invalid Message Error" },
235 1.1 christos { 0x4A, 0x00, "Command Phase Error" },
236 1.1 christos { 0x4B, 0x00, "Data Phase Error" },
237 1.1 christos { 0x4C, 0x00, "Logical Unit Failed Self-Configuration" },
238 1.1 christos { 0x4E, 0x00, "Overlapped Commands Attempted" },
239 1.1 christos { 0x50, 0x00, "Write Append Error" },
240 1.1 christos { 0x50, 0x01, "Write Append Position Error" },
241 1.1 christos { 0x50, 0x01, "Write Append Position Error" },
242 1.1 christos { 0x50, 0x02, "Position Error Related To Timing" },
243 1.1 christos { 0x51, 0x00, "Erase Failure" },
244 1.1 christos { 0x52, 0x00, "Cartridge Fault" },
245 1.1 christos { 0x53, 0x00, "Media Load or Eject Failed" },
246 1.1 christos { 0x53, 0x01, "Unload Tape Failure" },
247 1.1 christos { 0x53, 0x02, "Medium Removal Prevented" },
248 1.1 christos { 0x54, 0x00, "SCSI To Host System Interface Failure" },
249 1.1 christos { 0x55, 0x00, "System Resource Failure" },
250 1.1 christos { 0x57, 0x00, "Unable To Recover Table-Of-Contents" },
251 1.1 christos { 0x58, 0x00, "Generation Does Not Exist" },
252 1.1 christos { 0x59, 0x00, "Updated Block Read" },
253 1.1 christos { 0x5A, 0x00, "Operator Request or State Change Input (Unspecified)" },
254 1.1 christos { 0x5A, 0x01, "Operator Medium Removal Requested" },
255 1.1 christos { 0x5A, 0x02, "Operator Selected Write Protect" },
256 1.1 christos { 0x5A, 0x03, "Operator Selected Write Permit" },
257 1.1 christos { 0x5B, 0x00, "Log Exception" },
258 1.1 christos { 0x5B, 0x01, "Threshold Condition Met" },
259 1.1 christos { 0x5B, 0x02, "Log Counter At Maximum" },
260 1.1 christos { 0x5B, 0x03, "Log List Codes Exhausted" },
261 1.1 christos { 0x5C, 0x00, "RPL Status Change" },
262 1.1 christos { 0x5C, 0x01, "Spindles Synchronized" },
263 1.1 christos { 0x5C, 0x02, "Spindles Not Synchronized" },
264 1.1 christos { 0x60, 0x00, "Lamp Failure" },
265 1.1 christos { 0x61, 0x00, "Video Acquisition Error" },
266 1.1 christos { 0x61, 0x01, "Unable To Acquire Video" },
267 1.1 christos { 0x61, 0x02, "Out Of Focus" },
268 1.1 christos { 0x62, 0x00, "Scan Head Positioning Error" },
269 1.1 christos { 0x63, 0x00, "End Of User Area Encountered On This Track" },
270 1.1 christos { 0x64, 0x00, "Illegal Mode For This Track" },
271 1.1 christos { 0x00, 0x00, NULL }
272 1.1 christos };
273 1.1 christos
274 1.1 christos static __inline void asc2ascii __P((unsigned char, unsigned char, char *));
275 1.1 christos
276 1.1 christos static __inline void
277 1.1 christos asc2ascii(asc, ascq, result)
278 1.1 christos unsigned char asc, ascq;
279 1.1 christos char *result;
280 1.1 christos {
281 1.1 christos register int i = 0;
282 1.1 christos
283 1.1 christos while (adesc[i].description != NULL) {
284 1.1 christos if (adesc[i].asc == asc && adesc[i].ascq == ascq)
285 1.1 christos break;
286 1.1 christos i++;
287 1.1 christos }
288 1.1 christos if (adesc[i].description == NULL) {
289 1.1 christos if (asc == 0x40 && ascq != 0)
290 1.1 christos (void)sprintf(result,
291 1.1 christos "Diagnostic Failure on Component 0x%02x",
292 1.1 christos ascq & 0xff);
293 1.1 christos else
294 1.1 christos (void)sprintf(result, "ASC 0x%02x ASCQ 0x%02x",
295 1.1 christos asc & 0xff, ascq & 0xff);
296 1.1 christos } else
297 1.1 christos (void)strcpy(result, adesc[i].description);
298 1.1 christos }
299 1.1 christos
300 1.1 christos void
301 1.9 bouyer scsipi_print_sense_data(sense, verbosity)
302 1.1 christos struct scsipi_sense_data *sense;
303 1.1 christos int verbosity;
304 1.1 christos {
305 1.1 christos int32_t info;
306 1.1 christos register int i, j, k;
307 1.1 christos char *sbs, *s = (char *) sense;
308 1.1 christos
309 1.1 christos /*
310 1.1 christos * Basics- print out SENSE KEY
311 1.1 christos */
312 1.9 bouyer printf(" SENSE KEY: %s", scsipi_decode_sense(s, 0));
313 1.1 christos
314 1.1 christos /*
315 1.1 christos * Print out, unqualified but aligned, FMK, EOM and ILI status.
316 1.1 christos */
317 1.1 christos if (s[2] & 0xe0) {
318 1.1 christos char pad;
319 1.4 mjacob printf("\n ");
320 1.1 christos pad = ' ';
321 1.1 christos if (s[2] & SSD_FILEMARK) {
322 1.1 christos printf("%c Filemark Detected", pad);
323 1.1 christos pad = ',';
324 1.1 christos }
325 1.1 christos if (s[2] & SSD_EOM) {
326 1.1 christos printf("%c EOM Detected", pad);
327 1.1 christos pad = ',';
328 1.1 christos }
329 1.1 christos if (s[2] & SSD_ILI)
330 1.1 christos printf("%c Incorrect Length Indicator Set", pad);
331 1.1 christos }
332 1.1 christos
333 1.1 christos /*
334 1.1 christos * Now we should figure out, based upon device type, how
335 1.1 christos * to format the information field. Unfortunately, that's
336 1.1 christos * not convenient here, so we'll print it as a signed
337 1.1 christos * 32 bit integer.
338 1.1 christos */
339 1.1 christos info = _4btol(&s[3]);
340 1.1 christos if (info)
341 1.1 christos printf("\n INFO FIELD: %d", info);
342 1.1 christos
343 1.1 christos /*
344 1.1 christos * Now we check additional length to see whether there is
345 1.1 christos * more information to extract.
346 1.1 christos */
347 1.1 christos
348 1.1 christos /* enough for command specific information? */
349 1.5 mjacob if (((unsigned int) s[7]) < 4) {
350 1.1 christos printf("\n");
351 1.1 christos return;
352 1.1 christos }
353 1.1 christos info = _4btol(&s[8]);
354 1.1 christos if (info)
355 1.1 christos printf("\n COMMAND INFO: %d (0x%x)", info, info);
356 1.1 christos
357 1.1 christos /*
358 1.1 christos * Decode ASC && ASCQ info, plus FRU, plus the rest...
359 1.1 christos */
360 1.1 christos
361 1.9 bouyer sbs = scsipi_decode_sense(s, 1);
362 1.1 christos if (sbs)
363 1.1 christos printf("\n ASC/ASCQ: %s", sbs);
364 1.1 christos if (s[14] != 0)
365 1.1 christos printf("\n FRU CODE: 0x%x", s[14] & 0xff);
366 1.9 bouyer sbs = scsipi_decode_sense(s, 3);
367 1.1 christos if (sbs)
368 1.1 christos printf("\n SKSV: %s", sbs);
369 1.1 christos printf("\n");
370 1.1 christos if (verbosity == 0) {
371 1.1 christos printf("\n");
372 1.1 christos return;
373 1.1 christos }
374 1.1 christos
375 1.1 christos /*
376 1.1 christos * Now figure whether we should print any additional informtion.
377 1.1 christos *
378 1.1 christos * Where should we start from? If we had SKSV data,
379 1.1 christos * start from offset 18, else from offset 15.
380 1.1 christos *
381 1.1 christos * From that point until the end of the buffer, check for any
382 1.1 christos * nonzero data. If we have some, go back and print the lot,
383 1.1 christos * otherwise we're done.
384 1.1 christos */
385 1.1 christos if (sbs)
386 1.1 christos i = 18;
387 1.1 christos else
388 1.1 christos i = 15;
389 1.1 christos for (j = i; j < sizeof (*sense); j++)
390 1.1 christos if (s[j])
391 1.1 christos break;
392 1.1 christos if (j == sizeof (*sense))
393 1.1 christos return;
394 1.1 christos
395 1.1 christos printf("\n Additional Sense Information (byte %d out...):\n", i);
396 1.1 christos if (i == 15) {
397 1.1 christos printf("\n\t%2d:", i);
398 1.1 christos k = 7;
399 1.1 christos } else {
400 1.1 christos printf("\n\t%2d:", i);
401 1.1 christos k = 2;
402 1.1 christos j -= 2;
403 1.1 christos }
404 1.1 christos while (j > 0) {
405 1.1 christos if (i >= sizeof (*sense))
406 1.1 christos break;
407 1.1 christos if (k == 8) {
408 1.1 christos k = 0;
409 1.1 christos printf("\n\t%2d:", i);
410 1.1 christos }
411 1.1 christos printf(" 0x%02x", s[i] & 0xff);
412 1.1 christos k++;
413 1.1 christos j--;
414 1.1 christos i++;
415 1.1 christos }
416 1.1 christos printf("\n\n");
417 1.1 christos }
418 1.1 christos
419 1.1 christos char *
420 1.9 bouyer scsipi_decode_sense(sinfo, flag)
421 1.1 christos void *sinfo;
422 1.1 christos int flag;
423 1.1 christos {
424 1.1 christos unsigned char *snsbuf;
425 1.1 christos unsigned char skey;
426 1.1 christos static char rqsbuf[132];
427 1.1 christos
428 1.1 christos skey = 0;
429 1.1 christos
430 1.1 christos snsbuf = (unsigned char *) sinfo;
431 1.1 christos if (flag == 0 || flag == 2 || flag == 3)
432 1.1 christos skey = snsbuf[2] & 0xf;
433 1.1 christos if (flag == 0) { /* Sense Key Only */
434 1.1 christos (void) strcpy(rqsbuf, sense_keys[skey]);
435 1.1 christos return (rqsbuf);
436 1.1 christos } else if (flag == 1) { /* ASC/ASCQ Only */
437 1.1 christos asc2ascii(snsbuf[12], snsbuf[13], rqsbuf);
438 1.1 christos return (rqsbuf);
439 1.1 christos } else if (flag == 2) { /* Sense Key && ASC/ASCQ */
440 1.1 christos auto char localbuf[64];
441 1.1 christos asc2ascii(snsbuf[12], snsbuf[13], localbuf);
442 1.1 christos (void) sprintf(rqsbuf, "%s, %s", sense_keys[skey], localbuf);
443 1.1 christos return (rqsbuf);
444 1.1 christos } else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) {
445 1.1 christos /*
446 1.1 christos * SKSV Data
447 1.1 christos */
448 1.1 christos switch (skey) {
449 1.4 mjacob case SKEY_ILLEGAL_REQUEST:
450 1.1 christos if (snsbuf[15] & 0x8)
451 1.1 christos (void)sprintf(rqsbuf,
452 1.1 christos "Error in %s, Offset %d, bit %d",
453 1.1 christos (snsbuf[15] & 0x40)? "CDB" : "Parameters",
454 1.1 christos (snsbuf[16] & 0xff) << 8 |
455 1.1 christos (snsbuf[17] & 0xff), snsbuf[15] & 0x7);
456 1.1 christos else
457 1.1 christos (void)sprintf(rqsbuf,
458 1.1 christos "Error in %s, Offset %d",
459 1.1 christos (snsbuf[15] & 0x40)? "CDB" : "Parameters",
460 1.1 christos (snsbuf[16] & 0xff) << 8 |
461 1.1 christos (snsbuf[17] & 0xff));
462 1.1 christos return (rqsbuf);
463 1.6 mjacob case SKEY_RECOVERED_ERROR:
464 1.4 mjacob case SKEY_MEDIUM_ERROR:
465 1.4 mjacob case SKEY_HARDWARE_ERROR:
466 1.1 christos (void)sprintf(rqsbuf, "Actual Retry Count: %d",
467 1.1 christos (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
468 1.1 christos return (rqsbuf);
469 1.4 mjacob case SKEY_NOT_READY:
470 1.1 christos (void)sprintf(rqsbuf, "Progress Indicator: %d",
471 1.1 christos (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
472 1.1 christos return (rqsbuf);
473 1.1 christos default:
474 1.1 christos break;
475 1.1 christos }
476 1.1 christos }
477 1.1 christos return (NULL);
478 1.1 christos }
479 1.1 christos
480 1.1 christos void
481 1.9 bouyer scsipi_print_sense(xs, verbosity)
482 1.1 christos struct scsipi_xfer *xs;
483 1.1 christos int verbosity;
484 1.1 christos {
485 1.3 mjacob int i, j;
486 1.3 mjacob
487 1.1 christos xs->sc_link->sc_print_addr(xs->sc_link);
488 1.3 mjacob printf(" Check Condition on CDB: 0x%02x", xs->cmd->opcode);
489 1.3 mjacob
490 1.3 mjacob switch (CDB_GROUPID(xs->cmd->opcode)) {
491 1.3 mjacob case CDB_GROUPID_0:
492 1.3 mjacob j = CDB_GROUP0;
493 1.3 mjacob break;
494 1.3 mjacob case CDB_GROUPID_1:
495 1.3 mjacob j = CDB_GROUP1;
496 1.3 mjacob break;
497 1.3 mjacob case CDB_GROUPID_2:
498 1.3 mjacob j = CDB_GROUP2;
499 1.3 mjacob break;
500 1.3 mjacob case CDB_GROUPID_3:
501 1.3 mjacob j = CDB_GROUP3;
502 1.3 mjacob break;
503 1.3 mjacob case CDB_GROUPID_4:
504 1.3 mjacob j = CDB_GROUP4;
505 1.3 mjacob break;
506 1.3 mjacob case CDB_GROUPID_5:
507 1.3 mjacob j = CDB_GROUP5;
508 1.3 mjacob break;
509 1.3 mjacob case CDB_GROUPID_6:
510 1.3 mjacob j = CDB_GROUP6;
511 1.3 mjacob break;
512 1.3 mjacob case CDB_GROUPID_7:
513 1.3 mjacob j = CDB_GROUP7;
514 1.3 mjacob break;
515 1.3 mjacob default:
516 1.3 mjacob j = 0;
517 1.3 mjacob }
518 1.3 mjacob if (j == 0)
519 1.3 mjacob j = sizeof (xs->cmd->bytes);
520 1.3 mjacob for (i = 0; i < j-1; i++) /* already done the opcode */
521 1.3 mjacob printf(" %02x", xs->cmd->bytes[i]);
522 1.3 mjacob printf("\n");
523 1.9 bouyer scsipi_print_sense_data(&xs->sense.scsi_sense, verbosity);
524 1.1 christos }
525