Root/
Source at commit 2351 created 10 years 5 months ago. By ifabio, more info from dmi tables | |
---|---|
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 | ␊ |
44 | typedef 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␊ |
51 | ␉DEVICE_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 | */␊ |
60 | class IOUSBCommand : public IOCommand␊ |
61 | {␊ |
62 | OSDeclareAbstractStructors(IOUSBCommand)␊ |
63 | ␊ |
64 | protected:␊ |
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;␊ |
88 | ␉␉IOMemoryDescriptor *_requestMemoryDescriptor;␊ |
89 | ␉␉IOMemoryDescriptor *_bufferMemoryDescriptor;␊ |
90 | ␉␉bool␉␉␉␉_multiTransferTransaction;␊ |
91 | ␉␉bool␉␉␉␉_finalTransferInTransaction;␊ |
92 | bool␉␉␉␉_useTimeStamp;␊ |
93 | AbsoluteTime␉␉_timeStamp;␊ |
94 | ␉␉bool␉␉␉␉_isSyncTransfer;␉␉␉␉␉␉// Returns true if the command is used for a synchronous transfer␊ |
95 | ␉␉IODMACommand␉␉*_dmaCommand;␉␉␉␉␉␉␉// used to get memory mapping␊ |
96 | ␉␉IOUSBCommand␉␉*_bufferUSBCommand;␉␉␉␉␉␉// points to another IOUSBCommand used for phase 2 of control transactions␊ |
97 | ␉␉IOUSBCommand␉␉*_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 | ␊ |
105 | public:␊ |
106 | ␊ |
107 | // static constructor␊ |
108 | static IOUSBCommand *␉NewCommand(void);␊ |
109 | ␊ |
110 | // Manipulators␊ |
111 | void␉␉␉␉␉SetSelector(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 | void␉␉␉␉␉SetRequestMemoryDescriptor(IOMemoryDescriptor *requestMemoryDescriptor);␊ |
132 | void␉␉␉␉␉SetBufferMemoryDescriptor(IOMemoryDescriptor *bufferMemoryDescriptor);␊ |
133 | void␉␉␉␉␉SetMultiTransferTransaction(bool);␊ |
134 | void␉␉␉␉␉SetFinalTransferInTransaction(bool);␊ |
135 | void␉␉␉␉␉SetUseTimeStamp(bool);␊ |
136 | void␉␉␉␉␉SetTimeStamp(AbsoluteTime timeStamp);␊ |
137 | ␉void␉␉␉␉␉SetIsSyncTransfer(bool);␊ |
138 | ␉inline void␉␉␉␉SetDMACommand(IODMACommand *dmaCommand)␉␉␉␉␉{ _expansionData->_dmaCommand = dmaCommand; }␊ |
139 | ␉void␉␉␉␉␉SetBufferUSBCommand(IOUSBCommand *bufferUSBCommand);␊ |
140 | ␉␊ |
141 | ␉// Accessors␊ |
142 | usbCommand␉␉␉␉␉GetSelector(void);␊ |
143 | IOUSBDeviceRequestPtr␉␉GetRequest(void);␊ |
144 | USBDeviceAddress␉␉␉GetAddress(void);␊ |
145 | UInt8␉␉␉␉␉␉GetEndpoint(void);␊ |
146 | UInt8␉␉␉␉␉␉GetDirection(void);␊ |
147 | UInt8␉␉␉␉␉␉GetType(void);␊ |
148 | bool␉␉␉␉␉␉GetBufferRounding(void);␊ |
149 | IOMemoryDescriptor *␉␉GetBuffer(void);␊ |
150 | IOUSBCompletion␉␉␉␉GetUSLCompletion(void);␊ |
151 | IOUSBCompletion␉␉␉␉GetClientCompletion(void);␊ |
152 | UInt32␉␉␉␉␉␉GetDataRemaining(void);␊ |
153 | UInt8␉␉␉␉␉␉GetStage(void);␊ |
154 | IOReturn␉␉␉␉␉GetStatus(void);␊ |
155 | IOMemoryDescriptor *␉␉GetOrigBuffer(void);␊ |
156 | IOUSBCompletion␉␉␉␉GetDisjointCompletion(void);␊ |
157 | IOByteCount␉␉␉␉␉GetDblBufLength(void);␊ |
158 | UInt32␉␉␉␉␉␉GetNoDataTimeout(void);␊ |
159 | UInt32␉␉␉␉␉␉GetCompletionTimeout(void);␊ |
160 | UInt32␉␉␉␉␉␉GetUIMScratch(UInt32 index);␊ |
161 | IOByteCount␉␉␉␉␉GetReqCount(void);␊ |
162 | IOMemoryDescriptor *␉␉GetRequestMemoryDescriptor(void);␊ |
163 | IOMemoryDescriptor *␉␉GetBufferMemoryDescriptor(void);␊ |
164 | bool␉␉␉␉␉␉GetMultiTransferTransaction(void);␊ |
165 | bool␉␉␉␉␉␉GetFinalTransferInTransaction(void);␊ |
166 | bool␉␉␉␉␉␉GetUseTimeStamp(void);␊ |
167 | AbsoluteTime␉␉␉␉GetTimeStamp(void);␊ |
168 | ␉bool␉␉␉␉␉␉GetIsSyncTransfer(void);␊ |
169 | ␉inline IODMACommand *␉␉GetDMACommand(void)␉␉␉␉␉␉␉{return _expansionData->_dmaCommand; }␊ |
170 | ␉inline IOUSBCommand *␉␉GetBufferUSBCommand(void)␉␉␉␉␉{return _expansionData->_bufferUSBCommand; }␊ |
171 | };␊ |
172 | ␊ |
173 | ␊ |
174 | class IOUSBIsocCommand : public IOCommand␊ |
175 | {␊ |
176 | OSDeclareAbstractStructors(IOUSBIsocCommand)␊ |
177 | ␊ |
178 | protected:␊ |
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;␊ |
195 | ␉␉bool␉␉␉␉_isSyncTransfer;␉␉␉␉␉␉␉␉// Returns true if the command is used for a synchronous transfer␊ |
196 | ␉␉bool␉␉␉␉_rosettaClient;␊ |
197 | ␉␉IODMACommand *␉␉_dmaCommand;␊ |
198 | ␉␉IOUSBIsocCompletion␉_uslCompletion;␊ |
199 | ␉␉bool␉␉␉␉_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 | ␊ |
207 | public:␊ |
208 | // static constructor␊ |
209 | static IOUSBIsocCommand *NewCommand(void);␊ |
210 | ␊ |
211 | // Manipulators␊ |
212 | void␉␉␉␉␉SetSelector(usbCommand sel)␉␉␉␉␉␉␉{_selector = sel; }␊ |
213 | void␉␉␉␉␉SetAddress(USBDeviceAddress addr)␉␉␉␉␉{_address = addr; }␊ |
214 | void␉␉␉␉␉SetEndpoint(UInt8 ep)␉␉␉␉␉␉␉␉{_endpoint = ep; }␊ |
215 | void␉␉␉␉␉SetDirection(UInt8 dir)␉␉␉␉␉␉␉␉{_direction = dir; }␊ |
216 | void␉␉␉␉␉SetBuffer(IOMemoryDescriptor *buf)␉␉␉␉␉{_buffer = buf; }␊ |
217 | void␉␉␉␉␉SetCompletion(IOUSBIsocCompletion completion)␉␉{_completion = completion; }␊ |
218 | void␉␉␉␉␉SetStartFrame(UInt64 sf)␉␉␉␉␉␉␉{_startFrame = sf; }␊ |
219 | void␉␉␉␉␉SetNumFrames(UInt32 nf)␉␉␉␉␉␉␉␉{_numFrames = nf; }␊ |
220 | void␉␉␉␉␉SetFrameList(IOUSBIsocFrame *fl)␉␉␉␉␉{_frameList = fl; }␊ |
221 | void␉␉␉␉␉SetStatus(IOReturn stat)␉␉␉␉␉␉␉{_status = stat; }␊ |
222 | void␉␉␉␉␉SetUpdateFrequency( UInt32 fr)␉␉␉␉␉␉{ _expansionData->_updateFrequency = fr; }␊ |
223 | void␉␉␉␉␉SetUseTimeStamp(bool useIt)␉␉␉␉␉␉␉{ _expansionData->_useTimeStamp= useIt; }␊ |
224 | void␉␉␉␉␉SetTimeStamp(AbsoluteTime timeStamp)␉␉␉␉{ _expansionData->_timeStamp= timeStamp; }␊ |
225 | ␉void␉␉␉␉␉SetIsSyncTransfer(bool isSync)␉␉␉␉␉␉{ _expansionData->_isSyncTransfer = isSync; }␊ |
226 | ␉void␉␉␉␉␉SetRosettaClient(bool isRosetta)␉␉␉␉␉{ _expansionData->_rosettaClient = isRosetta; }␊ |
227 | ␉void␉␉␉␉␉SetDMACommand(IODMACommand *dmaCommand)␉␉␉␉{ _expansionData->_dmaCommand = dmaCommand; }␊ |
228 | void␉␉␉␉␉SetUSLCompletion(IOUSBIsocCompletion completion)␉{ _expansionData->_uslCompletion = completion; }␊ |
229 | ␉void␉␉␉␉␉SetLowLatency(bool lowLatency)␉␉␉␉␉␉{ _expansionData->_lowLatency = lowLatency; }␊ |
230 | ␊ |
231 | ␉// Accessors␊ |
232 | usbCommand␉␉␉␉GetSelector(void)␉␉␉␉␉␉␉␉{ return _selector; }␊ |
233 | USBDeviceAddress␉␉GetAddress(void)␉␉␉␉␉␉␉␉{ return _address; }␊ |
234 | UInt8␉␉␉␉␉GetEndpoint(void)␉␉␉␉␉␉␉␉{ return _endpoint; }␊ |
235 | UInt8␉␉␉␉␉GetDirection(void)␉␉␉␉␉␉␉␉{ return _direction; }␊ |
236 | IOMemoryDescriptor *␉GetBuffer(void)␉␉␉␉␉␉␉␉␉{ return _buffer; }␊ |
237 | IOUSBIsocCompletion␉␉GetCompletion(void)␉␉␉␉␉␉␉␉{ return _completion; }␊ |
238 | UInt64␉␉␉␉␉GetStartFrame(void)␉␉␉␉␉␉␉␉{ return _startFrame; }␊ |
239 | UInt32␉␉␉␉␉GetNumFrames(void)␉␉␉␉␉␉␉␉{ return _numFrames; }␊ |
240 | IOUSBIsocFrame *␉␉GetFrameList(void)␉␉␉␉␉␉␉␉{ return _frameList; }␊ |
241 | UInt32␉␉␉␉␉GetUpdateFrequency(void)␉␉␉␉␉␉{ return _expansionData->_updateFrequency; }␊ |
242 | IOReturn␉␉␉␉GetStatus(void)␉␉␉␉␉␉␉␉␉{ return _status; }␊ |
243 | bool␉␉␉␉␉GetUseTimeStamp(void)␉␉␉␉␉␉␉{ return _expansionData->_useTimeStamp; }␊ |
244 | AbsoluteTime␉␉␉GetTimeStamp(void)␉␉␉␉␉␉␉␉{ return _expansionData->_timeStamp; }␊ |
245 | ␉bool␉␉␉␉␉GetIsSyncTransfer(void)␉␉␉␉␉␉␉{ return _expansionData->_isSyncTransfer; }␊ |
246 | ␉bool␉␉␉␉␉GetIsRosettaClient(void)␉␉␉␉␉␉{ return _expansionData->_rosettaClient; }␊ |
247 | ␉IODMACommand *␉␉␉GetDMACommand(void)␉␉␉␉␉␉␉␉{ return _expansionData->_dmaCommand; }␊ |
248 | IOUSBIsocCompletion␉␉GetUSLCompletion(void)␉␉␉␉␉␉␉{ return _expansionData->_uslCompletion; }␊ |
249 | ␉bool␉␉␉␉␉GetLowLatency(void)␉␉␉␉␉␉␉␉{ return _expansionData->_lowLatency; }␊ |
250 | };␊ |
251 | ␊ |
252 | class IOUSBCommandPool : public IOCommandPool␊ |
253 | {␊ |
254 | OSDeclareDefaultStructors( IOUSBCommandPool )␊ |
255 | ␉␊ |
256 | protected:␊ |
257 | virtual IOReturn gatedReturnCommand(IOCommand * command);␊ |
258 | ␉virtual IOReturn gatedGetCommand(IOCommand ** command, bool blockForCommand);␊ |
259 | ␉␊ |
260 | public:␊ |
261 | static IOCommandPool * withWorkLoop(IOWorkLoop * inWorkLoop);␊ |
262 | };␊ |
263 | ␊ |
264 | ␊ |
265 | #endif␊ |
266 | ␊ |
267 |