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