]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/scsi/scsi-parallel/IOSCSIParallelCommand.h
21a72a1c3431d8026deb10fa67e78ff0a8f9e5be
[apple/xnu.git] / iokit / IOKit / scsi / scsi-parallel / IOSCSIParallelCommand.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 * IOSCSICommand.h
25 *
26 */
27 #ifndef _IOSCSIPARALLELCOMMAND_H
28 #define _IOSCSIPARALLELCOMMAND_H
29
30 class IOSCSIParallelDevice;
31 class IOSCSIParallelCommand;
32 class IOSyncer;
33
34 class IOSCSIParallelCommand : public IOSCSICommand
35 {
36 OSDeclareDefaultStructors(IOSCSIParallelCommand)
37
38 friend class IOSCSIParallelController;
39 friend class IOSCSIParallelDevice;
40
41 /*------------------Methods provided to IOCDBCommand users -------------------------*/
42 public:
43 /*
44 * Set/Get IOMemoryDescriptor object to I/O data buffer or sense data buffer.
45 */
46 void setPointers( IOMemoryDescriptor *desc,
47 UInt32 transferCount,
48 bool isWrite,
49 bool isSense = false );
50
51 void getPointers( IOMemoryDescriptor **desc,
52 UInt32 *transferCount,
53 bool *isWrite,
54 bool isSense = false );
55 /*
56 * Set/Get command timeout (mS)
57 */
58 void setTimeout( UInt32 timeoutmS );
59 UInt32 getTimeout();
60
61 /*
62 * Set async callback routine. Specifying no parameters indicates synchronous call.
63 */
64 void setCallback( void *target = 0, CallbackFn callback = 0, void *refcon = 0 );
65
66 /*
67 * Set/Get CDB information. (Generic CDB version)
68 */
69 void setCDB( CDBInfo *cdbInfo );
70 void getCDB( CDBInfo *cdbInfo );
71
72 /*
73 * Get CDB results. (Generic CDB version)
74 */
75 IOReturn getResults( CDBResults *cdbResults );
76
77 /*
78 * Get CDB Device this command is directed to.
79 */
80 IOCDBDevice *getDevice( IOCDBDevice *deviceType );
81
82 /*
83 * Command verbs
84 */
85 bool execute( UInt32 *sequenceNumber = 0 );
86 void abort( UInt32 sequenceNumber );
87 void complete();
88
89 /*
90 * Get pointers to client and command data.
91 */
92 void *getCommandData();
93 void *getClientData();
94
95 /*
96 * Get unique sequence number assigned to command.
97 */
98 UInt32 getSequenceNumber();
99
100 /*------------------ Additional methods provided to IOSCSICommand users -------------------------*/
101 public:
102 /*
103 * Set/Get CDB information. (SCSI specific version).
104 */
105 void setCDB( SCSICDBInfo *scsiCmd );
106 void getCDB( SCSICDBInfo *scsiCmd );
107
108 /*
109 * Get/Set CDB results. (SCSI specific version).
110 */
111 IOReturn getResults( SCSIResults *results );
112 void setResults( SCSIResults *results, SCSINegotiationResults *negotiationResults );
113
114 /*
115 * Get SCSI Device this command is directed to.
116 */
117 IOSCSIParallelDevice *getDevice( IOSCSIParallelDevice *deviceType );
118
119
120 /*
121 * Get SCSI Target/Lun for this command.
122 */
123 void getTargetLun( SCSITargetLun *targetLun );
124
125 /*
126 * Get/Set queue routing for this command.
127 */
128 void setQueueInfo( UInt32 forQueueType = kQTypeNormalQ, UInt32 forQueuePosition = kQPositionTail );
129 void getQueueInfo( UInt32 *forQueueType, UInt32 *forQueuePosition = 0 );
130
131 /*
132 * Get command type / Get original command.
133 *
134 * These methods are provided for the controller class to identify and relate commands.
135 * They are not usually of interest to the client side.
136 */
137 UInt32 getCmdType();
138 IOSCSIParallelCommand *getOriginalCmd();
139
140 /*
141 * Set to blank state, call prior to re-use of this object.
142 */
143 void zeroCommand();
144
145 /*------------------Methods private to the IOSCSICommand class-------------------------*/
146 public:
147 void free();
148
149 IOSCSIDevice *getDevice( IOSCSIDevice *deviceType );
150 void setResults( SCSIResults *results );
151
152 private:
153 IOReturn adapterStatusToIOReturnCode( SCSIAdapterStatus adapterStatus );
154 IOReturn scsiStatusToIOReturnCode( UInt8 scsiStatus );
155
156 private:
157 SCSICommandType cmdType;
158
159 IOSCSIParallelController *controller;
160 IOSCSIParallelDevice *device;
161
162 queue_head_t *list;
163 queue_chain_t nextCommand;
164
165 SCSICDBInfo scsiCmd;
166 SCSIResults results;
167
168 UInt32 timeout;
169 UInt32 timer;
170
171 UInt8 queueType;
172 UInt8 queuePosition;
173
174 IOMemoryDescriptor *xferDesc;
175 UInt32 xferCount;
176 UInt32 xferDirection;
177
178 UInt32 senseLength;
179 IOMemoryDescriptor *senseData;
180
181 IOSCSIParallelCommand *origCommand;
182
183 union
184 {
185 struct
186 {
187 UInt32 reserved;
188 IOSyncer * lock;
189 } sync;
190 struct
191 {
192 CallbackFn callback;
193 void *target;
194 void *refcon;
195 } async;
196 } completionInfo;
197
198 UInt32 dataSize;
199 void *dataArea;
200 void *commandPrivateData;
201 void *clientData;
202
203 UInt32 sequenceNumber;
204 };
205
206 #endif