xref: /netbsd/usr.sbin/mmcformat/uscsi_sense.c (revision 0e6570fc)
1*0e6570fcSandvar /* $NetBSD: uscsi_sense.c,v 1.2 2022/01/24 09:14:38 andvar Exp $	*/
2e979c658Sreinoud 
3e979c658Sreinoud /*-
4e979c658Sreinoud  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5e979c658Sreinoud  * All rights reserved.
6e979c658Sreinoud  *
7e979c658Sreinoud  * This code is derived from software contributed to The NetBSD Foundation
8e979c658Sreinoud  * by Charles M. Hannum.
9e979c658Sreinoud  *
10e979c658Sreinoud  * Redistribution and use in source and binary forms, with or without
11e979c658Sreinoud  * modification, are permitted provided that the following conditions
12e979c658Sreinoud  * are met:
13e979c658Sreinoud  * 1. Redistributions of source code must retain the above copyright
14e979c658Sreinoud  *    notice, this list of conditions and the following disclaimer.
15e979c658Sreinoud  * 2. Redistributions in binary form must reproduce the above copyright
16e979c658Sreinoud  *    notice, this list of conditions and the following disclaimer in the
17e979c658Sreinoud  *    documentation and/or other materials provided with the distribution.
18e979c658Sreinoud  *
19e979c658Sreinoud  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20e979c658Sreinoud  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21e979c658Sreinoud  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22e979c658Sreinoud  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23e979c658Sreinoud  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24e979c658Sreinoud  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25e979c658Sreinoud  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26e979c658Sreinoud  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27e979c658Sreinoud  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28e979c658Sreinoud  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29e979c658Sreinoud  * POSSIBILITY OF SUCH DAMAGE.
30e979c658Sreinoud  *
31e979c658Sreinoud  * Small changes made by Reinoud Zandijk <reinoud@netbsd.org>
32e979c658Sreinoud  */
33e979c658Sreinoud 
34e979c658Sreinoud /*
35e979c658Sreinoud  * SCSI sense interpretation.  Lifted from src/sys/dev/scsipi/scsipi_verbose.c,
36e979c658Sreinoud  * and modified for userland.
37e979c658Sreinoud  */
38e979c658Sreinoud 
39e979c658Sreinoud #include <stdio.h>
40e979c658Sreinoud #include <string.h>
41e979c658Sreinoud #include <sys/types.h>
42e979c658Sreinoud #include <inttypes.h>
43e979c658Sreinoud 
44e979c658Sreinoud #include "uscsilib.h"
45e979c658Sreinoud 
46e979c658Sreinoud 
47e979c658Sreinoud static const char *sense_keys[16] = {
48e979c658Sreinoud 	"No Additional Sense",
49e979c658Sreinoud 	"Recovered Error",
50e979c658Sreinoud 	"Not Ready",
51e979c658Sreinoud 	"Media Error",
52e979c658Sreinoud 	"Hardware Error",
53e979c658Sreinoud 	"Illegal Request",
54e979c658Sreinoud 	"Unit Attention",
55e979c658Sreinoud 	"Write Protected",
56e979c658Sreinoud 	"Blank Check",
57e979c658Sreinoud 	"Vendor Unique",
58e979c658Sreinoud 	"Copy Aborted",
59e979c658Sreinoud 	"Aborted Command",
60e979c658Sreinoud 	"Equal Error",
61e979c658Sreinoud 	"Volume Overflow",
62e979c658Sreinoud 	"Miscompare Error",
63e979c658Sreinoud 	"Reserved"
64e979c658Sreinoud };
65e979c658Sreinoud 
66e979c658Sreinoud /*
67e979c658Sreinoud  * The current version of this list can be obtained from
68e979c658Sreinoud  * <ftp://ftp.t10.org/t10/drafts/spc3/asc-num.txt>
69e979c658Sreinoud  */
70e979c658Sreinoud 
71e979c658Sreinoud static const struct {
72e979c658Sreinoud 	unsigned char asc;
73e979c658Sreinoud 	unsigned char ascq;
74e979c658Sreinoud 	const char *description;
75e979c658Sreinoud } adesc[] = {
76e979c658Sreinoud { 0x00, 0x00, "No Additional Sense Information" },
77e979c658Sreinoud { 0x00, 0x01, "Filemark Detected" },
78e979c658Sreinoud { 0x00, 0x02, "End-Of-Partition/Medium Detected" },
79e979c658Sreinoud { 0x00, 0x03, "Setmark Detected" },
80e979c658Sreinoud { 0x00, 0x04, "Beginning-Of-Partition/Medium Detected" },
81e979c658Sreinoud { 0x00, 0x05, "End-Of-Data Detected" },
82e979c658Sreinoud { 0x00, 0x06, "I/O Process Terminated" },
83e979c658Sreinoud { 0x00, 0x11, "Audio Play Operation In Progress" },
84e979c658Sreinoud { 0x00, 0x12, "Audio Play Operation Paused" },
85e979c658Sreinoud { 0x00, 0x13, "Audio Play Operation Successfully Completed" },
86e979c658Sreinoud { 0x00, 0x14, "Audio Play Operation Stopped Due to Error" },
87e979c658Sreinoud { 0x00, 0x15, "No Current Audio Status To Return" },
88e979c658Sreinoud { 0x00, 0x16, "Operation In Progress" },
89e979c658Sreinoud { 0x00, 0x17, "Cleaning Requested" },
90e979c658Sreinoud { 0x00, 0x18, "Erase Operation In Progress" },
91e979c658Sreinoud { 0x00, 0x19, "Locate Operation In Progress" },
92e979c658Sreinoud { 0x00, 0x1A, "Rewind Operation In Progress" },
93e979c658Sreinoud { 0x00, 0x1B, "Set Capacity Operation In Progess" },
94e979c658Sreinoud { 0x00, 0x1C, "Verify Operation In Progress" },
95e979c658Sreinoud { 0x01, 0x00, "No Index/Sector Signal" },
96e979c658Sreinoud { 0x02, 0x00, "No Seek Complete" },
97e979c658Sreinoud { 0x03, 0x00, "Peripheral Device Write Fault" },
98e979c658Sreinoud { 0x03, 0x01, "No Write Current" },
99e979c658Sreinoud { 0x03, 0x02, "Excessive Write Errors" },
100e979c658Sreinoud { 0x04, 0x00, "Logical Unit Not Ready, Cause Not Reportable" },
101e979c658Sreinoud { 0x04, 0x01, "Logical Unit Is in Process Of Becoming Ready" },
102e979c658Sreinoud { 0x04, 0x02, "Logical Unit Not Ready, Initialization Command Required" },
103e979c658Sreinoud { 0x04, 0x03, "Logical Unit Not Ready, Manual Intervention Required" },
104e979c658Sreinoud { 0x04, 0x04, "Logical Unit Not Ready, Format In Progress" },
105e979c658Sreinoud { 0x04, 0x05, "Logical Unit Not Ready, Rebuild In Progress" },
106e979c658Sreinoud { 0x04, 0x06, "Logical Unit Not Ready, Recalculation In Progress" },
107e979c658Sreinoud { 0x04, 0x07, "Logical Unit Not Ready, Operation In Progress" },
108e979c658Sreinoud { 0x04, 0x08, "Logical Unit Not Ready, Long Write In Progress" },
109e979c658Sreinoud { 0x04, 0x09, "Logical Unit Not Ready, Self-Test In Progress" },
110e979c658Sreinoud { 0x04, 0x0A, "Logical Unit Not Accessible, Asymmetric Access State "
111e979c658Sreinoud 								"Transition" },
112e979c658Sreinoud { 0x04, 0x0B, "Logical Unit Not Accessible, Target Port In Standby State" },
113e979c658Sreinoud { 0x04, 0x0C, "Logical Unit Not Accessible, Target Port In Unavailable State" },
114e979c658Sreinoud { 0x04, 0x10, "Logical Unit Not Ready, Auxiliary Memory Not Accessible" },
115e979c658Sreinoud { 0x04, 0x11, "Logical Unit Not Ready, Notify (Enable_Spinup) Required" },
116e979c658Sreinoud { 0x05, 0x00, "Logical Unit Does Not Respond To Selection" },
117e979c658Sreinoud { 0x06, 0x00, "No Reference Position Found" },
118e979c658Sreinoud { 0x07, 0x00, "Multiple Peripheral Devices Selected" },
119e979c658Sreinoud { 0x08, 0x00, "Logical Unit Communication Failure" },
120e979c658Sreinoud { 0x08, 0x01, "Logical Unit Communication Timeout" },
121e979c658Sreinoud { 0x08, 0x02, "Logical Unit Communication Parity Error" },
122e979c658Sreinoud { 0x08, 0x03, "Logical Unit Communication CRC Error" },
123e979c658Sreinoud { 0x08, 0x04, "Unreachable Copy Target" },
124e979c658Sreinoud { 0x09, 0x00, "Track Following Error" },
125e979c658Sreinoud { 0x09, 0x01, "Tracking Servo Failure" },
126e979c658Sreinoud { 0x09, 0x02, "Focus Servo Failure" },
127e979c658Sreinoud { 0x09, 0x03, "Spindle Servo Failure" },
128e979c658Sreinoud { 0x09, 0x04, "Head Select Fault" },
129e979c658Sreinoud { 0x0A, 0x00, "Error Log Overflow" },
130e979c658Sreinoud { 0x0B, 0x00, "Warning" },
131e979c658Sreinoud { 0x0B, 0x01, "Warning - Specified Temperature Exceeded" },
132e979c658Sreinoud { 0x0B, 0x02, "Warning - Enclosure Degraded" },
133e979c658Sreinoud { 0x0C, 0x00, "Write Error" },
134e979c658Sreinoud { 0x0C, 0x01, "Write Error - Recovered with Auto Reallocation" },
135e979c658Sreinoud { 0x0C, 0x02, "Write Error - Auto Reallocate Failed" },
136e979c658Sreinoud { 0x0C, 0x03, "Write Error - Recommend Reassignment" },
137e979c658Sreinoud { 0x0C, 0x04, "Compression Check Miscompare Error" },
138e979c658Sreinoud { 0x0C, 0x05, "Data Expansion Occurred During Compression" },
139e979c658Sreinoud { 0x0C, 0x06, "Block Not Compressible" },
140e979c658Sreinoud { 0x0C, 0x07, "Write Error - Recovery Needed" },
141e979c658Sreinoud { 0x0C, 0x08, "Write Error - Recovery Failed" },
142e979c658Sreinoud { 0x0C, 0x09, "Write Error - Loss Of Streaming" },
143e979c658Sreinoud { 0x0C, 0x0A, "Write Error - Padding Blocks Added" },
144e979c658Sreinoud { 0x0C, 0x0B, "Auxiliary Memory Write Error" },
145e979c658Sreinoud { 0x0C, 0x0C, "Write Error - Unexpected Unsolicited Data" },
146e979c658Sreinoud { 0x0C, 0x0D, "Write Error - Not Enough Unsolicited Data" },
147e979c658Sreinoud { 0x0D, 0x00, "Error Detected By Third Party Temporary Initiator" },
148e979c658Sreinoud { 0x0D, 0x01, "Third Party Device Failure" },
149e979c658Sreinoud { 0x0D, 0x02, "Copy Target Device Not Reachable" },
150e979c658Sreinoud { 0x0D, 0x03, "Incorrect Copy Target Device Type" },
151e979c658Sreinoud { 0x0D, 0x04, "Copy Target Device Data Underrun" },
152e979c658Sreinoud { 0x0D, 0x05, "Copy Target Device Data Overrun" },
153e979c658Sreinoud { 0x0E, 0x00, "Invalid Information Unit" },
154e979c658Sreinoud { 0x0E, 0x01, "Information Unit Too Short" },
155e979c658Sreinoud { 0x0E, 0x02, "Information Unit Too Long" },
156e979c658Sreinoud { 0x10, 0x00, "ID CRC Or ECC Error" },
157e979c658Sreinoud { 0x11, 0x00, "Unrecovered Read Error" },
158e979c658Sreinoud { 0x11, 0x01, "Read Retries Exhausted" },
159e979c658Sreinoud { 0x11, 0x02, "Error Too Long To Correct" },
160e979c658Sreinoud { 0x11, 0x03, "Multiple Read Errors" },
161e979c658Sreinoud { 0x11, 0x04, "Unrecovered Read Error - Auto Reallocate Failed" },
162e979c658Sreinoud { 0x11, 0x05, "L-EC Uncorrectable Error" },
163e979c658Sreinoud { 0x11, 0x06, "CIRC Unrecovered Error" },
164e979c658Sreinoud { 0x11, 0x07, "Data Re-synchronization Error" },
165e979c658Sreinoud { 0x11, 0x08, "Incomplete Block Read" },
166e979c658Sreinoud { 0x11, 0x09, "No Gap Found" },
167e979c658Sreinoud { 0x11, 0x0A, "Miscorrected Error" },
168e979c658Sreinoud { 0x11, 0x0B, "Uncorrected Read Error - Recommend Reassignment" },
169e979c658Sreinoud { 0x11, 0x0C, "Uncorrected Read Error - Recommend Rewrite the Data" },
170e979c658Sreinoud { 0x11, 0x0D, "De-Compression CRC Error" },
171e979c658Sreinoud { 0x11, 0x0E, "Cannot Decompress Using Declared Algorithm" },
172e979c658Sreinoud { 0x11, 0x0F, "Error Reading UPC/EAN Number" },
173e979c658Sreinoud { 0x11, 0x10, "Error Reading ISRC Number" },
174e979c658Sreinoud { 0x11, 0x11, "Read Error - Loss Of Streaming" },
175e979c658Sreinoud { 0x11, 0x12, "Auxiliary Memory Read Error" },
176e979c658Sreinoud { 0x11, 0x13, "Read Error - Failed Retransmission Request" },
177e979c658Sreinoud { 0x12, 0x00, "Address Mark Not Found for ID Field" },
178e979c658Sreinoud { 0x13, 0x00, "Address Mark Not Found for Data Field" },
179e979c658Sreinoud { 0x14, 0x00, "Recorded Entity Not Found" },
180e979c658Sreinoud { 0x14, 0x01, "Record Not Found" },
181e979c658Sreinoud { 0x14, 0x02, "Filemark or Setmark Not Found" },
182e979c658Sreinoud { 0x14, 0x03, "End-Of-Data Not Found" },
183e979c658Sreinoud { 0x14, 0x04, "Block Sequence Error" },
184e979c658Sreinoud { 0x14, 0x05, "Record Not Found - Recommend Reassignment" },
185e979c658Sreinoud { 0x14, 0x06, "Record Not Found - Data Auto-Reallocated" },
186e979c658Sreinoud { 0x14, 0x07, "Locate Operation Failure" },
187e979c658Sreinoud { 0x15, 0x00, "Random Positioning Error" },
188e979c658Sreinoud { 0x15, 0x01, "Mechanical Positioning Error" },
189e979c658Sreinoud { 0x15, 0x02, "Positioning Error Detected By Read of Medium" },
190e979c658Sreinoud { 0x16, 0x00, "Data Synchronization Mark Error" },
191e979c658Sreinoud { 0x16, 0x01, "Data Sync Error - Data Rewritten" },
192e979c658Sreinoud { 0x16, 0x02, "Data Sync Error - Recommend Rewrite" },
193e979c658Sreinoud { 0x16, 0x03, "Data Sync Error - Data Auto-Reallocated" },
194e979c658Sreinoud { 0x16, 0x04, "Data Sync Error - Recommend Reassignment" },
195e979c658Sreinoud { 0x17, 0x00, "Recovered Data With No Error Correction Applied" },
196e979c658Sreinoud { 0x17, 0x01, "Recovered Data With Retries" },
197e979c658Sreinoud { 0x17, 0x02, "Recovered Data With Positive Head Offset" },
198e979c658Sreinoud { 0x17, 0x03, "Recovered Data With Negative Head Offset" },
199e979c658Sreinoud { 0x17, 0x04, "Recovered Data With Retries and/or CIRC Applied" },
200e979c658Sreinoud { 0x17, 0x05, "Recovered Data Using Previous Sector ID" },
201e979c658Sreinoud { 0x17, 0x06, "Recovered Data Without ECC - Data Auto-Reallocated" },
202e979c658Sreinoud { 0x17, 0x07, "Recovered Data Without ECC - Recommend Reassignment" },
203e979c658Sreinoud { 0x17, 0x08, "Recovered Data Without ECC - Recommend Rewrite" },
204e979c658Sreinoud { 0x17, 0x09, "Recovered Data Without ECC - Data Rewritten" },
205e979c658Sreinoud { 0x18, 0x00, "Recovered Data With Error Correction Applied" },
206e979c658Sreinoud { 0x18, 0x01, "Recovered Data With Error Correction & Retries Applied" },
207e979c658Sreinoud { 0x18, 0x02, "Recovered Data - Data Auto-Reallocated" },
208e979c658Sreinoud { 0x18, 0x03, "Recovered Data With CIRC" },
209e979c658Sreinoud { 0x18, 0x04, "Recovered Data With LEC" },
210e979c658Sreinoud { 0x18, 0x05, "Recovered Data - Recommend Reassignment" },
211e979c658Sreinoud { 0x18, 0x06, "Recovered Data - Recommend Rewrite" },
212e979c658Sreinoud { 0x18, 0x07, "Recovered Data With ECC - Data Rewritten" },
213e979c658Sreinoud { 0x18, 0x08, "Recovered Data With Linking" },
214e979c658Sreinoud { 0x19, 0x00, "Defect List Error" },
215e979c658Sreinoud { 0x19, 0x01, "Defect List Not Available" },
216e979c658Sreinoud { 0x19, 0x02, "Defect List Error in Primary List" },
217e979c658Sreinoud { 0x19, 0x03, "Defect List Error in Grown List" },
218e979c658Sreinoud { 0x1A, 0x00, "Parameter List Length Error" },
219e979c658Sreinoud { 0x1B, 0x00, "Synchronous Data Transfer Error" },
220e979c658Sreinoud { 0x1C, 0x00, "Defect List Not Found" },
221e979c658Sreinoud { 0x1C, 0x01, "Primary Defect List Not Found" },
222e979c658Sreinoud { 0x1C, 0x02, "Grown Defect List Not Found" },
223e979c658Sreinoud { 0x1D, 0x00, "Miscompare During Verify Operation" },
224e979c658Sreinoud { 0x1E, 0x00, "Recovered ID with ECC Correction" },
225e979c658Sreinoud { 0x1F, 0x00, "Partial Defect List Transfer" },
226e979c658Sreinoud { 0x20, 0x00, "Invalid Command Operation Code" },
227e979c658Sreinoud { 0x20, 0x01, "Access Denied - Initiator Pending-Enrolled" },
228e979c658Sreinoud { 0x20, 0x02, "Access Denied - No Access Rights" },
229e979c658Sreinoud { 0x20, 0x03, "Access Denied - Invalid Mgmt ID Key" },
230e979c658Sreinoud { 0x20, 0x04, "Illegal Command While In Write Capable State" },
231e979c658Sreinoud { 0x20, 0x06, "Illegal Command While In Explicit Address Mode" },
232e979c658Sreinoud { 0x20, 0x07, "Illegal Command While In Implicit Address Mode" },
233e979c658Sreinoud { 0x20, 0x08, "Access Denied - Enrollment Conflict" },
234e979c658Sreinoud { 0x20, 0x09, "Access Denied - Invalid LU Identifer" },
235e979c658Sreinoud { 0x20, 0x0A, "Access Denied - Invalid Proxy Token" },
236e979c658Sreinoud { 0x20, 0x0B, "Access Denied - ACL LUN Conflict" },
237e979c658Sreinoud { 0x21, 0x00, "Logical Block Address Out of Range" },
238e979c658Sreinoud { 0x21, 0x01, "Invalid Element Address" },
239e979c658Sreinoud { 0x21, 0x02, "Invalid Address For Write" },
240e979c658Sreinoud { 0x22, 0x00, "Illegal Function (Use 20 00, 24 00, or 26 00)" },
241e979c658Sreinoud { 0x24, 0x00, "Illegal Field in CDB" },
242e979c658Sreinoud { 0x24, 0x01, "CDB Decryption Error" },
243e979c658Sreinoud { 0x24, 0x04, "Security Audit Value Frozen" },
244e979c658Sreinoud { 0x24, 0x05, "Security Working Key Frozen" },
245e979c658Sreinoud { 0x24, 0x06, "Nonce Not Unique" },
246e979c658Sreinoud { 0x24, 0x07, "Nonce Timestamp Out Of Range" },
247e979c658Sreinoud { 0x25, 0x00, "Logical Unit Not Supported" },
248e979c658Sreinoud { 0x26, 0x00, "Invalid Field In Parameter List" },
249e979c658Sreinoud { 0x26, 0x01, "Parameter Not Supported" },
250e979c658Sreinoud { 0x26, 0x02, "Parameter Value Invalid" },
251e979c658Sreinoud { 0x26, 0x03, "Threshold Parameters Not Supported" },
252e979c658Sreinoud { 0x26, 0x04, "Invalid Release Of Persistent Reservation" },
253e979c658Sreinoud { 0x26, 0x05, "Data Decryption Error" },
254e979c658Sreinoud { 0x26, 0x06, "Too Many Target Descriptors" },
255e979c658Sreinoud { 0x26, 0x07, "Unsupported Target Descriptor Type Code" },
256e979c658Sreinoud { 0x26, 0x08, "Too Many Segment Descriptors" },
257e979c658Sreinoud { 0x26, 0x09, "Unsupported Segment Descriptor Type Code" },
258e979c658Sreinoud { 0x26, 0x0A, "Unexpected Inexact Segment" },
259e979c658Sreinoud { 0x26, 0x0B, "Inline Data Length Exceeded" },
260e979c658Sreinoud { 0x26, 0x0C, "Invalid Operation For Copy Source Or Destination" },
261e979c658Sreinoud { 0x26, 0x0D, "Copy Segment Granularity Violation" },
262e979c658Sreinoud { 0x26, 0x0E, "Invalid Parameter While Port Is Enabled" },
263e979c658Sreinoud { 0x27, 0x00, "Write Protected" },
264e979c658Sreinoud { 0x27, 0x01, "Hardware Write Protected" },
265e979c658Sreinoud { 0x27, 0x02, "Logical Unit Software Write Protected" },
266e979c658Sreinoud { 0x27, 0x03, "Associated Write Protect" },
267e979c658Sreinoud { 0x27, 0x04, "Persistent Write Protect" },
268e979c658Sreinoud { 0x27, 0x05, "Permanent Write Protect" },
269e979c658Sreinoud { 0x27, 0x06, "Conditional Write Protect" },
270e979c658Sreinoud { 0x28, 0x00, "Not Ready To Ready Transition (Medium May Have Changed)" },
271e979c658Sreinoud { 0x28, 0x01, "Import Or Export Element Accessed" },
272e979c658Sreinoud { 0x29, 0x00, "Power On, Reset, or Bus Device Reset Occurred" },
273e979c658Sreinoud { 0x29, 0x01, "Power On Occurred" },
274e979c658Sreinoud { 0x29, 0x02, "SCSI Bus Reset Occurred" },
275e979c658Sreinoud { 0x29, 0x03, "Bus Device Reset Function Occurred" },
276e979c658Sreinoud { 0x29, 0x04, "Device Internal Reset" },
277e979c658Sreinoud { 0x29, 0x05, "Transceiver Mode Changed To Single-Ended" },
278e979c658Sreinoud { 0x29, 0x06, "Transceiver Mode Changed To LVD" },
279e979c658Sreinoud { 0x29, 0x07, "I_T Nexus Loss Occurred" },
280e979c658Sreinoud { 0x2A, 0x00, "Parameters Changed" },
281e979c658Sreinoud { 0x2A, 0x01, "Mode Parameters Changed" },
282e979c658Sreinoud { 0x2A, 0x02, "Log Parameters Changed" },
283e979c658Sreinoud { 0x2A, 0x03, "Reservations Preempted" },
284e979c658Sreinoud { 0x2A, 0x04, "Reservations Released" },
285e979c658Sreinoud { 0x2A, 0x05, "Registrations Preempted" },
286e979c658Sreinoud { 0x2A, 0x06, "Asymmetric Access State Changed" },
287e979c658Sreinoud { 0x2A, 0x07, "Implicit Asymmetric Access State Transition Failed" },
288e979c658Sreinoud { 0x2B, 0x00, "Copy Cannot Execute Since Host Cannot Disconnect" },
289e979c658Sreinoud { 0x2C, 0x00, "Command Sequence Error" },
290e979c658Sreinoud { 0x2C, 0x01, "Too Many Windows Specified" },
291e979c658Sreinoud { 0x2C, 0x02, "Invalid Combination of Windows Specified" },
292e979c658Sreinoud { 0x2C, 0x03, "Current Program Area Is Not Empty" },
293e979c658Sreinoud { 0x2C, 0x04, "Current Program Area Is Empty" },
294e979c658Sreinoud { 0x2C, 0x05, "Illegal Power Condition Request" },
295e979c658Sreinoud { 0x2C, 0x06, "Persistent Prevent Conflict" },
296e979c658Sreinoud { 0x2C, 0x07, "Previous Busy Status" },
297e979c658Sreinoud { 0x2C, 0x08, "Previous Task Set Full Status" },
298e979c658Sreinoud { 0x2C, 0x09, "Previous Reservation Conflict Status" },
299e979c658Sreinoud { 0x2C, 0x0A, "Partition or Collection Contains User Objects" },
300e979c658Sreinoud { 0x2D, 0x00, "Overwrite Error On Update In Place" },
301e979c658Sreinoud { 0x2E, 0x00, "Insufficient Time For Operation" },
302e979c658Sreinoud { 0x2F, 0x00, "Commands Cleared By Another Initiator" },
303e979c658Sreinoud { 0x30, 0x00, "Incompatible Medium Installed" },
304e979c658Sreinoud { 0x30, 0x01, "Cannot Read Medium - Unknown Format" },
305e979c658Sreinoud { 0x30, 0x02, "Cannot Read Medium - Incompatible Format" },
306e979c658Sreinoud { 0x30, 0x03, "Cleaning Cartridge Installed" },
307e979c658Sreinoud { 0x30, 0x04, "Cannot Write Medium - Unknown Format" },
308e979c658Sreinoud { 0x30, 0x05, "Cannot Write Medium - Incompatible Format" },
309e979c658Sreinoud { 0x30, 0x06, "Cannot Format Medium - Incompatible Medium" },
310e979c658Sreinoud { 0x30, 0x07, "Cleaning Failure" },
311e979c658Sreinoud { 0x30, 0x08, "Cannot Write - Application Code Mismatch" },
312e979c658Sreinoud { 0x30, 0x09, "Current Session Not Fixated For Append" },
313e979c658Sreinoud { 0x30, 0x0A, "Cleaning Request Rejected" },
314e979c658Sreinoud { 0x30, 0x10, "Medium Not Formatted" },
315e979c658Sreinoud { 0x31, 0x00, "Medium Format Corrupted" },
316e979c658Sreinoud { 0x31, 0x01, "Format Command Failed" },
317e979c658Sreinoud { 0x31, 0x02, "Zoned Formatting Failed Due To Spare Linking" },
318e979c658Sreinoud { 0x32, 0x00, "No Defect Spare Location Available" },
319e979c658Sreinoud { 0x32, 0x01, "Defect List Update Failure" },
320e979c658Sreinoud { 0x33, 0x00, "Tape Length Error" },
321e979c658Sreinoud { 0x34, 0x00, "Enclosure Failure" },
322e979c658Sreinoud { 0x35, 0x00, "Enclosure Services Failure" },
323e979c658Sreinoud { 0x35, 0x01, "Unsupported Enclosure Function" },
324e979c658Sreinoud { 0x35, 0x02, "Enclosure Services Unavailable" },
325e979c658Sreinoud { 0x35, 0x03, "Enclosure Services Transfer Failed" },
326e979c658Sreinoud { 0x35, 0x04, "Enclosure Services Transfer Refused" },
327e979c658Sreinoud { 0x36, 0x00, "Ribbon, Ink, or Toner Failure" },
328e979c658Sreinoud { 0x37, 0x00, "Rounded Parameter" },
329e979c658Sreinoud { 0x39, 0x00, "Saving Parameters Not Supported" },
330e979c658Sreinoud { 0x3A, 0x00, "Medium Not Present" },
331e979c658Sreinoud { 0x3A, 0x01, "Medium Not Present - Tray Closed" },
332e979c658Sreinoud { 0x3A, 0x02, "Medium Not Present - Tray Open" },
333e979c658Sreinoud { 0x3A, 0x03, "Medium Not Present - Loadable" },
334e979c658Sreinoud { 0x3A, 0x04, "Medium Not Present - Medium Auxilliary Memory Accessible" },
335e979c658Sreinoud { 0x3B, 0x00, "Sequential Positioning Error" },
336e979c658Sreinoud { 0x3B, 0x01, "Tape Position Error At Beginning-of-Medium" },
337e979c658Sreinoud { 0x3B, 0x02, "Tape Position Error At End-of-Medium" },
338e979c658Sreinoud { 0x3B, 0x03, "Tape or Electronic Vertical Forms Unit Not Ready" },
339e979c658Sreinoud { 0x3B, 0x04, "Slew Failure" },
340e979c658Sreinoud { 0x3B, 0x05, "Paper Jam" },
341e979c658Sreinoud { 0x3B, 0x06, "Failed To Sense Top-Of-Form" },
342e979c658Sreinoud { 0x3B, 0x07, "Failed To Sense Bottom-Of-Form" },
343e979c658Sreinoud { 0x3B, 0x08, "Reposition Error" },
344e979c658Sreinoud { 0x3B, 0x09, "Read Past End Of Medium" },
345*0e6570fcSandvar { 0x3B, 0x0A, "Read Past Beginning Of Medium" },
346e979c658Sreinoud { 0x3B, 0x0B, "Position Past End Of Medium" },
347e979c658Sreinoud { 0x3B, 0x0C, "Position Past Beginning Of Medium" },
348e979c658Sreinoud { 0x3B, 0x0D, "Medium Destination Element Full" },
349e979c658Sreinoud { 0x3B, 0x0E, "Medium Source Element Empty" },
350e979c658Sreinoud { 0x3B, 0x0F, "End Of Medium Reached" },
351e979c658Sreinoud { 0x3B, 0x11, "Medium Magazine Not Accessible" },
352e979c658Sreinoud { 0x3B, 0x12, "Medium Magazine Removed" },
353e979c658Sreinoud { 0x3B, 0x13, "Medium Magazine Inserted" },
354e979c658Sreinoud { 0x3B, 0x14, "Medium Magazine Locked" },
355e979c658Sreinoud { 0x3B, 0x15, "Medium Magazine Unlocked" },
356e979c658Sreinoud { 0x3B, 0x16, "Mechanical Positioning Or Changer Error" },
357e979c658Sreinoud { 0x3D, 0x00, "Invalid Bits In IDENTIFY Message" },
358e979c658Sreinoud { 0x3E, 0x00, "Logical Unit Has Not Self-Configured Yet" },
359e979c658Sreinoud { 0x3E, 0x01, "Logical Unit Failure" },
360e979c658Sreinoud { 0x3E, 0x02, "Timeout On Logical Unit" },
361e979c658Sreinoud { 0x3E, 0x03, "Logical Unit Failed Self-Test" },
362e979c658Sreinoud { 0x3E, 0x04, "Logical Unit Unable To Update Self-Test Log" },
363e979c658Sreinoud { 0x3F, 0x00, "Target Operating Conditions Have Changed" },
364e979c658Sreinoud { 0x3F, 0x01, "Microcode Has Been Changed" },
365e979c658Sreinoud { 0x3F, 0x02, "Changed Operating Definition" },
366e979c658Sreinoud { 0x3F, 0x03, "INQUIRY Data Has Changed" },
367e979c658Sreinoud { 0x3F, 0x04, "Component Device Attached" },
368e979c658Sreinoud { 0x3F, 0x05, "Device Identifier Changed" },
369e979c658Sreinoud { 0x3F, 0x06, "Redundancy Group Created Or Modified" },
370e979c658Sreinoud { 0x3F, 0x07, "Redundancy Group Deleted" },
371e979c658Sreinoud { 0x3F, 0x08, "Spare Created Or Modified" },
372e979c658Sreinoud { 0x3F, 0x09, "Spare Deleted" },
373e979c658Sreinoud { 0x3F, 0x0A, "Volume Set Created Or Modified" },
374e979c658Sreinoud { 0x3F, 0x0B, "Volume Set Deleted" },
375e979c658Sreinoud { 0x3F, 0x0C, "Volume Set Deassigned" },
376e979c658Sreinoud { 0x3F, 0x0D, "Volume Set Reassigned" },
377e979c658Sreinoud { 0x3F, 0x0E, "Reported LUNs Data Has Changed" },
378e979c658Sreinoud { 0x3F, 0x0F, "Echo Buffer Overwritten" },
379e979c658Sreinoud { 0x3F, 0x10, "Medium Loadable" },
380e979c658Sreinoud { 0x3F, 0x11, "Medium Auxiliary Memory Accessible" },
381e979c658Sreinoud { 0x40, 0x00, "RAM FAILURE (Should Use 40 NN)" },
382e979c658Sreinoud { 0x41, 0x00, "Data Path FAILURE (Should Use 40 NN)" },
383e979c658Sreinoud { 0x42, 0x00, "Power-On or Self-Test FAILURE (Should Use 40 NN)" },
384e979c658Sreinoud { 0x43, 0x00, "Message Error" },
385e979c658Sreinoud { 0x44, 0x00, "Internal Target Failure" },
386e979c658Sreinoud { 0x45, 0x00, "Select Or Reselect Failure" },
387e979c658Sreinoud { 0x46, 0x00, "Unsuccessful Soft Reset" },
388e979c658Sreinoud { 0x47, 0x00, "SCSI Parity Error" },
389e979c658Sreinoud { 0x47, 0x01, "Data Phase CRC Error Detected" },
390e979c658Sreinoud { 0x47, 0x02, "SCSI Parity Error Detected During ST Data Phase" },
391e979c658Sreinoud { 0x47, 0x03, "Information Unit iuCRC Error Detected" },
392e979c658Sreinoud { 0x47, 0x04, "Asynchronous Information Protection Error Detected" },
393e979c658Sreinoud { 0x47, 0x05, "Protocol Service CRC Error" },
394e979c658Sreinoud { 0x47, 0x7F, "Some Commands Cleared by iSCSI Protocol Event" },
395e979c658Sreinoud { 0x48, 0x00, "INITIATOR DETECTED ERROR Message Received" },
396e979c658Sreinoud { 0x49, 0x00, "Invalid Message Error" },
397e979c658Sreinoud { 0x4A, 0x00, "Command Phase Error" },
398e979c658Sreinoud { 0x4B, 0x00, "Data Phase Error" },
399e979c658Sreinoud { 0x4B, 0x01, "Illegal Target Port Transfer Tag Received" },
400e979c658Sreinoud { 0x4B, 0x02, "Too Much Write Data" },
401e979c658Sreinoud { 0x4B, 0x03, "ACK/NAK Timeout" },
402e979c658Sreinoud { 0x4B, 0x04, "NAK Reveived" },
403e979c658Sreinoud { 0x4B, 0x05, "Data Offset Error" },
404e979c658Sreinoud { 0x4B, 0x06, "Initiator Response Timeout" },
405e979c658Sreinoud { 0x4C, 0x00, "Logical Unit Failed Self-Configuration" },
406e979c658Sreinoud { 0x4D, 0x00, "Tagged Overlapped Commands (NN = Queue Tag)" },
407e979c658Sreinoud { 0x4E, 0x00, "Overlapped Commands Attempted" },
408e979c658Sreinoud { 0x50, 0x00, "Write Append Error" },
409e979c658Sreinoud { 0x50, 0x01, "Write Append Position Error" },
410e979c658Sreinoud { 0x50, 0x02, "Position Error Related To Timing" },
411e979c658Sreinoud { 0x51, 0x00, "Erase Failure" },
412e979c658Sreinoud { 0x51, 0x01, "Erase Failure - Incomplete Erase Operation Detected" },
413e979c658Sreinoud { 0x52, 0x00, "Cartridge Fault" },
414e979c658Sreinoud { 0x53, 0x00, "Media Load or Eject Failed" },
415e979c658Sreinoud { 0x53, 0x01, "Unload Tape Failure" },
416e979c658Sreinoud { 0x53, 0x02, "Medium Removal Prevented" },
417e979c658Sreinoud { 0x54, 0x00, "SCSI To Host System Interface Failure" },
418e979c658Sreinoud { 0x55, 0x00, "System Resource Failure" },
419e979c658Sreinoud { 0x55, 0x01, "System Buffer Full" },
420e979c658Sreinoud { 0x55, 0x02, "Insufficient Reservation Resources" },
421e979c658Sreinoud { 0x55, 0x03, "Insufficient Resources" },
422e979c658Sreinoud { 0x55, 0x04, "Insufficient Registration Resources" },
423e979c658Sreinoud { 0x55, 0x05, "Insufficient Access Control Resources" },
424e979c658Sreinoud { 0x55, 0x06, "Auxiliary Memory Out Of Space" },
425e979c658Sreinoud { 0x57, 0x00, "Unable To Recover Table-Of-Contents" },
426e979c658Sreinoud { 0x58, 0x00, "Generation Does Not Exist" },
427e979c658Sreinoud { 0x59, 0x00, "Updated Block Read" },
428e979c658Sreinoud { 0x5A, 0x00, "Operator Request or State Change Input (Unspecified)" },
429e979c658Sreinoud { 0x5A, 0x01, "Operator Medium Removal Requested" },
430e979c658Sreinoud { 0x5A, 0x02, "Operator Selected Write Protect" },
431e979c658Sreinoud { 0x5A, 0x03, "Operator Selected Write Permit" },
432e979c658Sreinoud { 0x5B, 0x00, "Log Exception" },
433e979c658Sreinoud { 0x5B, 0x01, "Threshold Condition Met" },
434e979c658Sreinoud { 0x5B, 0x02, "Log Counter At Maximum" },
435e979c658Sreinoud { 0x5B, 0x03, "Log List Codes Exhausted" },
436e979c658Sreinoud { 0x5C, 0x00, "RPL Status Change" },
437e979c658Sreinoud { 0x5C, 0x01, "Spindles Synchronized" },
438e979c658Sreinoud { 0x5C, 0x02, "Spindles Not Synchronized" },
439e979c658Sreinoud { 0x5D, 0x00, "Failure Prediction Threshold Exceeded" },
440e979c658Sreinoud { 0x5D, 0x01, "Media Failure Prediction Threshold Exceeded" },
441e979c658Sreinoud { 0x5D, 0x02, "Logical Unit Failure Prediction Threshold Exceeded" },
442e979c658Sreinoud { 0x5D, 0x03, "Spare Area Exhaustion Prediction Threshold Exceeded" },
443e979c658Sreinoud { 0x5D, 0x10, "Hardware Impending Failure General Hard Drive Failure" },
444e979c658Sreinoud { 0x5D, 0x11, "Hardware Impending Failure Drive Error Rate Too High" },
445e979c658Sreinoud { 0x5D, 0x12, "Hardware Impending Failure Data Error Rate Too High" },
446e979c658Sreinoud { 0x5D, 0x13, "Hardware Impending Failure Seek Error Rate Too High" },
447e979c658Sreinoud { 0x5D, 0x14, "Hardware Impending Failure Too Many Block Reassigns" },
448e979c658Sreinoud { 0x5D, 0x15, "Hardware Impending Failure Access Times Too High" },
449e979c658Sreinoud { 0x5D, 0x16, "Hardware Impending Failure Start Unit Times Too High" },
450e979c658Sreinoud { 0x5D, 0x17, "Hardware Impending Failure Channel Parametrics" },
451e979c658Sreinoud { 0x5D, 0x18, "Hardware Impending Failure Controller Detected" },
452e979c658Sreinoud { 0x5D, 0x19, "Hardware Impending Failure Throughput Performance" },
453e979c658Sreinoud { 0x5D, 0x1A, "Hardware Impending Failure Seek Time Performance" },
454e979c658Sreinoud { 0x5D, 0x1B, "Hardware Impending Failure Spin-Up Retry Count" },
455e979c658Sreinoud { 0x5D, 0x1C, "Hardware Impending Failure Drive Calibration Retry Count" },
456e979c658Sreinoud { 0x5D, 0x20, "Controller Impending Failure General Hard Drive Failure" },
457e979c658Sreinoud { 0x5D, 0x21, "Controller Impending Failure Drive Error Rate Too High" },
458e979c658Sreinoud { 0x5D, 0x22, "Controller Impending Failure Data Error Rate Too High" },
459e979c658Sreinoud { 0x5D, 0x23, "Controller Impending Failure Seek Error Rate Too High" },
460e979c658Sreinoud { 0x5D, 0x24, "Controller Impending Failure Too Many Block Reassigns" },
461e979c658Sreinoud { 0x5D, 0x25, "Controller Impending Failure Access Times Too High" },
462e979c658Sreinoud { 0x5D, 0x26, "Controller Impending Failure Start Unit Times Too High" },
463e979c658Sreinoud { 0x5D, 0x27, "Controller Impending Failure Channel Parametrics" },
464e979c658Sreinoud { 0x5D, 0x28, "Controller Impending Failure Controller Detected" },
465e979c658Sreinoud { 0x5D, 0x29, "Controller Impending Failure Throughput Performance" },
466e979c658Sreinoud { 0x5D, 0x2A, "Controller Impending Failure Seek Time Performance" },
467e979c658Sreinoud { 0x5D, 0x2B, "Controller Impending Failure Spin-Up Retry Count" },
468e979c658Sreinoud { 0x5D, 0x2C, "Controller Impending Failure Drive Calibration Retry Count" },
469e979c658Sreinoud { 0x5D, 0x30, "Data Channel Impending Failure General Hard Drive Failure" },
470e979c658Sreinoud { 0x5D, 0x31, "Data Channel Impending Failure Drive Error Rate Too High" },
471e979c658Sreinoud { 0x5D, 0x32, "Data Channel Impending Failure Data Error Rate Too High" },
472e979c658Sreinoud { 0x5D, 0x33, "Data Channel Impending Failure Seek Error Rate Too High" },
473e979c658Sreinoud { 0x5D, 0x34, "Data Channel Impending Failure Too Many Block Reassigns" },
474e979c658Sreinoud { 0x5D, 0x35, "Data Channel Impending Failure Access Times Too High" },
475e979c658Sreinoud { 0x5D, 0x36, "Data Channel Impending Failure Start Unit Times Too High" },
476e979c658Sreinoud { 0x5D, 0x37, "Data Channel Impending Failure Channel Parametrics" },
477e979c658Sreinoud { 0x5D, 0x38, "Data Channel Impending Failure Controller Detected" },
478e979c658Sreinoud { 0x5D, 0x39, "Data Channel Impending Failure Throughput Performance" },
479e979c658Sreinoud { 0x5D, 0x3A, "Data Channel Impending Failure Seek Time Performance" },
480e979c658Sreinoud { 0x5D, 0x3B, "Data Channel Impending Failure Spin-Up Retry Count" },
481e979c658Sreinoud { 0x5D, 0x3C, "Data Channel Impending Failure Drive Calibration Retry Count" },
482e979c658Sreinoud { 0x5D, 0x40, "Servo Impending Failure General Hard Drive Failure" },
483e979c658Sreinoud { 0x5D, 0x41, "Servo Impending Failure Drive Error Rate Too High" },
484e979c658Sreinoud { 0x5D, 0x42, "Servo Impending Failure Data Error Rate Too High" },
485e979c658Sreinoud { 0x5D, 0x43, "Servo Impending Failure Seek Error Rate Too High" },
486e979c658Sreinoud { 0x5D, 0x44, "Servo Impending Failure Too Many Block Reassigns" },
487e979c658Sreinoud { 0x5D, 0x45, "Servo Impending Failure Access Times Too High" },
488e979c658Sreinoud { 0x5D, 0x46, "Servo Impending Failure Start Unit Times Too High" },
489e979c658Sreinoud { 0x5D, 0x47, "Servo Impending Failure Channel Parametrics" },
490e979c658Sreinoud { 0x5D, 0x48, "Servo Impending Failure Controller Detected" },
491e979c658Sreinoud { 0x5D, 0x49, "Servo Impending Failure Throughput Performance" },
492e979c658Sreinoud { 0x5D, 0x4A, "Servo Impending Failure Seek Time Performance" },
493e979c658Sreinoud { 0x5D, 0x4B, "Servo Impending Failure Spin-Up Retry Count" },
494e979c658Sreinoud { 0x5D, 0x4C, "Servo Impending Failure Drive Calibration Retry Count" },
495e979c658Sreinoud { 0x5D, 0x50, "Spindle Impending Failure General Hard Drive Failure" },
496e979c658Sreinoud { 0x5D, 0x51, "Spindle Impending Failure Drive Error Rate Too High" },
497e979c658Sreinoud { 0x5D, 0x52, "Spindle Impending Failure Data Error Rate Too High" },
498e979c658Sreinoud { 0x5D, 0x53, "Spindle Impending Failure Seek Error Rate Too High" },
499e979c658Sreinoud { 0x5D, 0x54, "Spindle Impending Failure Too Many Block Reassigns" },
500e979c658Sreinoud { 0x5D, 0x55, "Spindle Impending Failure Access Times Too High" },
501e979c658Sreinoud { 0x5D, 0x56, "Spindle Impending Failure Start Unit Times Too High" },
502e979c658Sreinoud { 0x5D, 0x57, "Spindle Impending Failure Channel Parametrics" },
503e979c658Sreinoud { 0x5D, 0x58, "Spindle Impending Failure Controller Detected" },
504e979c658Sreinoud { 0x5D, 0x59, "Spindle Impending Failure Throughput Performance" },
505e979c658Sreinoud { 0x5D, 0x5A, "Spindle Impending Failure Seek Time Performance" },
506e979c658Sreinoud { 0x5D, 0x5B, "Spindle Impending Failure Spin-Up Retry Count" },
507e979c658Sreinoud { 0x5D, 0x5C, "Spindle Impending Failure Drive Calibration Retry Count" },
508e979c658Sreinoud { 0x5D, 0x60, "Firmware Impending Failure General Hard Drive Failure" },
509e979c658Sreinoud { 0x5D, 0x61, "Firmware Impending Failure Drive Error Rate Too High" },
510e979c658Sreinoud { 0x5D, 0x62, "Firmware Impending Failure Data Error Rate Too High" },
511e979c658Sreinoud { 0x5D, 0x63, "Firmware Impending Failure Seek Error Rate Too High" },
512e979c658Sreinoud { 0x5D, 0x64, "Firmware Impending Failure Too Many Block Reassigns" },
513e979c658Sreinoud { 0x5D, 0x65, "Firmware Impending Failure Access Times Too High" },
514e979c658Sreinoud { 0x5D, 0x66, "Firmware Impending Failure Start Unit Times Too High" },
515e979c658Sreinoud { 0x5D, 0x67, "Firmware Impending Failure Channel Parametrics" },
516e979c658Sreinoud { 0x5D, 0x68, "Firmware Impending Failure Controller Detected" },
517e979c658Sreinoud { 0x5D, 0x69, "Firmware Impending Failure Throughput Performance" },
518e979c658Sreinoud { 0x5D, 0x6A, "Firmware Impending Failure Seek Time Performance" },
519e979c658Sreinoud { 0x5D, 0x6B, "Firmware Impending Failure Spin-Up Retry Count" },
520e979c658Sreinoud { 0x5D, 0x6C, "Firmware Impending Failure Drive Calibration Retry Count" },
521e979c658Sreinoud { 0x5D, 0xFF, "Failure Prediction Threshold Exceeded (False)" },
522e979c658Sreinoud { 0x5E, 0x00, "Low Power Condition On" },
523e979c658Sreinoud { 0x5E, 0x01, "Idle Condition Activated By Timer" },
524e979c658Sreinoud { 0x5E, 0x02, "Standby Condition Activated By Timer" },
525e979c658Sreinoud { 0x5E, 0x03, "Idle Condition Activated By Command" },
526e979c658Sreinoud { 0x5E, 0x04, "Standby Condition Activated By Command" },
527e979c658Sreinoud { 0x5E, 0x41, "Power State Change To Active" },
528e979c658Sreinoud { 0x5E, 0x42, "Power State Change To Idle" },
529e979c658Sreinoud { 0x5E, 0x43, "Power State Change To Standby" },
530e979c658Sreinoud { 0x5E, 0x45, "Power State Change To Sleep" },
531e979c658Sreinoud { 0x5E, 0x47, "Power State Change To Device Control" },
532e979c658Sreinoud { 0x60, 0x00, "Lamp Failure" },
533e979c658Sreinoud { 0x61, 0x00, "Video Acquisition Error" },
534e979c658Sreinoud { 0x61, 0x01, "Unable To Acquire Video" },
535e979c658Sreinoud { 0x61, 0x02, "Out Of Focus" },
536e979c658Sreinoud { 0x62, 0x00, "Scan Head Positioning Error" },
537e979c658Sreinoud { 0x63, 0x00, "End Of User Area Encountered On This Track" },
538e979c658Sreinoud { 0x63, 0x01, "Packet Does Not Fit In Available Space" },
539e979c658Sreinoud { 0x64, 0x00, "Illegal Mode For This Track" },
540e979c658Sreinoud { 0x64, 0x01, "Invalid Packet Size" },
541e979c658Sreinoud { 0x65, 0x00, "Voltage Fault" },
542e979c658Sreinoud { 0x66, 0x00, "Automatic Document Feeder Cover Up" },
543e979c658Sreinoud { 0x66, 0x01, "Automatic Document Feeder Lift Up" },
544e979c658Sreinoud { 0x66, 0x02, "Document Jam In Automatic Document Feeder" },
545e979c658Sreinoud { 0x66, 0x03, "Document Misfeed In Automatic Document Feeder" },
546e979c658Sreinoud { 0x67, 0x00, "Configuration Failure" },
547e979c658Sreinoud { 0x67, 0x01, "Configuration Of Incapable Logical Units Failed" },
548e979c658Sreinoud { 0x67, 0x02, "Add Logical Unit Failed" },
549e979c658Sreinoud { 0x67, 0x03, "Modification Of Logical Unit Failed" },
550e979c658Sreinoud { 0x67, 0x04, "Exchange Of Logical Unit Failed" },
551e979c658Sreinoud { 0x67, 0x05, "Remove Of Logical Unit Failed" },
552e979c658Sreinoud { 0x67, 0x06, "Attachment Of Logical Unit Failed" },
553e979c658Sreinoud { 0x67, 0x07, "Creation of Logical Unit Failed" },
554e979c658Sreinoud { 0x67, 0x08, "Assign Failure Occurred" },
555e979c658Sreinoud { 0x67, 0x09, "Multiply Assigned Logical Unit" },
556e979c658Sreinoud { 0x67, 0x0A, "Set Target Port Groups Command Failed" },
557e979c658Sreinoud { 0x68, 0x00, "Logical Unit Not Configured" },
558e979c658Sreinoud { 0x69, 0x00, "Data Loss On Logical Unit" },
559e979c658Sreinoud { 0x69, 0x01, "Multiple Logical Unit Failures" },
560e979c658Sreinoud { 0x69, 0x02, "Parity/Data Mismatch" },
561e979c658Sreinoud { 0x6A, 0x00, "Informational, Refer To Log" },
562e979c658Sreinoud { 0x6B, 0x00, "State Change Has Occurred" },
563e979c658Sreinoud { 0x6B, 0x01, "Redundancy Level Got Better" },
564e979c658Sreinoud { 0x6B, 0x02, "Redundancy Level Got Worse" },
565e979c658Sreinoud { 0x6C, 0x00, "Rebuild Failure Occurred" },
566e979c658Sreinoud { 0x6D, 0x00, "Recalculate Failure Occurred" },
567e979c658Sreinoud { 0x6E, 0x00, "Command To Logical Unit Failed" },
568e979c658Sreinoud { 0x6F, 0x00, "Copy Protection Key Exchange Failure - Authentication Failure" },
569e979c658Sreinoud { 0x6F, 0x01, "Copy Protection Key Exchange Failure - Key Not Present" },
570e979c658Sreinoud { 0x6F, 0x02, "Copy Protection Key Exchange Failure - Key Not Established" },
571e979c658Sreinoud { 0x6F, 0x03, "Read Of Scrambled Sector Without Authentication" },
572e979c658Sreinoud { 0x6F, 0x04, "Media Region Code Is Mismatched To Logical Unit Region" },
573e979c658Sreinoud { 0x6F, 0x05, "Drive Region Must Be Permanent/Region Reset Count Error" },
574e979c658Sreinoud { 0x70, 0x00, "Decompression Exception Short Algorithm ID Of NN" },
575e979c658Sreinoud { 0x71, 0x00, "Decompression Exception Long Algorithm ID" },
576e979c658Sreinoud { 0x72, 0x00, "Session Fixation Error" },
577e979c658Sreinoud { 0x72, 0x01, "Session Fixation Error Writing Lead-In" },
578e979c658Sreinoud { 0x72, 0x02, "Session Fixation Error Writing Lead-Out" },
579e979c658Sreinoud { 0x72, 0x03, "Session Fixation Error - Incomplete Track In Session" },
580e979c658Sreinoud { 0x72, 0x04, "Empty Or Partially Written Reserved Track" },
581e979c658Sreinoud { 0x72, 0x05, "No More Track Reservations Allowed" },
582e979c658Sreinoud { 0x73, 0x00, "CD Control Error" },
583e979c658Sreinoud { 0x73, 0x01, "Power Calibration Area Almost Full" },
584e979c658Sreinoud { 0x73, 0x02, "Power Calibration Area Is Full" },
585e979c658Sreinoud { 0x73, 0x03, "Power Calibration Area Error" },
586e979c658Sreinoud { 0x73, 0x04, "Program Memory Area Update Failure" },
587e979c658Sreinoud { 0x73, 0x05, "Program Memory Area Is Full" },
588e979c658Sreinoud { 0x73, 0x06, "RMA/PMA Is Almost Full" },
589e979c658Sreinoud { 0x00, 0x00, NULL }
590e979c658Sreinoud };
591e979c658Sreinoud 
592e979c658Sreinoud 
593e979c658Sreinoud /* needs to move to a compat.c one day */
594e979c658Sreinoud #ifdef NO_STRLCPY
595e979c658Sreinoud 
596e979c658Sreinoud size_t
strlcpy(char * dst,const char * src,size_t size)597e979c658Sreinoud strlcpy(char *dst, const char *src, size_t size)
598e979c658Sreinoud {
599e979c658Sreinoud 	strncpy(dst, src, size-1);
600e979c658Sreinoud 	dst[size] = '\0';
601e979c658Sreinoud 
602e979c658Sreinoud 	return strlen(src);
603e979c658Sreinoud }
604e979c658Sreinoud 
605e979c658Sreinoud #endif
606e979c658Sreinoud 
607e979c658Sreinoud 
608e979c658Sreinoud static void
asc2ascii(u_char asc,u_char ascq,char * result,size_t l)609e979c658Sreinoud asc2ascii(u_char asc, u_char ascq, char *result, size_t l)
610e979c658Sreinoud {
611e979c658Sreinoud 	int i = 0;
612e979c658Sreinoud 
613e979c658Sreinoud 	while (adesc[i].description != NULL) {
614e979c658Sreinoud 		if (adesc[i].asc == asc && adesc[i].ascq == ascq)
615e979c658Sreinoud 			break;
616e979c658Sreinoud 		i++;
617e979c658Sreinoud 	}
618e979c658Sreinoud 	if (adesc[i].description == NULL) {
619e979c658Sreinoud 		if (asc == 0x40 && ascq != 0)
620e979c658Sreinoud 			(void) snprintf(result, l,
621e979c658Sreinoud 			    "Diagnostic Failure on Component 0x%02x",
622e979c658Sreinoud 			    ascq & 0xff);
623e979c658Sreinoud 		else
624e979c658Sreinoud 			(void) snprintf(result, l, "ASC 0x%02x ASCQ 0x%02x",
625e979c658Sreinoud 			    asc & 0xff, ascq & 0xff);
626e979c658Sreinoud 	} else
627e979c658Sreinoud 		(void) strlcpy(result, adesc[i].description, l);
628e979c658Sreinoud }
629e979c658Sreinoud 
630e979c658Sreinoud 
631e979c658Sreinoud static void
uscsi_print_sense_data(uint8_t * s,int slen,int verbosity)632e979c658Sreinoud uscsi_print_sense_data(uint8_t *s, int slen, int verbosity)
633e979c658Sreinoud {
634e979c658Sreinoud 	int32_t info;
635e979c658Sreinoud 	int i, j, k;
636e979c658Sreinoud 	char *sbs;
637e979c658Sreinoud 
638e979c658Sreinoud 	/*
639e979c658Sreinoud 	 * Basics - print out SENSE KEY
640e979c658Sreinoud 	 */
641e979c658Sreinoud 	printf("    SENSE KEY: %s", uscsi_decode_sense(s, 0));
642e979c658Sreinoud 
643e979c658Sreinoud 	/*
644e979c658Sreinoud 	 * Print out, unqualified but aligned, FMK, EOM and ILI status.
645e979c658Sreinoud 	 */
646e979c658Sreinoud 	if (s[2] & 0xe0) {
647e979c658Sreinoud 		char pad;
648e979c658Sreinoud 	        printf("\n              ");
649e979c658Sreinoud 		pad = ' ';
650e979c658Sreinoud 		if (s[2] & SSD_FILEMARK) {
651e979c658Sreinoud 			printf("%c Filemark Detected", pad);
652e979c658Sreinoud 			pad = ',';
653e979c658Sreinoud 		}
654e979c658Sreinoud 		if (s[2] & SSD_EOM) {
655e979c658Sreinoud 			printf("%c EOM Detected", pad);
656e979c658Sreinoud 			pad = ',';
657e979c658Sreinoud 		}
658e979c658Sreinoud 		if (s[2] & SSD_ILI)
659e979c658Sreinoud 			printf("%c Incorrect Length Indicator Set", pad);
660e979c658Sreinoud 	}
661e979c658Sreinoud 
662e979c658Sreinoud 	/*
663e979c658Sreinoud 	 * Now we should figure out, based upon device type, how
664e979c658Sreinoud 	 * to format the information field. Unfortunately, that's
665e979c658Sreinoud 	 * not convenient here, so we'll print it as a signed
666e979c658Sreinoud 	 * 32 bit integer.
667e979c658Sreinoud 	 */
668e979c658Sreinoud 	//info = _4btol(&s[3]);
669e979c658Sreinoud 	info = (s[3] << 24) | (s[4] << 16) | (s[5] << 8) | s[6];
670e979c658Sreinoud 	if (info)
671e979c658Sreinoud 		printf("\n   INFO FIELD: %d", info);
672e979c658Sreinoud 
673e979c658Sreinoud 	/*
674e979c658Sreinoud 	 * Now we check additional length to see whether there is
675e979c658Sreinoud 	 * more information to extract.
676e979c658Sreinoud 	 */
677e979c658Sreinoud 
678e979c658Sreinoud 	/* enough for command specific information? */
679e979c658Sreinoud 	if (((unsigned int) s[7]) < 4) {
680e979c658Sreinoud 		printf("\n");
681e979c658Sreinoud 		return;
682e979c658Sreinoud 	}
683e979c658Sreinoud 	// info = _4btol(&s[8]);
684e979c658Sreinoud 	info = (s[8] << 24) | (s[9] << 16) | (s[10] << 8) | s[11];
685e979c658Sreinoud 	if (info)
686e979c658Sreinoud 		printf("\n COMMAND INFO: %d (0x%x)", info, info);
687e979c658Sreinoud 
688e979c658Sreinoud 	/*
689e979c658Sreinoud 	 * Decode ASC && ASCQ info, plus FRU, plus the rest...
690e979c658Sreinoud 	 */
691e979c658Sreinoud 
692e979c658Sreinoud 	sbs = uscsi_decode_sense(s, 1);
693e979c658Sreinoud 	if (sbs)
694e979c658Sreinoud 		printf("\n     ASC/ASCQ: %s", sbs);
695e979c658Sreinoud 	if (s[14] != 0)
696e979c658Sreinoud 		printf("\n     FRU CODE: 0x%x", s[14] & 0xff);
697e979c658Sreinoud 	sbs = uscsi_decode_sense(s, 3);
698e979c658Sreinoud 	if (sbs)
699e979c658Sreinoud 		printf("\n         SKSV: %s", sbs);
700e979c658Sreinoud 	printf("\n");
701e979c658Sreinoud 	if (verbosity == 0) {
702e979c658Sreinoud 		printf("\n");
703e979c658Sreinoud 		return;
704e979c658Sreinoud 	}
705e979c658Sreinoud 
706e979c658Sreinoud 	/*
707e979c658Sreinoud 	 * Now figure whether we should print any additional informtion.
708e979c658Sreinoud 	 *
709e979c658Sreinoud 	 * Where should we start from? If we had SKSV data,
710e979c658Sreinoud 	 * start from offset 18, else from offset 15.
711e979c658Sreinoud 	 *
712e979c658Sreinoud 	 * From that point until the end of the buffer, check for any
713e979c658Sreinoud 	 * nonzero data. If we have some, go back and print the lot,
714e979c658Sreinoud 	 * otherwise we're done.
715e979c658Sreinoud 	 */
716e979c658Sreinoud 	if (sbs)
717e979c658Sreinoud 		i = 18;
718e979c658Sreinoud 	else
719e979c658Sreinoud 		i = 15;
720e979c658Sreinoud 	for (j = i; j < slen; j++)
721e979c658Sreinoud 		if (s[j])
722e979c658Sreinoud 			break;
723e979c658Sreinoud 	if (j == slen)
724e979c658Sreinoud 		return;
725e979c658Sreinoud 
726e979c658Sreinoud 	printf("\n Additional Sense Information (byte %d out...):\n", i);
727e979c658Sreinoud 	if (i == 15) {
728e979c658Sreinoud 		printf("\n\t%2d:", i);
729e979c658Sreinoud 		k = 7;
730e979c658Sreinoud 	} else {
731e979c658Sreinoud 		printf("\n\t%2d:", i);
732e979c658Sreinoud 		k = 2;
733e979c658Sreinoud 		j -= 2;
734e979c658Sreinoud 	}
735e979c658Sreinoud 	while (j > 0) {
736e979c658Sreinoud 		if (i >= slen)
737e979c658Sreinoud 			break;
738e979c658Sreinoud 		if (k == 8) {
739e979c658Sreinoud 			k = 0;
740e979c658Sreinoud 			printf("\n\t%2d:", i);
741e979c658Sreinoud 		}
742e979c658Sreinoud 		printf(" 0x%02x", s[i] & 0xff);
743e979c658Sreinoud 		k++;
744e979c658Sreinoud 		j--;
745e979c658Sreinoud 		i++;
746e979c658Sreinoud 	}
747e979c658Sreinoud 	printf("\n\n");
748e979c658Sreinoud }
749e979c658Sreinoud 
750e979c658Sreinoud 
751e979c658Sreinoud char *
uscsi_decode_sense(void * sinfo,int flag)752e979c658Sreinoud uscsi_decode_sense(void *sinfo, int flag)
753e979c658Sreinoud {
754e979c658Sreinoud 	unsigned char *snsbuf;
755e979c658Sreinoud 	unsigned char skey;
756e979c658Sreinoud 	static char rqsbuf[132];
757e979c658Sreinoud 
758e979c658Sreinoud 	skey = 0;
759e979c658Sreinoud 
760e979c658Sreinoud 	snsbuf = (unsigned char *) sinfo;
761e979c658Sreinoud 	if (flag == 0 || flag == 2 || flag == 3)
762e979c658Sreinoud 		skey = snsbuf[2] & 0xf;
763e979c658Sreinoud 	if (flag == 0) {			/* Sense Key Only */
764e979c658Sreinoud 		(void) strlcpy(rqsbuf, sense_keys[skey], sizeof(rqsbuf));
765e979c658Sreinoud 		return (rqsbuf);
766e979c658Sreinoud 	} else if (flag == 1) {			/* ASC/ASCQ Only */
767e979c658Sreinoud 		asc2ascii(snsbuf[12], snsbuf[13], rqsbuf, sizeof(rqsbuf));
768e979c658Sreinoud 		return (rqsbuf);
769e979c658Sreinoud 	} else  if (flag == 2) {		/* Sense Key && ASC/ASCQ */
770e979c658Sreinoud 		auto char localbuf[64];
771e979c658Sreinoud 		asc2ascii(snsbuf[12], snsbuf[13], localbuf, sizeof(localbuf));
772e979c658Sreinoud 		(void) snprintf(rqsbuf, sizeof(rqsbuf), "%s, %s",
773e979c658Sreinoud 		    sense_keys[skey], localbuf);
774e979c658Sreinoud 		return (rqsbuf);
775e979c658Sreinoud 	} else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) {
776e979c658Sreinoud 		/*
777e979c658Sreinoud 		 * SKSV Data
778e979c658Sreinoud 		 */
779e979c658Sreinoud 		switch (skey) {
780e979c658Sreinoud 		case SKEY_ILLEGAL_REQUEST:
781e979c658Sreinoud 			if (snsbuf[15] & 0x8)
782e979c658Sreinoud 				(void)snprintf(rqsbuf, sizeof(rqsbuf),
783e979c658Sreinoud 				    "Error in %s, Offset %d, bit %d",
784e979c658Sreinoud 				    (snsbuf[15] & 0x40)? "CDB" : "Parameters",
785e979c658Sreinoud 				    (snsbuf[16] & 0xff) << 8 |
786e979c658Sreinoud 				    (snsbuf[17] & 0xff), snsbuf[15] & 0x7);
787e979c658Sreinoud 			else
788e979c658Sreinoud 				(void)snprintf(rqsbuf, sizeof(rqsbuf),
789e979c658Sreinoud 				    "Error in %s, Offset %d",
790e979c658Sreinoud 				    (snsbuf[15] & 0x40)? "CDB" : "Parameters",
791e979c658Sreinoud 				    (snsbuf[16] & 0xff) << 8 |
792e979c658Sreinoud 				    (snsbuf[17] & 0xff));
793e979c658Sreinoud 			return (rqsbuf);
794e979c658Sreinoud 
795e979c658Sreinoud 		case SKEY_RECOVERED_ERROR:
796e979c658Sreinoud 		case SKEY_MEDIUM_ERROR:
797e979c658Sreinoud 		case SKEY_HARDWARE_ERROR:
798e979c658Sreinoud 			(void)snprintf(rqsbuf, sizeof(rqsbuf),
799e979c658Sreinoud 			    "Actual Retry Count: %d",
800e979c658Sreinoud 			    (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
801e979c658Sreinoud 			return (rqsbuf);
802e979c658Sreinoud 
803e979c658Sreinoud 		case SKEY_NOT_READY:
804e979c658Sreinoud 			(void)snprintf(rqsbuf, sizeof(rqsbuf),
805e979c658Sreinoud 			    "Progress Indicator: %d",
806e979c658Sreinoud 			    (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
807e979c658Sreinoud 			return (rqsbuf);
808e979c658Sreinoud 
809e979c658Sreinoud 		default:
810e979c658Sreinoud 			break;
811e979c658Sreinoud 		}
812e979c658Sreinoud 	}
813e979c658Sreinoud 	return (NULL);
814e979c658Sreinoud }
815e979c658Sreinoud 
816e979c658Sreinoud 
817e979c658Sreinoud void
uscsi_print_sense(const char * name,u_char * req_cmd,int req_cmdlen,u_char * req_sense,int req_senselen_used,int verbosity)818e979c658Sreinoud uscsi_print_sense(const char *name, u_char *req_cmd, int req_cmdlen,
819e979c658Sreinoud 	u_char *req_sense, int req_senselen_used, int verbosity)
820e979c658Sreinoud {
821e979c658Sreinoud 	int i;
822e979c658Sreinoud 
823e979c658Sreinoud  	printf("%s: Check Condition on CDB:", name);
824e979c658Sreinoud  	for (i = 0; i < req_cmdlen; i++)
825e979c658Sreinoud  		printf(" %02x", req_cmd[i]);
826e979c658Sreinoud  	printf("\n");
827e979c658Sreinoud 	uscsi_print_sense_data(req_sense, req_senselen_used, verbosity);
828e979c658Sreinoud }
829e979c658Sreinoud 
830