]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/scsi/scsi-device/SCSIPublic.h
xnu-201.5.tar.gz
[apple/xnu.git] / iokit / IOKit / scsi / scsi-device / SCSIPublic.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 *
24 * SCSIPublic.h
25 *
26 */
27
28 #ifndef _SCSIPUBLIC_H
29 #define _SCSIPUBLIC_H
30
31 typedef struct _SCSIInquiry
32 {
33 unsigned char devType; /* 0 Device type, */
34 unsigned char devTypeMod; /* 1 Device type modifier */
35 unsigned char version; /* 2 ISO/ECMA/ANSI version */
36 unsigned char format; /* 3 Response data format */
37 unsigned char length; /* 4 Additional Length */
38 unsigned char reserved5; /* 5 Reserved */
39 unsigned char reserved6; /* 6 Reserved */
40 unsigned char flags; /* 7 Capability flags */
41 unsigned char vendorName[8]; /* 8-15 Vendor-specific */
42 unsigned char productName[16]; /* 16-31 Product id */
43 unsigned char productRevision[4]; /* 32-35 Product revision */
44 unsigned char vendorSpecific[20]; /* 36-55 Vendor stuff */
45 unsigned char scsi3Options; /* 56 SCSI-3 options */
46 unsigned char moreReserved[39]; /* 57-95 Reserved */
47 } SCSIInquiry;
48
49 /*
50 * These are device type qualifiers. We need them to distinguish between "unknown"
51 * and "missing" devices.
52 */
53 enum
54 {
55 kSCSIDevTypeQualifierConnected = 0x00, /* Exists and is connected */
56 kSCSIDevTypeQualifierNotConnected = 0x20, /* Logical unit exists */
57 kSCSIDevTypeQualifierReserved = 0x40,
58 kSCSIDevTypeQualifierMissing = 0x60, /* No such logical unit */
59 kSCSIDevTypeQualifierVendorSpecific = 0x80, /* Non-standardized */
60 kSCSIDevTypeQualifierMask = 0xE0,
61 };
62
63 enum
64 {
65 kSCSIDevTypeModRemovable = 0x80, /* Device has removable media */
66 };
67
68 enum _SCSIDevFlags
69 {
70 kSCSIDevCapRelAdr = 0x80,
71 kSCSIDevCapWBus32 = 0x40,
72 kSCSIDevCapWBus16 = 0x20,
73 kSCSIDevCapSync = 0x10,
74 kSCSIDevCapLinked = 0x08,
75 kSCSIDevCapCmdQue = 0x02,
76 kSCSIDevCapSftRe = 0x01,
77 };
78
79 typedef struct _SCSISenseData
80 {
81 unsigned char errorCode; /* 0 Result validity */
82 unsigned char segmentNumber; /* 1 Segment number */
83 unsigned char senseKey; /* 2 Sense code, flags */
84 unsigned char info[4]; /* 3-6 Sense-key specific */
85 unsigned char additionalSenseLength; /* 7 Sense length info */
86 unsigned char reservedForCopy[4]; /* 8-11 Sense-key specific */
87 unsigned char additionalSenseCode; /* 12 What kind of error */
88 unsigned char additionalSenseQualifier; /* 13 More error info */
89 unsigned char fruCode; /* 14 Field replacable */
90 unsigned char senseKeySpecific[2]; /* 15-16 Additional info */
91 unsigned char additional[101]; /* 17-26 Additional info */
92 } SCSISenseData;
93
94 /*
95 * The high-bit of errorCode signals whether there is a logical
96 * block. The low value signals whether there is a valid sense
97 */
98 enum _SCSIErrorCode
99 {
100 kSCSISenseHasLBN = 0x80, /* Logical block number set */
101 kSCSISenseInfoValid = 0x70, /* Is sense key valid? */
102 kSCSISenseInfoMask = 0x70, /* Mask for sense info */
103 kSCSISenseCurrentErr = 0x70, /* Error code (byte 0 & 0x7F */
104 kSCSISenseDeferredErr = 0x71, /* Error code (byte 0 & 0x7F */
105 };
106
107 /*
108 * These bits may be set in the sense key
109 */
110 enum _SCSISenseKeyMasks
111 {
112 kSCSISenseKeyMask = 0x0F,
113 kSCSISenseILI = 0x20, /* Illegal logical Length */
114 kSCSISenseEOM = 0x40, /* End of media */
115 kSCSISenseFileMark = 0x80, /* End of file mark */
116 };
117 /*
118 * SCSI sense codes. (Returned after request sense).
119 */
120 enum _SCSISenseKeys
121 {
122 kSCSISenseNone = 0x00, /* No error */
123 kSCSISenseRecoveredErr = 0x01, /* Warning */
124 kSCSISenseNotReady = 0x02, /* Device not ready */
125 kSCSISenseMediumErr = 0x03, /* Device medium error */
126 kSCSISenseHardwareErr = 0x04, /* Device hardware error */
127 kSCSISenseIllegalReq = 0x05, /* Illegal request for dev. */
128 kSCSISenseUnitAtn = 0x06, /* Unit attention (not err) */
129 kSCSISenseDataProtect = 0x07, /* Data protection */
130 kSCSISenseBlankCheck = 0x08, /* Tape-specific error */
131 kSCSISenseVendorSpecific = 0x09, /* Vendor-specific error */
132 kSCSISenseCopyAborted = 0x0a, /* Copy request cancelled */
133 kSCSISenseAbortedCmd = 0x0b, /* Initiator aborted cmd. */
134 kSCSISenseEqual = 0x0c, /* Comparison equal */
135 kSCSISenseVolumeOverflow = 0x0d, /* Write past end mark */
136 kSCSISenseMiscompare = 0x0e, /* Comparison failed */
137 };
138
139 enum _SCSIStatus
140 {
141 kSCSIStatusGood = 0x00,
142 kSCSIStatusCheckCondition = 0x02,
143 kSCSIStatusConditionMet = 0x04,
144 kSCSIStatusBusy = 0x08,
145 kSCSIStatusIntermediate = 0x10,
146 kSCSIStatusIntermediateMet = 0x0a,
147 kSCSIStatusReservationConfict = 0x18,
148 kSCSIStatusCommandTerminated = 0x22,
149 kSCSIStatusQueueFull = 0x28,
150 };
151
152
153 enum _SCSIDevTypes
154 {
155 kSCSIDevTypeDirect = 0, /* Hard disk (not CD-ROM) */
156 kSCSIDevTypeSequential, /* Magtape or DAT */
157 kSCSIDevTypePrinter, /* Printer */
158 kSCSIDevTypeProcessor, /* Attached processor */
159 kSCSIDevTypeWorm, /* Write-once, read multiple */
160 kSCSIDevTypeCDROM, /* CD-ROM */
161 kSCSIDevTypeScanner, /* Scanner */
162 kSCSIDevTypeOptical, /* Optical disk */
163 kSCSIDevTypeChanger, /* Jukebox */
164 kSCSIDevTypeComm, /* Communication link */
165 kSCSIDevTypeGraphicArts0A,
166 kSCSIDevTypeGraphicArts0B,
167 kSCSIDevTypeFirstReserved, /* Reserved sequence start */
168 kSCSIDevTypeUnknownOrMissing = 0x1F,
169 kSCSIDevTypeMask = 0x1F,
170 };
171
172 enum _SCSIInqVersion
173 {
174 kSCSIInqVersionSCSI3 = 0x03,
175 };
176
177 enum _SCSI3Options
178 {
179 kSCSI3InqOptionIUS = 0x01,
180 kSCSI3InqOptionQAS = 0x02,
181 kSCSI3InqOptionClockDT = 0x04,
182 };
183
184
185 /*
186 * SCSI command codes. Commands defined as ...6, ...10, ...12, are
187 * six-byte, ten-byte, and twelve-byte variants of the indicated command.
188 */
189
190 /*
191 * These commands are supported for all devices.
192 */
193 enum _SCSICmds
194 {
195 kSCSICmdChangeDefinition = 0x40,
196 kSCSICmdCompare = 0x39,
197 kSCSICmdCopy = 0x18,
198 kSCSICmdCopyAndVerify = 0x3a,
199 kSCSICmdInquiry = 0x12,
200 kSCSICmdLogSelect = 0x4c,
201 kSCSICmdLogSense = 0x4d,
202 kSCSICmdModeSelect12 = 0x55,
203 kSCSICmdModeSelect6 = 0x15,
204 kSCSICmdModeSense12 = 0x5a,
205 kSCSICmdModeSense6 = 0x1a,
206 kSCSICmdReadBuffer = 0x3c,
207 kSCSICmdRecvDiagResult = 0x1c,
208 kSCSICmdRequestSense = 0x03,
209 kSCSICmdSendDiagnostic = 0x1d,
210 kSCSICmdTestUnitReady = 0x00,
211 kSCSICmdWriteBuffer = 0x3b,
212
213 /*
214 * These commands are supported by direct-access devices only.
215 */
216 kSCSICmdFormatUnit = 0x04,
217 kSCSICmdLockUnlockCache = 0x36,
218 kSCSICmdPrefetch = 0x34,
219 kSCSICmdPreventAllowRemoval = 0x1e,
220 kSCSICmdRead6 = 0x08,
221 kSCSICmdRead10 = 0x28,
222 kSCSICmdReadCapacity = 0x25,
223 kSCSICmdReadDefectData = 0x37,
224 kSCSICmdReadLong = 0x3e,
225 kSCSICmdReassignBlocks = 0x07,
226 kSCSICmdRelease = 0x17,
227 kSCSICmdReserve = 0x16,
228 kSCSICmdRezeroUnit = 0x01,
229 kSCSICmdSearchDataEql = 0x31,
230 kSCSICmdSearchDataHigh = 0x30,
231 kSCSICmdSearchDataLow = 0x32,
232 kSCSICmdSeek6 = 0x0b,
233 kSCSICmdSeek10 = 0x2b,
234 kSCSICmdSetLimits = 0x33,
235 kSCSICmdStartStopUnit = 0x1b,
236 kSCSICmdSynchronizeCache = 0x35,
237 kSCSICmdVerify = 0x2f,
238 kSCSICmdWrite6 = 0x0a,
239 kSCSICmdWrite10 = 0x2a,
240 kSCSICmdWriteAndVerify = 0x2e,
241 kSCSICmdWriteLong = 0x3f,
242 kSCSICmdWriteSame = 0x41,
243
244 /*
245 * These commands are supported by sequential devices.
246 */
247 kSCSICmdRewind = 0x01,
248 kSCSICmdWriteFilemarks = 0x10,
249 kSCSICmdSpace = 0x11,
250 kSCSICmdLoadUnload = 0x1B,
251 /*
252 * ANSI SCSI-II for CD-ROM devices.
253 */
254 kSCSICmdReadCDTableOfContents = 0x43,
255 };
256
257 /*
258 * Message codes (for Msg In and Msg Out phases).
259 */
260 enum _SCSIMsgs
261 {
262 kSCSIMsgAbort = 0x06,
263 kSCSIMsgAbortTag = 0x0d,
264 kSCSIMsgBusDeviceReset = 0x0c,
265 kSCSIMsgClearQueue = 0x0e,
266 kSCSIMsgCmdComplete = 0x00,
267 kSCSIMsgDisconnect = 0x04,
268 kSCSIMsgIdentify = 0x80,
269 kSCSIMsgIgnoreWideResdue = 0x23,
270 kSCSIMsgInitiateRecovery = 0x0f,
271 kSCSIMsgInitiatorDetectedErr = 0x05,
272 kSCSIMsgLinkedCmdComplete = 0x0a,
273 kSCSIMsgLinkedCmdCompleteFlag = 0x0b,
274 kSCSIMsgParityErr = 0x09,
275 kSCSIMsgRejectMsg = 0x07,
276 kSCSIMsgModifyDataPtr = 0x00, /* Extended msg */
277 kSCSIMsgNop = 0x08,
278 kSCSIMsgHeadOfQueueTag = 0x21, /* Two byte msg */
279 kSCSIMsgOrderedQueueTag = 0x22, /* Two byte msg */
280 kSCSIMsgSimpleQueueTag = 0x20, /* Two byte msg */
281 kSCSIMsgReleaseRecovery = 0x10,
282 kSCSIMsgRestorePointers = 0x03,
283 kSCSIMsgSaveDataPointers = 0x02,
284 kSCSIMsgSyncXferReq = 0x01, /* Extended msg */
285 kSCSIMsgWideDataXferReq = 0x03, /* Extended msg */
286 kSCSIMsgTerminateIOP = 0x11,
287 kSCSIMsgExtended = 0x01,
288 kSCSIMsgEnableDisconnectMask = 0x40,
289 };
290
291 #endif