1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Global SCSI data
29  */
30 
31 #include <sys/scsi/scsi.h>
32 #include <sys/cdio.h>			/* CDROM SCMD_ commands */
33 
34 char *sense_keys[NUM_SENSE_KEYS + NUM_IMPL_SENSE_KEYS] = {
35 					/* ==== SCSI Standard Keys */
36 	"No_Additional_Sense",		/* 0x00 KEY_NO_SENSE */
37 	"Soft_Error",			/* 0x01 KEY_RECOVERABLE_ERROR */
38 	"Not_Ready",			/* 0x02 KEY_NOT_READY */
39 	"Media_Error",			/* 0x03 KEY_MEDIUM_ERROR */
40 	"Hardware_Error",		/* 0x04 KEY_HARDWARE_ERROR */
41 	"Illegal_Request",		/* 0x05 KEY_ILLEGAL_REQUEST */
42 	"Unit_Attention",		/* 0x06 KEY_UNIT_ATTENTION */
43 	"Write_Protected",		/* 0x07 KEY_WRITE_PROTECT */
44 	"Blank_Check",			/* 0x08 KEY_BLANK_CHECK */
45 	"Vendor_Unique",		/* 0x09 KEY_VENDOR_UNIQUE */
46 	"Copy_Aborted",			/* 0x0a KEY_COPY_ABORTED */
47 	"Aborted_Command",		/* 0x0b KEY_ABORTED_COMMAND */
48 	"Equal_Error",			/* 0x0c KEY_EQUAL */
49 	"Volume_Overflow",		/* 0x0d KEY_VOLUME_OVERFLOW */
50 	"Miscompare_Error",		/* 0x0e KEY_MISCOMPARE */
51 	"Reserved",			/* 0x0f KEY_RESERVED */
52 					/* ==== SUN SCSA 'pseudo' keys */
53 	"fatal",			/* 0x10 SUN_KEY_FATAL */
54 	"timeout",			/* 0x11 SUN_KEY_TIMEOUT */
55 	"EOF",				/* 0x12 SUN_KEY_EOF */
56 	"EOT",				/* 0x13 SUN_KEY_EOT */
57 	"length_error",			/* 0x14 SUN_KEY_LENGTH */
58 	"BOT",				/* 0x15 SUN_KEY_BOT */
59 	"wrong_tape_media"		/* 0x16 SUN_KEY_WRONGMEDIA */
60 };
61 
62 
63 char *scsi_state_bits = "\20\05STS\04XFER\03CMD\02SEL\01ARB";
64 
65 
66 /*
67  * This structure is used to allow you to quickly determine the size of the
68  * cdb by examining the cmd code.  It is used in conjunction with the
69  * CDB_GROUPID macro.  Lookup returns size of cdb.  If unknown, zero returned.
70  */
71 uchar_t	scsi_cdb_size[] = {
72 	CDB_GROUP0,	/* Group 0, 6  byte cdb */
73 	CDB_GROUP1,	/* Group 1, 10 byte cdb */
74 	CDB_GROUP2,	/* Group 2, 10 byte cdb */
75 	CDB_GROUP3,	/* Group 3,  reserved */
76 	CDB_GROUP4,	/* Group 4, 16 byte cdb */
77 	CDB_GROUP5,	/* Group 5, 12 byte cdb */
78 	CDB_GROUP6,	/* Group 6,  ? byte cdb (vendor specific) */
79 	CDB_GROUP7	/* Group 7,  ? byte cdb (vendor specific) */
80 };
81 
82 /*
83  * Basic SCSI command description strings that can be used by drivers
84  * to pass to scsi_errmsg().
85  */
86 struct scsi_key_strings scsi_cmds[] = {
87 	SCSI_CMDS_KEY_STRINGS,
88 	SCSI_CMDS_KEY_STRINGS_CDIO,
89 	-1,			NULL
90 };
91