Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/include/IOKit/usb/IOUSBCommand.h

Source at commit 296 created 12 years 10 months ago.
By ifabio, add i386 folder
1/*
2 * Copyright (c) 1998-2006 Apple Computer, 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#ifndef _IOKIT_IOUSBCOMMAND_H
25#define _IOKIT_IOUSBCOMMAND_H
26
27#include <IOKit/IOCommand.h>
28#include <IOKit/IOCommandPool.h>
29#include <IOKit/IOMemoryDescriptor.h>
30#include <IOKit/IODMACommand.h>
31#include <IOKit/usb/USB.h>
32
33/*
34 * USB Command
35 * This is the command block for a USB command to be queued on the
36 * Command Gate of the WorkLoop. Although the actual work of creating
37 * the command and enqueueing it is done for them via the deviceRequest,
38 * read, and write methods, this is the primary way that devices will get
39 * work done.
40 * Note: This is private to IOUSBController and should be moved to a
41 * private header.
42 */
43
44typedef enum {
45 DEVICE_REQUEST,// Device request using pointer
46 READ,
47 WRITE,
48 CREATE_EP,
49 DELETE_EP,
50 DEVICE_REQUEST_DESC,// Device request using descriptor
51DEVICE_REQUEST_BUFFERCOMMAND// Device request using a second IOUSBCommand in _bufferCommand
52} usbCommand;
53
54
55
56/*!
57 @class IOUSBCommand
58 @abstract A subclass of IOCommand that is used to add USB specific data.
59 */
60class IOUSBCommand : public IOCommand
61{
62 OSDeclareAbstractStructors(IOUSBCommand)
63
64protected:
65 usbCommand_selector;
66 IOUSBDeviceRequestPtr_request;
67 USBDeviceAddress_address;
68 UInt8_endpoint;
69 UInt8_direction;
70 UInt8_type;
71 bool_bufferRounding;
72 IOMemoryDescriptor *_buffer;
73 IOUSBCompletion_uslCompletion;
74 IOUSBCompletion_clientCompletion;
75 UInt32_dataRemaining;// For Control transfers
76 UInt8_stage;// For Control transfers
77 IOReturn_status;
78 IOMemoryDescriptor *_origBuffer;
79 IOUSBCompletion_disjointCompletion;
80 IOByteCount_dblBufLength;
81 UInt32_noDataTimeout;
82 UInt32_completionTimeout;
83 UInt32_UIMScratch[10];
84
85 struct ExpansionData
86 {
87 IOByteCount_reqCount;
88IOMemoryDescriptor *_requestMemoryDescriptor;
89IOMemoryDescriptor *_bufferMemoryDescriptor;
90bool_multiTransferTransaction;
91bool_finalTransferInTransaction;
92 bool_useTimeStamp;
93 AbsoluteTime_timeStamp;
94bool_isSyncTransfer;// Returns true if the command is used for a synchronous transfer
95IODMACommand*_dmaCommand;// used to get memory mapping
96IOUSBCommand*_bufferUSBCommand;// points to another IOUSBCommand used for phase 2 of control transactions
97IOUSBCommand*_masterUSBCommand;// points from the bufferUSBCommand back to the parent command
98 };
99 ExpansionData * _expansionData;
100
101 // we override these OSObject method in order to allocate and release our expansion data
102 virtual bool init();
103 virtual void free();
104
105public:
106
107 // static constructor
108 static IOUSBCommand *NewCommand(void);
109
110 // Manipulators
111 voidSetSelector(usbCommand sel);
112 void SetRequest(IOUSBDeviceRequestPtr req);
113 void SetAddress(USBDeviceAddress addr);
114 void SetEndpoint(UInt8 ep);
115 void SetDirection(UInt8 dir);
116 void SetType(UInt8 type);
117 void SetBufferRounding(bool br);
118 void SetBuffer(IOMemoryDescriptor *buf);
119 void SetUSLCompletion(IOUSBCompletion completion);
120 void SetClientCompletion(IOUSBCompletion completion);
121 void SetDataRemaining(UInt32 dr);
122 void SetStage(UInt8 stage);
123 void SetStatus(IOReturn stat);
124 void SetOrigBuffer(IOMemoryDescriptor *buf);
125 void SetDisjointCompletion(IOUSBCompletion completion);
126 void SetDblBufLength(IOByteCount len);
127 void SetNoDataTimeout(UInt32 to);
128 void SetCompletionTimeout(UInt32 to);
129 void SetUIMScratch(UInt32 index, UInt32 value);
130 void SetReqCount(IOByteCount reqCount);
131 voidSetRequestMemoryDescriptor(IOMemoryDescriptor *requestMemoryDescriptor);
132 voidSetBufferMemoryDescriptor(IOMemoryDescriptor *bufferMemoryDescriptor);
133 voidSetMultiTransferTransaction(bool);
134 voidSetFinalTransferInTransaction(bool);
135 voidSetUseTimeStamp(bool);
136 voidSetTimeStamp(AbsoluteTime timeStamp);
137voidSetIsSyncTransfer(bool);
138inline voidSetDMACommand(IODMACommand *dmaCommand){ _expansionData->_dmaCommand = dmaCommand; }
139voidSetBufferUSBCommand(IOUSBCommand *bufferUSBCommand);
140
141// Accessors
142 usbCommandGetSelector(void);
143 IOUSBDeviceRequestPtrGetRequest(void);
144 USBDeviceAddressGetAddress(void);
145 UInt8GetEndpoint(void);
146 UInt8GetDirection(void);
147 UInt8GetType(void);
148 boolGetBufferRounding(void);
149 IOMemoryDescriptor *GetBuffer(void);
150 IOUSBCompletionGetUSLCompletion(void);
151 IOUSBCompletionGetClientCompletion(void);
152 UInt32GetDataRemaining(void);
153 UInt8GetStage(void);
154 IOReturnGetStatus(void);
155 IOMemoryDescriptor *GetOrigBuffer(void);
156 IOUSBCompletionGetDisjointCompletion(void);
157 IOByteCountGetDblBufLength(void);
158 UInt32GetNoDataTimeout(void);
159 UInt32GetCompletionTimeout(void);
160 UInt32GetUIMScratch(UInt32 index);
161 IOByteCountGetReqCount(void);
162 IOMemoryDescriptor *GetRequestMemoryDescriptor(void);
163 IOMemoryDescriptor *GetBufferMemoryDescriptor(void);
164 boolGetMultiTransferTransaction(void);
165 boolGetFinalTransferInTransaction(void);
166 boolGetUseTimeStamp(void);
167 AbsoluteTimeGetTimeStamp(void);
168boolGetIsSyncTransfer(void);
169inline IODMACommand *GetDMACommand(void){return _expansionData->_dmaCommand; }
170inline IOUSBCommand *GetBufferUSBCommand(void){return _expansionData->_bufferUSBCommand; }
171};
172
173
174class IOUSBIsocCommand : public IOCommand
175{
176 OSDeclareAbstractStructors(IOUSBIsocCommand)
177
178protected:
179 usbCommand_selector;
180 USBDeviceAddress_address;
181 UInt8_endpoint;
182 UInt8_direction;
183 IOMemoryDescriptor *_buffer;
184 IOUSBIsocCompletion_completion;
185 UInt64_startFrame;
186 UInt32_numFrames;
187 IOUSBIsocFrame *_frameList;
188 IOReturn_status;
189
190 struct ExpansionData
191 {
192 UInt32_updateFrequency;
193 bool_useTimeStamp;
194 AbsoluteTime_timeStamp;
195bool_isSyncTransfer;// Returns true if the command is used for a synchronous transfer
196bool_rosettaClient;
197IODMACommand *_dmaCommand;
198IOUSBIsocCompletion_uslCompletion;
199bool_lowLatency;
200 };
201 ExpansionData * _expansionData;
202
203 // we override these OSObject method in order to allocate and release our expansion data
204 virtual bool init();
205 virtual void free();
206
207public:
208 // static constructor
209 static IOUSBIsocCommand *NewCommand(void);
210
211 // Manipulators
212 voidSetSelector(usbCommand sel){_selector = sel; }
213 voidSetAddress(USBDeviceAddress addr){_address = addr; }
214 voidSetEndpoint(UInt8 ep){_endpoint = ep; }
215 voidSetDirection(UInt8 dir){_direction = dir; }
216 voidSetBuffer(IOMemoryDescriptor *buf){_buffer = buf; }
217 voidSetCompletion(IOUSBIsocCompletion completion){_completion = completion; }
218 voidSetStartFrame(UInt64 sf){_startFrame = sf; }
219 voidSetNumFrames(UInt32 nf){_numFrames = nf; }
220 voidSetFrameList(IOUSBIsocFrame *fl){_frameList = fl; }
221 voidSetStatus(IOReturn stat){_status = stat; }
222 voidSetUpdateFrequency( UInt32 fr){ _expansionData->_updateFrequency = fr; }
223 voidSetUseTimeStamp(bool useIt){ _expansionData->_useTimeStamp= useIt; }
224 voidSetTimeStamp(AbsoluteTime timeStamp){ _expansionData->_timeStamp= timeStamp; }
225 voidSetIsSyncTransfer(bool isSync){ _expansionData->_isSyncTransfer = isSync; }
226 voidSetRosettaClient(bool isRosetta){ _expansionData->_rosettaClient = isRosetta; }
227 voidSetDMACommand(IODMACommand *dmaCommand){ _expansionData->_dmaCommand = dmaCommand; }
228 voidSetUSLCompletion(IOUSBIsocCompletion completion){ _expansionData->_uslCompletion = completion; }
229 voidSetLowLatency(bool lowLatency){ _expansionData->_lowLatency = lowLatency; }
230
231// Accessors
232 usbCommandGetSelector(void){ return _selector; }
233 USBDeviceAddressGetAddress(void){ return _address; }
234 UInt8GetEndpoint(void){ return _endpoint; }
235 UInt8GetDirection(void){ return _direction; }
236 IOMemoryDescriptor *GetBuffer(void){ return _buffer; }
237 IOUSBIsocCompletionGetCompletion(void){ return _completion; }
238 UInt64GetStartFrame(void){ return _startFrame; }
239 UInt32GetNumFrames(void){ return _numFrames; }
240 IOUSBIsocFrame *GetFrameList(void){ return _frameList; }
241 UInt32GetUpdateFrequency(void){ return _expansionData->_updateFrequency; }
242 IOReturnGetStatus(void){ return _status; }
243 boolGetUseTimeStamp(void){ return _expansionData->_useTimeStamp; }
244 AbsoluteTimeGetTimeStamp(void){ return _expansionData->_timeStamp; }
245boolGetIsSyncTransfer(void){ return _expansionData->_isSyncTransfer; }
246boolGetIsRosettaClient(void){ return _expansionData->_rosettaClient; }
247IODMACommand *GetDMACommand(void){ return _expansionData->_dmaCommand; }
248 IOUSBIsocCompletionGetUSLCompletion(void){ return _expansionData->_uslCompletion; }
249boolGetLowLatency(void){ return _expansionData->_lowLatency; }
250};
251
252class IOUSBCommandPool : public IOCommandPool
253{
254 OSDeclareDefaultStructors( IOUSBCommandPool )
255
256protected:
257 virtual IOReturn gatedReturnCommand(IOCommand * command);
258virtual IOReturn gatedGetCommand(IOCommand ** command, bool blockForCommand);
259
260public:
261 static IOCommandPool * withWorkLoop(IOWorkLoop * inWorkLoop);
262};
263
264
265#endif
266
267

Archive Download this file

Revision: 296