Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/i386/include/IOKit/scsi/SCSITask.h

1/*
2 * Copyright (c) 1998-2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25#ifndef _IOKIT_SCSI_TASK_H_
26#define _IOKIT_SCSI_TASK_H_
27
28
29#if KERNEL
30#include <IOKit/IOTypes.h>
31#else
32#include <CoreFoundation/CoreFoundation.h>
33#endif
34
35
36/*! @header SCSITask
37SCSITask typedefs and constants used inside the kernel and user space.
38
39Note that the SCSITaskIdentifier is an opaque object and that directly
40casting the SCSITaskIdentifier to any other type is discouraged. The SCSITask
41implementation changes when necessary to accomodate architectural changes,
42performance improvements, and bug fixes.
43
44Device and protocol layer drivers that need to access information
45contained in a SCSITask should use the appropriate accessor methods in
46IOSCSIPrimaryCommandsDevice.h or IOSCSIProtocolServices.h
47*/
48
49
50/*! @typedef SCSIDeviceIdentifier
51 @abstract 64-bit number to represent a SCSI Device.
52@discussion If the identifier can either be that of an initiator or a target,
53 SCSIDeviceIdentifier should be used.
54*/
55
56typedef UInt64 SCSIDeviceIdentifier;
57
58/*! @typedef SCSITargetIdentifier
59 @abstract 64-bit number to represent a SCSI Target Device.
60@discussion If the identifier is for a target only and not an initiator, then
61SCSITargetIdentifier should be used.
62*/
63
64typedef SCSIDeviceIdentifier SCSITargetIdentifier;
65
66/*! @typedef SCSIInitiatorIdentifier
67 @abstract 64-bit number to represent a SCSI Initiator Device.
68@discussion If the identifier is for an initiator only and not a target, then
69SCSIInitiatorIdentifier should be used.
70*/
71
72typedef SCSIDeviceIdentifier SCSIInitiatorIdentifier;
73
74/*! @typedef SCSILogicalUnitNumber
75 @abstract 64-bit number to represent a logical unit.
76@discussion 64-bit number to represent a logical unit.
77*/
78
79typedef UInt64 SCSILogicalUnitNumber;
80
81/*! @typedef SCSITaggedTaskIdentifier
82 @abstract 64-bit number to represent a unique task identifier.
83@discussion The Tagged Task Identifier is used when a Task has a Task Attribute other
84than SIMPLE. The SCSI Application Layer client that controls the Logical
85Unit for which a Task is intended is required to guarantee that the Task
86Tag Identifier is unique. Zero cannot be used a a Tag value as this is used
87to when a Tagged Task Identifier value is needed for a Task with a SIMPLE
88attribute.
89*/
90
91typedef UInt64 SCSITaggedTaskIdentifier;
92
93/*!
94@enum Untagged Task Identifier
95@discussion The Untagged Task Identifier is used to indicate no unique tag
96is associated with the Task.
97@constant kSCSIUntaggedTaskIdentifier This value means the task is untagged.
98 */
99
100enum
101{
102kSCSIUntaggedTaskIdentifier = 0
103};
104
105/*!
106@typedef SCSITaskAttribute
107@abstract Attributes for task delivery.
108@discussion The Task Attribute defines how this task should be managed
109when determing order for queueing and submission to the
110appropriate device server. The Task Attribute is set by the SCSI
111Application Layer and cannot be modified by the SCSI Protocol Layer.
112@constant kSCSITask_SIMPLE The task has a simple attribute.
113@constant kSCSITask_ORDERED The task has an ordered attribute.
114@constant kSCSITask_HEAD_OF_QUEUE The task has a head-of-queue attribute.
115@constant kSCSITask_ACA The task has an auto-contingent-allegiance attribute.
116 */
117
118typedef enum SCSITaskAttribute
119{
120kSCSITask_SIMPLE= 0,
121kSCSITask_ORDERED= 1,
122kSCSITask_HEAD_OF_QUEUE= 2,
123kSCSITask_ACA= 3
124} SCSITaskAttribute;
125
126/*!
127@typedef SCSITaskState
128@abstract Attributes for task state.
129@discussion The Task State represents the current state of the task.
130The state is set to NEW_TASK when the task is created. The SCSI Protocol
131Layer will then adjust the state as the task is queued and during
132execution. The SCSI Application Layer can examine the state to monitor
133the progress of a task. The Task State can only be modified by the SCSI
134Protocol Layer. The SCSI Application Layer can only read the state.
135@constant kSCSITaskState_NEW_TASK The task state is new task.
136@constant kSCSITaskState_ENABLED The task is enabled and queued.
137@constant kSCSITaskState_BLOCKED The task is blocked.
138@constant kSCSITaskState_DORMANT The task is dormant.
139@constant kSCSITaskState_ENDED The task is complete.
140 */
141
142typedef enum SCSITaskState
143{
144kSCSITaskState_NEW_TASK= 0,
145kSCSITaskState_ENABLED= 1,
146kSCSITaskState_BLOCKED= 2,
147kSCSITaskState_DORMANT= 3,
148kSCSITaskState_ENDED= 4
149} SCSITaskState;
150
151
152/*!
153@typedef SCSIServiceResponse
154@abstract Attributes for task service response.
155@discussion The Service Response represents the execution status of
156a service request made to a Protocol Services Driver. The Service
157Response can only be modified by the SCSI Protocol Layer. The SCSI
158Application Layer can only read the state.
159 */
160
161typedef enum SCSIServiceResponse
162{
163/*!
164@constant kSCSIServiceResponse_Request_In_Process
165Not defined in SAM specification, but is a service response used
166for asynchronous commands that are not yet completed.
167*/
168kSCSIServiceResponse_Request_In_Process= 0,
169
170/*!
171@constant kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE
172The service request failed because of a delivery or target failure.
173*/
174kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE= 1,
175
176/*!
177@constant kSCSIServiceResponse_TASK_COMPLETE
178The task completed.
179*/
180kSCSIServiceResponse_TASK_COMPLETE = 2,
181
182/*!
183@constant kSCSIServiceResponse_LINK_COMMAND_COMPLETE
184The linked command completed.
185*/
186kSCSIServiceResponse_LINK_COMMAND_COMPLETE= 3,
187
188/*!
189@constant kSCSIServiceResponse_FUNCTION_COMPLETE
190The task management function completed.
191*/
192kSCSIServiceResponse_FUNCTION_COMPLETE= 4,
193
194/*!
195@constant kSCSIServiceResponse_FUNCTION_REJECTED
196The task management function was rejected.
197*/
198kSCSIServiceResponse_FUNCTION_REJECTED= 5
199} SCSIServiceResponse;
200
201/*!
202@typedef SCSITaskStatus
203@abstract Attributes for task status.
204@discussion The Task Status represents the completion status
205of the task which provides the SCSI Application Layer with
206additional information about how to procede in handling a
207completed task.
208
209The SCSI Architecture Model specification only defines task
210status values for when a task completes with a service response
211of either TASK_COMPLETED or LINK_COMMAND_COMPLETE.
212
213Since additional information will aid in error recovery when
214a task fails to be completed by a device due to a service
215response of kSCSIServiceResponse_SERVICE_DELIVERY_OR_TARGET_FAILURE,
216additional values have been defined that can be returned by the
217SCSI Protocol Layer to inform the SCSI Application Layer of the
218cause of the delivery failure.
219
220The Task Status can only be modified by the SCSI Protocol Layer.
221The SCSI Application Layer can only read the status
222*/
223typedef enum SCSITaskStatus
224{
225
226/*!
227@constant kSCSITaskStatus_GOOD
228The task completed with a status of GOOD.
229*/
230
231kSCSITaskStatus_GOOD= 0x00,
232
233/*!
234@constant kSCSITaskStatus_CHECK_CONDITION
235The task completed with a status of CHECK_CONDITION. Additional
236information about the condition should be available in the sense data.
237*/
238
239kSCSITaskStatus_CHECK_CONDITION= 0x02,
240
241/*!
242@constant kSCSITaskStatus_CONDITION_MET
243The task completed with a status of CONDITION_MET.
244*/
245
246kSCSITaskStatus_CONDITION_MET= 0x04,
247
248/*!
249@constant kSCSITaskStatus_BUSY
250The task completed with a status of BUSY. The device server might need
251time to process a request and a delay may be required.
252*/
253kSCSITaskStatus_BUSY= 0x08,
254
255/*!
256@constant kSCSITaskStatus_INTERMEDIATE
257The task completed with a status of INTERMEDIATE.
258*/
259kSCSITaskStatus_INTERMEDIATE= 0x10,
260
261/*!
262@constant kSCSITaskStatus_INTERMEDIATE_CONDITION_MET
263The task completed with a status of INTERMEDIATE_CONDITION_MET.
264*/
265kSCSITaskStatus_INTERMEDIATE_CONDITION_MET= 0x14,
266
267/*!
268@constant kSCSITaskStatus_RESERVATION_CONFLICT
269The task completed with a status of RESERVATION_CONFLICT.
270*/
271kSCSITaskStatus_RESERVATION_CONFLICT= 0x18,
272
273/*!
274@constant kSCSITaskStatus_TASK_SET_FULL
275The task completed with a status of TASK_SET_FULL. The device server
276may need to complete a task before the initiator sends another.
277*/
278kSCSITaskStatus_TASK_SET_FULL= 0x28,
279
280/*!
281@constant kSCSITaskStatus_ACA_ACTIVE
282The task completed with a status of ACA_ACTIVE. The device server may
283need the initiator to clear the Auto-Contingent Allegiance condition
284before it will respond to new commands.
285*/
286kSCSITaskStatus_ACA_ACTIVE= 0x30,
287
288/*!
289@constant kSCSITaskStatus_TaskTimeoutOccurred
290If a task is aborted by the SCSI Protocol Layer due to it exceeding
291the timeout value specified by the task, the task status shall be
292set to kSCSITaskStatus_TaskTimeoutOccurred.
293*/
294
295kSCSITaskStatus_TaskTimeoutOccurred= 0x01,
296
297/*!
298@constant kSCSITaskStatus_ProtocolTimeoutOccurred
299If a task is aborted by the SCSI Protocol Layer due to it exceeding a
300timeout value specified by the support for the protocol or a related
301specification, the task status shall be set to
302kSCSITaskStatus_ProtocolTimeoutOccurred.
303*/
304
305kSCSITaskStatus_ProtocolTimeoutOccurred= 0x02,
306
307/*!
308@constant kSCSITaskStatus_DeviceNotResponding
309If a task is unable to be delivered due to a failure of the device not
310accepting the task or the device acknowledging the attempt to send it the
311device the task status shall be set to kSCSITaskStatus_DeviceNotResponding.
312This will allow the SCSI Application driver to perform the necessary steps
313to try to recover the device. This shall only be reported after the SCSI
314Protocol Layer driver has attempted all protocol specific attempts to recover
315the device.
316*/
317
318kSCSITaskStatus_DeviceNotResponding= 0x03,
319
320/*!
321@constant kSCSITaskStatus_DeviceNotPresent
322If the task is unable to be delivered because the device has been
323detached, the task status shall be set to kSCSITaskStatus_DeviceNotPresent.
324This will allow the SCSI Application Layer to halt the sending of tasks
325to the device and, if supported, perform any device failover or system
326cleanup.
327*/
328kSCSITaskStatus_DeviceNotPresent= 0x04,
329
330/*!
331@constant kSCSITaskStatus_DeliveryFailure
332If the task is unable to be
333delivered to the device due to a failure in the SCSI Protocol Layer,
334such as a bus reset or communications error, but the device is is
335known to be functioning properly, the task status shall be set to
336kSCSITaskStatus_DeliveryFailure. This can also be reported if the
337task could not be delivered due to a protocol error that has since
338been corrected.
339 */
340kSCSITaskStatus_DeliveryFailure= 0x05,
341
342/*!
343@constant kSCSITaskStatus_No_Status
344This status is not defined by
345the SCSI specifications, but is here to provide a status that can
346be returned in cases where there is not status available from the
347device or protocol, for example, when the service response is
348neither TASK_COMPLETED nor LINK_COMMAND_COMPLETE or when the
349service response is SERVICE_DELIVERY_OR_TARGET_FAILURE and the
350reason for failure could not be determined.
351*/
352kSCSITaskStatus_No_Status= 0xFF
353} SCSITaskStatus;
354
355/*!
356@enum Command Descriptor Block Size
357@discussion Command Descriptor Block Size constants.
358*/
359enum
360{
361/*!
362@constant kSCSICDBSize_Maximum This is the largest size a Command Descriptor
363Block can be as specified in SPC-2.
364*/
365kSCSICDBSize_Maximum = 16,
366
367/*!
368@constant kSCSICDBSize_6Byte Use this for a 6-byte CDB.
369*/
370kSCSICDBSize_6Byte = 6,
371
372/*!
373@constant kSCSICDBSize_10Byte Use this for a 10-byte CDB.
374*/
375kSCSICDBSize_10Byte = 10,
376
377/*!
378@constant kSCSICDBSize_12Byte Use this for a 12-byte CDB.
379*/
380kSCSICDBSize_12Byte = 12,
381
382/*!
383@constant kSCSICDBSize_16Byte Use this for a 16-byte CDB.
384*/
385kSCSICDBSize_16Byte = 16
386};
387
388typedef UInt8 SCSICommandDescriptorBlock[kSCSICDBSize_Maximum];
389
390/*!
391@enum Data Transfer Direction
392@discussion DataTransferDirection constants.
393*/
394enum
395{
396/*!
397@constant kSCSIDataTransfer_NoDataTransfer Use this for tasks
398that transfer no data.
399*/
400kSCSIDataTransfer_NoDataTransfer= 0x00,
401
402/*!
403@constant kSCSIDataTransfer_FromInitiatorToTarget Use this for tasks that transfer
404data from the initiator to the target.
405*/
406kSCSIDataTransfer_FromInitiatorToTarget= 0x01,
407
408/*!
409@constant kSCSIDataTransfer_FromTargetToInitiator Use this for tasks that transfer
410data from the target to the initiator.
411*/
412kSCSIDataTransfer_FromTargetToInitiator= 0x02
413};
414
415
416#if defined(KERNEL) && defined(__cplusplus)
417
418/* Libkern includes */
419#include <libkern/c++/OSObject.h>
420
421
422/*!
423@enum SCSITaskMode
424@discussion The SCSI Task mode is used by the SCSI
425Protocol Layer to indicate what mode the task is executing.
426*/
427typedef enum SCSITaskMode
428{
429kSCSITaskMode_CommandExecution= 1,
430kSCSITaskMode_Autosense= 2
431} SCSITaskMode;
432
433/*!
434@typedef SCSITaskIdentifier
435@discussion This is an opaque object that represents a task.
436This is used so that drivers for both the SCSI Protocol Layer
437and the SCSI Application Layer cannot modify the SCSITask object
438directly but must instead use the inherited methods to do so. This
439allows the implementation of SCSITask to change without directly
440impacting device and protocol layer drivers. In addition, it
441prevents changing of properties that are not allowed to be
442changed by a given layer.
443*/
444typedef OSObject *SCSITaskIdentifier;
445
446
447/*!
448@typedef SCSITaskCompletion
449@discussion This is the typedef for completion routines that
450work with SCSITaskIdentifiers.
451*/
452typedef void ( *SCSITaskCompletion )( SCSITaskIdentifier completedTask );
453
454#endif/* defined(KERNEL) && defined(__cplusplus) */
455
456#endif /* _IOKIT_SCSI_TASK_H_ */
457

Archive Download this file

Revision: 1171