2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)usalcmd.h 2.22 04/09/04 Copyright 1986 J. Schilling */
15 * Definitions for the SCSI 'usal_cmd' structure that has been created
16 * for the SCSI general driver 'usal' for SunOS and Solaris but
17 * now is used for wrapping general libusal SCSI transport requests.
19 * Copyright (c) 1986 J. Schilling
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License version 2
24 * as published by the Free Software Foundation.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License along with
32 * this program; see the file COPYING. If not, write to the Free Software
33 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 #if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
44 # if defined(_BIT_FIELDS_HTOL) /* Motorola byteorder */
47 * #error will not work for all compilers (e.g. sunos4)
48 * The following line will abort compilation on all compilers
49 * if none of the above is defines. And that's what we want.
51 error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
55 #include <usal/scsisense.h>
56 #include <usal/scsicdb.h>
64 * Leave these definitions here if possible to avoid the need to
65 * include scsireg.h which makes problems on some OS because these
66 * OS define the same types as in scsireg.h
72 #define ST_VU_00 0x01 /* Vendor unique */
73 #define ST_CHK_COND 0x02 /* Check condition */
74 #define ST_COND_MET 0x04 /* Condition met */
75 #define ST_BUSY 0x08 /* Busy */
76 #define ST_IS_SEND 0x10 /* Intermediate status send */
77 #define ST_VU_05 0x20 /* Vendor unique */
78 #define ST_VU_06 0x40 /* Vendor unique */
79 #define ST_RSVD_07 0x80 /* Reserved */
82 * Sense key values for extended sense.
84 #define SC_NO_SENSE 0x00
85 #define SC_RECOVERABLE_ERROR 0x01
86 #define SC_NOT_READY 0x02
87 #define SC_MEDIUM_ERROR 0x03
88 #define SC_HARDWARE_ERROR 0x04
89 #define SC_ILLEGAL_REQUEST 0x05
90 #define SC_UNIT_ATTENTION 0x06
91 #define SC_WRITE_PROTECT 0x07
92 #define SC_BLANK_CHECK 0x08
93 #define SC_VENDOR_UNIQUE 0x09
94 #define SC_COPY_ABORTED 0x0A
95 #define SC_ABORTED_COMMAND 0x0B
97 #define SC_VOLUME_OVERFLOW 0x0D
98 #define SC_MISCOMPARE 0x0E
99 #define SC_RESERVED 0x0F
102 * Messages that SCSI can send.
104 #define SC_COMMAND_COMPLETE 0x00
105 #define SC_SYNCHRONOUS 0x01
106 #define SC_SAVE_DATA_PTR 0x02
107 #define SC_RESTORE_PTRS 0x03
108 #define SC_DISCONNECT 0x04
109 #define SC_ABORT 0x06
110 #define SC_MSG_REJECT 0x07
111 #define SC_NO_OP 0x08
112 #define SC_PARITY 0x09
113 #define SC_IDENTIFY 0x80
114 #define SC_DR_IDENTIFY 0xc0
115 #define SC_DEVICE_RESET 0x0c
117 #define SC_G0_CDBLEN 6 /* Len of Group 0 commands */
118 #define SC_G1_CDBLEN 10 /* Len of Group 1 commands */
119 #define SC_G5_CDBLEN 12 /* Len of Group 5 commands */
121 #define SCG_MAX_CMD 24 /* 24 bytes max. size is supported */
122 #define SCG_MAX_STATUS 3 /* XXX (sollte 4 allign.) Mamimum Status Len */
123 #define SCG_MAX_SENSE 32 /* Mamimum Sense Len for auto Req. Sense */
125 #define DEF_SENSE_LEN 16 /* Default Sense Len */
126 #define CCS_SENSE_LEN 18 /* Sense Len for CCS compatible devices */
129 caddr_t addr; /* Address of data in user space */
130 int size; /* DMA count for data transfer */
131 int flags; /* see below for definition */
132 int cdb_len; /* Size of SCSI command in bytes */
133 /* NOTE: rel 4 uses this field only */
134 /* with commands not in group 1 or 2*/
135 int sense_len; /* for intr() if -1 don't get sense */
136 int timeout; /* timeout in seconds */
137 /* NOTE: actual resolution depends */
138 /* on driver implementation */
139 int kdebug; /* driver kernel debug level */
140 int resid; /* Bytes not transfered */
141 int error; /* Error code from usalintr() */
142 int ux_errno; /* UNIX error code */
144 XXX struct scsi_status scb; ??? /* Status returnd by command */
147 struct scsi_status Scb; /* Status returnd by command */
148 Uchar cmd_scb[SCG_MAX_STATUS];
150 #define scb u_scb.Scb
152 XXX struct scsi_sense sense; ??? /* Sense bytes from command */
155 struct scsi_sense Sense; /* Sense bytes from command */
156 Uchar cmd_sense[SCG_MAX_SENSE];
158 #define sense u_sense.Sense
159 int sense_count; /* Number of bytes valid in sense */
160 int target; /* SCSI target id */
161 /* NOTE: The SCSI target id field */
162 /* does not need to be filled unless */
163 /* the low level transport is a real */
164 /* usal driver. In this case the low */
165 /* level transport routine of libusal */
166 /* will fill in the needed value */
167 union { /* SCSI command descriptor block */
168 struct scsi_g0cdb g0_cdb;
169 struct scsi_g1cdb g1_cdb;
170 struct scsi_g5cdb g5_cdb;
171 Uchar cmd_cdb[SCG_MAX_CMD];
172 } cdb; /* 24 bytes max. size is supported */
175 #define dma_read flags /* 1 if DMA to Sun, 0 otherwise */
178 * definition for flags field in usal_cmd struct
180 #define SCG_RECV_DATA 0x0001 /* DMA direction to Sun */
181 #define SCG_DISRE_ENA 0x0002 /* enable disconnect/reconnect */
182 #define SCG_SILENT 0x0004 /* be silent on errors */
183 #define SCG_CMD_RETRY 0x0008 /* enable retries */
184 #define SCG_NOPARITY 0x0010 /* disable parity for this command */
187 * definition for error field in usal_cmd struct
189 * The codes refer to SCSI general errors, not to device
190 * specific errors. Device specific errors are discovered
191 * by checking the sense data.
192 * The distinction between retryable and fatal is somewhat ad hoc.
194 #define SCG_NO_ERROR 0 /* cdb transported without error */
195 /* SCG_NO_ERROR incudes all commands */
196 /* where the SCSI status is valid */
198 #define SCG_RETRYABLE 1 /* any other case e.g. SCSI bus busy */
199 /* SCSI cdb could not be send, */
200 /* includes DMA errors other than */
203 #define SCG_FATAL 2 /* could not select target */
204 #define SCG_TIMEOUT 3 /* driver timed out */
211 #endif /* _SCG_SCGCMD_H */