1 | /* $Id: VUSBInternal.h 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Virtual USB - Internal header.
|
---|
4 | *
|
---|
5 | * This subsystem implements USB devices in a host controller independent
|
---|
6 | * way. All the host controller code has to do is use VUSBHUB for its
|
---|
7 | * root hub implementation and any emulated USB device may be plugged into
|
---|
8 | * the virtual bus.
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
13 | *
|
---|
14 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
15 | * available from http://www.virtualbox.org. This file is free software;
|
---|
16 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
17 | * General Public License (GPL) as published by the Free Software
|
---|
18 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
19 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
20 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef ___VUSBInternal_h
|
---|
24 | #define ___VUSBInternal_h
|
---|
25 |
|
---|
26 | #include <VBox/cdefs.h>
|
---|
27 | #include <VBox/types.h>
|
---|
28 | #include <VBox/vusb.h>
|
---|
29 | #include <VBox/stam.h>
|
---|
30 |
|
---|
31 | RT_C_DECLS_BEGIN
|
---|
32 |
|
---|
33 |
|
---|
34 | /** @name Internal Device Operations, Structures and Constants.
|
---|
35 | * @{
|
---|
36 | */
|
---|
37 |
|
---|
38 | /** Pointer to a Virtual USB device (core). */
|
---|
39 | typedef struct VUSBDEV *PVUSBDEV;
|
---|
40 | /** Pointer to a VUSB hub device. */
|
---|
41 | typedef struct VUSBHUB *PVUSBHUB;
|
---|
42 | /** Pointer to a VUSB root hub. */
|
---|
43 | typedef struct VUSBROOTHUB *PVUSBROOTHUB;
|
---|
44 |
|
---|
45 |
|
---|
46 | /** Number of the default control endpoint */
|
---|
47 | #define VUSB_PIPE_DEFAULT 0
|
---|
48 |
|
---|
49 | /** @name Device addresses
|
---|
50 | * @{ */
|
---|
51 | #define VUSB_DEFAULT_ADDRESS 0
|
---|
52 | #define VUSB_INVALID_ADDRESS UINT8_C(0xff)
|
---|
53 | /** @} */
|
---|
54 |
|
---|
55 | /** @name Feature bits (1<<FEATURE for the u16Status bit)
|
---|
56 | * @{ */
|
---|
57 | #define VUSB_DEV_SELF_POWERED 0
|
---|
58 | #define VUSB_DEV_REMOTE_WAKEUP 1
|
---|
59 | #define VUSB_EP_HALT 0
|
---|
60 | /** @} */
|
---|
61 |
|
---|
62 | /** Maximum number of endpoint addresses */
|
---|
63 | #define VUSB_PIPE_MAX 16
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Control-pipe stages.
|
---|
67 | */
|
---|
68 | typedef enum CTLSTAGE
|
---|
69 | {
|
---|
70 | /** the control pipe is in the setup stage. */
|
---|
71 | CTLSTAGE_SETUP = 0,
|
---|
72 | /** the control pipe is in the data stage. */
|
---|
73 | CTLSTAGE_DATA,
|
---|
74 | /** the control pipe is in the status stage. */
|
---|
75 | CTLSTAGE_STATUS
|
---|
76 | } CTLSTAGE;
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Extra data for a control pipe.
|
---|
80 | *
|
---|
81 | * This is state information needed for the special multi-stage
|
---|
82 | * transfers performed on this kind of pipes.
|
---|
83 | */
|
---|
84 | typedef struct vusb_ctrl_extra
|
---|
85 | {
|
---|
86 | /** Current pipe stage. */
|
---|
87 | CTLSTAGE enmStage;
|
---|
88 | /** Success indicator. */
|
---|
89 | bool fOk;
|
---|
90 | /** Set if the message URB has been submitted. */
|
---|
91 | bool fSubmitted;
|
---|
92 | /** Pointer to the SETUP.
|
---|
93 | * This is a pointer to Urb->abData[0]. */
|
---|
94 | PVUSBSETUP pMsg;
|
---|
95 | /** Current DATA pointer.
|
---|
96 | * This starts at pMsg + 1 and is incremented at we read/write data. */
|
---|
97 | uint8_t *pbCur;
|
---|
98 | /** The amount of data left to read on IN operations.
|
---|
99 | * On OUT operations this is not used. */
|
---|
100 | uint32_t cbLeft;
|
---|
101 | /** The amount of data we can house.
|
---|
102 | * This starts at the default 8KB, and this structure will be reallocated to
|
---|
103 | * accommodate any larger request (unlikely). */
|
---|
104 | uint32_t cbMax;
|
---|
105 | /** The message URB. */
|
---|
106 | VUSBURB Urb;
|
---|
107 | } VUSBCTRLEXTRA, *PVUSBCTRLEXTRA;
|
---|
108 |
|
---|
109 | void vusbMsgFreeExtraData(PVUSBCTRLEXTRA pExtra);
|
---|
110 | void vusbMsgResetExtraData(PVUSBCTRLEXTRA pExtra);
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * A VUSB pipe
|
---|
115 | */
|
---|
116 | typedef struct vusb_pipe
|
---|
117 | {
|
---|
118 | PCVUSBDESCENDPOINTEX in;
|
---|
119 | PCVUSBDESCENDPOINTEX out;
|
---|
120 | /** Pointer to the extra state data required to run a control pipe. */
|
---|
121 | PVUSBCTRLEXTRA pCtrl;
|
---|
122 | /** Count of active async transfers. */
|
---|
123 | uint8_t async;
|
---|
124 | /** The periodic read-ahead buffer thread. */
|
---|
125 | RTTHREAD ReadAheadThread;
|
---|
126 | /** Pointer to the reset thread arguments. */
|
---|
127 | void *pvReadAheadArgs;
|
---|
128 | /** Pointer to the first buffered URB. */
|
---|
129 | PVUSBURB pBuffUrbHead;
|
---|
130 | /** Pointer to the last buffered URB. */
|
---|
131 | PVUSBURB pBuffUrbTail;
|
---|
132 | /** Count of URBs in read-ahead buffer. */
|
---|
133 | uint32_t cBuffered;
|
---|
134 | /** Count of URBs submitted for read-ahead but not yet reaped. */
|
---|
135 | uint32_t cSubmitted;
|
---|
136 | } VUSBPIPE;
|
---|
137 | /** Pointer to a VUSB pipe structure. */
|
---|
138 | typedef VUSBPIPE *PVUSBPIPE;
|
---|
139 |
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Interface state and possible settings.
|
---|
143 | */
|
---|
144 | typedef struct vusb_interface_state
|
---|
145 | {
|
---|
146 | /** Pointer to the interface descriptor of the currently selected (active)
|
---|
147 | * interface. */
|
---|
148 | PCVUSBDESCINTERFACEEX pCurIfDesc;
|
---|
149 | /** Pointer to the interface settings. */
|
---|
150 | PCVUSBINTERFACE pIf;
|
---|
151 | } VUSBINTERFACESTATE;
|
---|
152 | /** Pointer to interface state. */
|
---|
153 | typedef VUSBINTERFACESTATE *PVUSBINTERFACESTATE;
|
---|
154 | /** Pointer to const interface state. */
|
---|
155 | typedef const VUSBINTERFACESTATE *PCVUSBINTERFACESTATE;
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * A Virtual USB device (core).
|
---|
160 | *
|
---|
161 | * @implements VUSBIDEVICE
|
---|
162 | */
|
---|
163 | typedef struct VUSBDEV
|
---|
164 | {
|
---|
165 | /** The device interface exposed to the HCI. */
|
---|
166 | VUSBIDEVICE IDevice;
|
---|
167 | /** Pointer to the PDM USB device instance. */
|
---|
168 | PPDMUSBINS pUsbIns;
|
---|
169 | /** Next device in the chain maintained by the roothub. */
|
---|
170 | PVUSBDEV pNext;
|
---|
171 | /** Pointer to the next device with the same address hash. */
|
---|
172 | PVUSBDEV pNextHash;
|
---|
173 | /** Pointer to the hub this device is attached to. */
|
---|
174 | PVUSBHUB pHub;
|
---|
175 | /** The device state.
|
---|
176 | * Only EMT changes this value. */
|
---|
177 | VUSBDEVICESTATE volatile enmState;
|
---|
178 |
|
---|
179 | /** The device address. */
|
---|
180 | uint8_t u8Address;
|
---|
181 | /** The new device address. */
|
---|
182 | uint8_t u8NewAddress;
|
---|
183 | /** The port. */
|
---|
184 | int16_t i16Port;
|
---|
185 | /** Device status. (VUSB_DEV_SELF_POWERED or not.) */
|
---|
186 | uint16_t u16Status;
|
---|
187 |
|
---|
188 | /** Pointer to the descriptor cache.
|
---|
189 | * (Provided by the device thru the pfnGetDescriptorCache method.) */
|
---|
190 | PCPDMUSBDESCCACHE pDescCache;
|
---|
191 | /** Current configuration. */
|
---|
192 | PCVUSBDESCCONFIGEX pCurCfgDesc;
|
---|
193 |
|
---|
194 | /** Current interface state (including alternate interface setting) - maximum
|
---|
195 | * valid index is config->bNumInterfaces
|
---|
196 | */
|
---|
197 | PVUSBINTERFACESTATE paIfStates;
|
---|
198 |
|
---|
199 | /** Pipe/direction -> endpoint descriptor mapping */
|
---|
200 | VUSBPIPE aPipes[VUSB_PIPE_MAX];
|
---|
201 |
|
---|
202 | /** Dumper state. */
|
---|
203 | union VUSBDEVURBDUMPERSTATE
|
---|
204 | {
|
---|
205 | /** The current scsi command. */
|
---|
206 | uint8_t u8ScsiCmd;
|
---|
207 | } Urb;
|
---|
208 |
|
---|
209 | /** The reset thread. */
|
---|
210 | RTTHREAD hResetThread;
|
---|
211 | /** Pointer to the reset thread arguments. */
|
---|
212 | void *pvResetArgs;
|
---|
213 | } VUSBDEV;
|
---|
214 |
|
---|
215 |
|
---|
216 |
|
---|
217 | /** Pointer to the virtual method table for a kind of USB devices. */
|
---|
218 | typedef struct vusb_dev_ops *PVUSBDEVOPS;
|
---|
219 |
|
---|
220 | /** Pointer to the const virtual method table for a kind of USB devices. */
|
---|
221 | typedef const struct vusb_dev_ops *PCVUSBDEVOPS;
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * Virtual method table for USB devices - these are the functions you need to
|
---|
225 | * implement when writing a new device (or hub)
|
---|
226 | *
|
---|
227 | * Note that when creating your structure, you are required to zero the
|
---|
228 | * vusb_dev fields (ie. use calloc).
|
---|
229 | */
|
---|
230 | typedef struct vusb_dev_ops
|
---|
231 | {
|
---|
232 | /* mandatory */
|
---|
233 | const char *name;
|
---|
234 | } VUSBDEVOPS;
|
---|
235 |
|
---|
236 |
|
---|
237 | int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns);
|
---|
238 | int vusbDevCreateOld(const char *pszDeviceName, void *pvDriverInit, PCRTUUID pUuid, PVUSBDEV *ppDev);
|
---|
239 | void vusbDevDestroy(PVUSBDEV pDev);
|
---|
240 |
|
---|
241 | DECLINLINE(bool) vusbDevIsRh(PVUSBDEV pDev)
|
---|
242 | {
|
---|
243 | return (pDev->pHub == (PVUSBHUB)pDev);
|
---|
244 | }
|
---|
245 |
|
---|
246 | bool vusbDevDoSelectConfig(PVUSBDEV dev, PCVUSBDESCCONFIGEX pCfg);
|
---|
247 | void vusbDevMapEndpoint(PVUSBDEV dev, PCVUSBDESCENDPOINTEX ep);
|
---|
248 | int vusbDevDetach(PVUSBDEV pDev);
|
---|
249 | DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev);
|
---|
250 | size_t vusbDevMaxInterfaces(PVUSBDEV dev);
|
---|
251 |
|
---|
252 | DECLCALLBACK(int) vusbDevReset(PVUSBIDEVICE pDevice, bool fResetOnLinux, PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM);
|
---|
253 | DECLCALLBACK(int) vusbDevPowerOn(PVUSBIDEVICE pInterface);
|
---|
254 | DECLCALLBACK(int) vusbDevPowerOff(PVUSBIDEVICE pInterface);
|
---|
255 | DECLCALLBACK(VUSBDEVICESTATE) vusbDevGetState(PVUSBIDEVICE pInterface);
|
---|
256 | void vusbDevSetAddress(PVUSBDEV pDev, uint8_t u8Address);
|
---|
257 | bool vusbDevStandardRequest(PVUSBDEV pDev, int EndPt, PVUSBSETUP pSetup, void *pvBuf, uint32_t *pcbBuf);
|
---|
258 |
|
---|
259 |
|
---|
260 | /** @} */
|
---|
261 |
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|
265 |
|
---|
266 | /** @name Internal Hub Operations, Structures and Constants.
|
---|
267 | * @{
|
---|
268 | */
|
---|
269 |
|
---|
270 |
|
---|
271 | /** Virtual method table for USB hub devices.
|
---|
272 | * Hub and roothub drivers need to implement these functions in addition to the
|
---|
273 | * vusb_dev_ops.
|
---|
274 | */
|
---|
275 | typedef struct VUSBHUBOPS
|
---|
276 | {
|
---|
277 | int (*pfnAttach)(PVUSBHUB pHub, PVUSBDEV pDev);
|
---|
278 | void (*pfnDetach)(PVUSBHUB pHub, PVUSBDEV pDev);
|
---|
279 | } VUSBHUBOPS;
|
---|
280 | /** Pointer to a const HUB method table. */
|
---|
281 | typedef const VUSBHUBOPS *PCVUSBHUBOPS;
|
---|
282 |
|
---|
283 | /** A VUSB Hub Device - Hub and roothub drivers need to use this struct
|
---|
284 | * @todo eliminate this (PDM / roothubs only).
|
---|
285 | */
|
---|
286 | typedef struct VUSBHUB
|
---|
287 | {
|
---|
288 | VUSBDEV Dev;
|
---|
289 | PCVUSBHUBOPS pOps;
|
---|
290 | PVUSBROOTHUB pRootHub;
|
---|
291 | uint16_t cPorts;
|
---|
292 | uint16_t cDevices;
|
---|
293 | /** Name of the hub. Used for logging. */
|
---|
294 | char *pszName;
|
---|
295 | } VUSBHUB;
|
---|
296 |
|
---|
297 | /** @} */
|
---|
298 |
|
---|
299 |
|
---|
300 | /** @name Internal Root Hub Operations, Structures and Constants.
|
---|
301 | * @{
|
---|
302 | */
|
---|
303 |
|
---|
304 | /**
|
---|
305 | * Per transfer type statistics.
|
---|
306 | */
|
---|
307 | typedef struct VUSBROOTHUBTYPESTATS
|
---|
308 | {
|
---|
309 | STAMCOUNTER StatUrbsSubmitted;
|
---|
310 | STAMCOUNTER StatUrbsFailed;
|
---|
311 | STAMCOUNTER StatUrbsCancelled;
|
---|
312 |
|
---|
313 | STAMCOUNTER StatReqBytes;
|
---|
314 | STAMCOUNTER StatReqReadBytes;
|
---|
315 | STAMCOUNTER StatReqWriteBytes;
|
---|
316 |
|
---|
317 | STAMCOUNTER StatActBytes;
|
---|
318 | STAMCOUNTER StatActReadBytes;
|
---|
319 | STAMCOUNTER StatActWriteBytes;
|
---|
320 | } VUSBROOTHUBTYPESTATS, *PVUSBROOTHUBTYPESTATS;
|
---|
321 |
|
---|
322 |
|
---|
323 |
|
---|
324 | /** The address hash table size. */
|
---|
325 | #define VUSB_ADDR_HASHSZ 5
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * The instance data of a root hub driver.
|
---|
329 | *
|
---|
330 | * This extends the generic VUSB hub.
|
---|
331 | *
|
---|
332 | * @implements VUSBIROOTHUBCONNECTOR
|
---|
333 | */
|
---|
334 | typedef struct VUSBROOTHUB
|
---|
335 | {
|
---|
336 | /** The HUB.
|
---|
337 | * @todo remove this? */
|
---|
338 | VUSBHUB Hub;
|
---|
339 | /** Address hash table. */
|
---|
340 | PVUSBDEV apAddrHash[VUSB_ADDR_HASHSZ];
|
---|
341 | /** List of async URBs. */
|
---|
342 | PVUSBURB pAsyncUrbHead;
|
---|
343 | /** The default address. */
|
---|
344 | PVUSBDEV pDefaultAddress;
|
---|
345 |
|
---|
346 | /** Pointer to the driver instance. */
|
---|
347 | PPDMDRVINS pDrvIns;
|
---|
348 | /** Pointer to the root hub port interface we're attached to. */
|
---|
349 | PVUSBIROOTHUBPORT pIRhPort;
|
---|
350 | /** Connector interface exposed upwards. */
|
---|
351 | VUSBIROOTHUBCONNECTOR IRhConnector;
|
---|
352 |
|
---|
353 | /** Chain of devices attached to this hub. */
|
---|
354 | PVUSBDEV pDevices;
|
---|
355 | /** Availability Bitmap. */
|
---|
356 | VUSBPORTBITMAP Bitmap;
|
---|
357 |
|
---|
358 | /** Critical section protecting the free list. */
|
---|
359 | RTCRITSECT CritSect;
|
---|
360 | /** Chain of free URBs. (Singly linked) */
|
---|
361 | PVUSBURB pFreeUrbs;
|
---|
362 | /** The number of URBs in the pool. */
|
---|
363 | uint32_t cUrbsInPool;
|
---|
364 | /** Version of the attached Host Controller. */
|
---|
365 | uint32_t fHcVersions;
|
---|
366 | #ifdef VBOX_WITH_STATISTICS
|
---|
367 | VUSBROOTHUBTYPESTATS Total;
|
---|
368 | VUSBROOTHUBTYPESTATS aTypes[VUSBXFERTYPE_MSG];
|
---|
369 | STAMCOUNTER StatIsocReqPkts;
|
---|
370 | STAMCOUNTER StatIsocReqReadPkts;
|
---|
371 | STAMCOUNTER StatIsocReqWritePkts;
|
---|
372 | STAMCOUNTER StatIsocActPkts;
|
---|
373 | STAMCOUNTER StatIsocActReadPkts;
|
---|
374 | STAMCOUNTER StatIsocActWritePkts;
|
---|
375 | struct
|
---|
376 | {
|
---|
377 | STAMCOUNTER Pkts;
|
---|
378 | STAMCOUNTER Ok;
|
---|
379 | STAMCOUNTER Ok0;
|
---|
380 | STAMCOUNTER DataUnderrun;
|
---|
381 | STAMCOUNTER DataUnderrun0;
|
---|
382 | STAMCOUNTER DataOverrun;
|
---|
383 | STAMCOUNTER NotAccessed;
|
---|
384 | STAMCOUNTER Misc;
|
---|
385 | STAMCOUNTER Bytes;
|
---|
386 | } aStatIsocDetails[8];
|
---|
387 |
|
---|
388 | STAMPROFILE StatReapAsyncUrbs;
|
---|
389 | STAMPROFILE StatSubmitUrb;
|
---|
390 | #endif
|
---|
391 | } VUSBROOTHUB;
|
---|
392 |
|
---|
393 | /** Converts a pointer to VUSBROOTHUB::IRhConnector to a PVUSBROOTHUB. */
|
---|
394 | #define VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface) (PVUSBROOTHUB)( (uintptr_t)(pInterface) - RT_OFFSETOF(VUSBROOTHUB, IRhConnector) )
|
---|
395 |
|
---|
396 |
|
---|
397 | /* @} */
|
---|
398 |
|
---|
399 |
|
---|
400 |
|
---|
401 | /** @name Internal URB Operations, Structures and Constants.
|
---|
402 | * @{ */
|
---|
403 | int vusbUrbSubmit(PVUSBURB pUrb);
|
---|
404 | void vusbUrbTrace(PVUSBURB pUrb, const char *pszMsg, bool fComplete);
|
---|
405 | void vusbUrbDoReapAsync(PVUSBURB pHead, RTMSINTERVAL cMillies);
|
---|
406 | void vusbUrbCancel(PVUSBURB pUrb);
|
---|
407 | void vusbUrbRipe(PVUSBURB pUrb);
|
---|
408 | void vusbUrbCompletionRh(PVUSBURB pUrb);
|
---|
409 |
|
---|
410 | void vusbUrbCompletionReadAhead(PVUSBURB pUrb);
|
---|
411 | void vusbReadAheadStart(PVUSBDEV pDev, PVUSBPIPE pPipe);
|
---|
412 | void vusbReadAheadStop(void *pvReadAheadArgs);
|
---|
413 | int vusbUrbQueueAsyncRh(PVUSBURB pUrb);
|
---|
414 | int vusbUrbSubmitBufferedRead(PVUSBURB pUrb, PVUSBPIPE pPipe);
|
---|
415 | PVUSBURB vusbRhNewUrb(PVUSBROOTHUB pRh, uint8_t DstAddress, uint32_t cbData, uint32_t cTds);
|
---|
416 |
|
---|
417 |
|
---|
418 | DECLINLINE(void) vusbUrbUnlink(PVUSBURB pUrb)
|
---|
419 | {
|
---|
420 | *pUrb->VUsb.ppPrev = pUrb->VUsb.pNext;
|
---|
421 | if (pUrb->VUsb.pNext)
|
---|
422 | pUrb->VUsb.pNext->VUsb.ppPrev = pUrb->VUsb.ppPrev;
|
---|
423 | pUrb->VUsb.pNext = NULL;
|
---|
424 | pUrb->VUsb.ppPrev = NULL;
|
---|
425 | }
|
---|
426 |
|
---|
427 | /** @def vusbUrbAssert
|
---|
428 | * Asserts that a URB is valid.
|
---|
429 | */
|
---|
430 | #ifdef VBOX_STRICT
|
---|
431 | # define vusbUrbAssert(pUrb) do { \
|
---|
432 | AssertMsg(VALID_PTR((pUrb)), ("%p\n", (pUrb))); \
|
---|
433 | AssertMsg((pUrb)->u32Magic == VUSBURB_MAGIC, ("%#x", (pUrb)->u32Magic)); \
|
---|
434 | AssertMsg((pUrb)->enmState > VUSBURBSTATE_INVALID && (pUrb)->enmState < VUSBURBSTATE_END, \
|
---|
435 | ("%d\n", (pUrb)->enmState)); \
|
---|
436 | } while (0)
|
---|
437 | #else
|
---|
438 | # define vusbUrbAssert(pUrb) do {} while (0)
|
---|
439 | #endif
|
---|
440 |
|
---|
441 | /** @} */
|
---|
442 |
|
---|
443 |
|
---|
444 |
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * Addresses are between 0 and 127 inclusive
|
---|
448 | */
|
---|
449 | DECLINLINE(uint8_t) vusbHashAddress(uint8_t Address)
|
---|
450 | {
|
---|
451 | uint8_t u8Hash = Address;
|
---|
452 | u8Hash ^= (Address >> 2);
|
---|
453 | u8Hash ^= (Address >> 3);
|
---|
454 | u8Hash %= VUSB_ADDR_HASHSZ;
|
---|
455 | return u8Hash;
|
---|
456 | }
|
---|
457 |
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Gets the roothub of a device.
|
---|
461 | *
|
---|
462 | * @returns Pointer to the roothub instance the device is attached to.
|
---|
463 | * @returns NULL if not attached to any hub.
|
---|
464 | * @param pDev Pointer to the device in question.
|
---|
465 | */
|
---|
466 | DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev)
|
---|
467 | {
|
---|
468 | if (!pDev->pHub)
|
---|
469 | return NULL;
|
---|
470 | return pDev->pHub->pRootHub;
|
---|
471 | }
|
---|
472 |
|
---|
473 |
|
---|
474 |
|
---|
475 | /** Strings for the CTLSTAGE enum values. */
|
---|
476 | extern const char * const g_apszCtlStates[4];
|
---|
477 | /** Default message pipe. */
|
---|
478 | extern const VUSBDESCENDPOINTEX g_Endpoint0;
|
---|
479 | /** Default configuration. */
|
---|
480 | extern const VUSBDESCCONFIGEX g_Config0;
|
---|
481 |
|
---|
482 | RT_C_DECLS_END
|
---|
483 | #endif
|
---|
484 |
|
---|