4f26703036db522b0c661deafa0a157bc0e41932
[reactos.git] / reactos / sdk / include / reactos / drivers / usbport / usbmport.h
1 #ifndef USBMPORT_H__
2 #define USBMPORT_H__
3
4 #define USBPORT_HCI_MN 0x10000001
5
6 /* Tranfer types */
7 #define USBPORT_TRANSFER_TYPE_ISOCHRONOUS 0
8 #define USBPORT_TRANSFER_TYPE_CONTROL 1
9 #define USBPORT_TRANSFER_TYPE_BULK 2
10 #define USBPORT_TRANSFER_TYPE_INTERRUPT 3
11
12 /* Endpoint states */
13 #define USBPORT_ENDPOINT_UNKNOWN 0
14 #define USBPORT_ENDPOINT_PAUSED 2
15 #define USBPORT_ENDPOINT_ACTIVE 3
16 #define USBPORT_ENDPOINT_REMOVE 4
17 #define USBPORT_ENDPOINT_CLOSED 5
18
19 /* Endpoint status */
20 #define USBPORT_ENDPOINT_RUN 0
21 #define USBPORT_ENDPOINT_HALT 1
22 #define USBPORT_ENDPOINT_CONTROL 4
23
24 /* Interrupt Endpoint Poll Interval */
25 #define ENDPOINT_INTERRUPT_1ms 1
26 #define ENDPOINT_INTERRUPT_2ms 2
27 #define ENDPOINT_INTERRUPT_4ms 4
28 #define ENDPOINT_INTERRUPT_8ms 8
29 #define ENDPOINT_INTERRUPT_16ms 16
30 #define ENDPOINT_INTERRUPT_32ms 32
31
32 #define INTERRUPT_ENDPOINTs (ENDPOINT_INTERRUPT_32ms + \
33 ENDPOINT_INTERRUPT_16ms + \
34 ENDPOINT_INTERRUPT_8ms + \
35 ENDPOINT_INTERRUPT_4ms + \
36 ENDPOINT_INTERRUPT_2ms + \
37 ENDPOINT_INTERRUPT_1ms)
38
39 /* Types of resources. For USBPORT_RESOURCES::ResourcesTypes */
40 #define USBPORT_RESOURCES_PORT 1
41 #define USBPORT_RESOURCES_INTERRUPT 2
42 #define USBPORT_RESOURCES_MEMORY 4
43
44 typedef struct _USBPORT_RESOURCES {
45 ULONG ResourcesTypes;
46 ULONG HcFlavor;
47 ULONG InterruptVector;
48 KIRQL InterruptLevel;
49 UCHAR Padded1[3];
50 KAFFINITY InterruptAffinity;
51 BOOLEAN ShareVector;
52 UCHAR Padded2[3];
53 KINTERRUPT_MODE InterruptMode;
54 ULONG Reserved;
55 PVOID ResourceBase;
56 SIZE_T IoSpaceLength;
57 PVOID StartVA;
58 PVOID StartPA;
59 UCHAR LegacySupport;
60 BOOLEAN IsChirpHandled;
61 UCHAR Reserved2;
62 UCHAR Reserved3;
63 } USBPORT_RESOURCES, *PUSBPORT_RESOURCES;
64
65 C_ASSERT(sizeof(USBPORT_RESOURCES) == 52);
66
67 typedef ULONG MPSTATUS; // Miniport status
68 typedef ULONG RHSTATUS; // Roothub status
69
70 #define MP_STATUS_SUCCESS 0
71 #define MP_STATUS_FAILURE 1
72 #define MP_STATUS_NO_RESOURCES 2
73 #define MP_STATUS_NO_BANDWIDTH 3
74 #define MP_STATUS_ERROR 4
75 #define MP_STATUS_RESERVED1 5
76 #define MP_STATUS_NOT_SUPPORTED 6
77 #define MP_STATUS_HW_ERROR 7
78 #define MP_STATUS_UNSUCCESSFUL 8
79
80 #define RH_STATUS_SUCCESS 0
81 #define RH_STATUS_NO_CHANGES 1
82 #define RH_STATUS_UNSUCCESSFUL 2
83
84 /* Additional USB Class Codes from USB.org */
85 #define USBC_DEVICE_CLASS_TYPE_C_BRIDGE 0x12
86
87 /* Miniport functions */
88 typedef MPSTATUS
89 (NTAPI *PHCI_OPEN_ENDPOINT)(
90 PVOID,
91 PVOID,
92 PVOID);
93
94 typedef MPSTATUS
95 (NTAPI *PHCI_REOPEN_ENDPOINT)(
96 PVOID,
97 PVOID,
98 PVOID);
99
100 typedef VOID
101 (NTAPI *PHCI_QUERY_ENDPOINT_REQUIREMENTS)(
102 PVOID,
103 PVOID,
104 PULONG);
105
106 typedef VOID
107 (NTAPI *PHCI_CLOSE_ENDPOINT)(
108 PVOID,
109 PVOID,
110 BOOLEAN);
111
112 typedef MPSTATUS
113 (NTAPI *PHCI_START_CONTROLLER)(
114 PVOID,
115 PUSBPORT_RESOURCES);
116
117 typedef VOID
118 (NTAPI *PHCI_STOP_CONTROLLER)(
119 PVOID,
120 BOOLEAN);
121
122 typedef VOID
123 (NTAPI *PHCI_SUSPEND_CONTROLLER)(PVOID);
124
125 typedef MPSTATUS
126 (NTAPI *PHCI_RESUME_CONTROLLER)(PVOID);
127
128 typedef BOOLEAN
129 (NTAPI *PHCI_INTERRUPT_SERVICE)(PVOID);
130
131 typedef VOID
132 (NTAPI *PHCI_INTERRUPT_DPC)(
133 PVOID,
134 BOOLEAN);
135
136 typedef MPSTATUS
137 (NTAPI *PHCI_SUBMIT_TRANSFER)(
138 PVOID,
139 PVOID,
140 PVOID,
141 PVOID,
142 PVOID);
143
144 typedef MPSTATUS
145 (NTAPI *PHCI_SUBMIT_ISO_TRANSFER)(
146 PVOID,
147 PVOID,
148 PVOID,
149 PVOID,
150 PVOID);
151
152 typedef VOID
153 (NTAPI *PHCI_ABORT_TRANSFER)(
154 PVOID,
155 PVOID,
156 PVOID,
157 PULONG);
158
159 typedef ULONG
160 (NTAPI *PHCI_GET_ENDPOINT_STATE)(
161 PVOID,
162 PVOID);
163
164 typedef VOID
165 (NTAPI *PHCI_SET_ENDPOINT_STATE)(
166 PVOID,
167 PVOID,
168 ULONG);
169
170 typedef VOID
171 (NTAPI *PHCI_POLL_ENDPOINT)(
172 PVOID,
173 PVOID);
174
175 typedef VOID
176 (NTAPI *PHCI_CHECK_CONTROLLER)(PVOID);
177
178 typedef ULONG
179 (NTAPI *PHCI_GET_32BIT_FRAME_NUMBER)(PVOID);
180
181 typedef VOID
182 (NTAPI *PHCI_INTERRUPT_NEXT_SOF)(PVOID);
183
184 typedef VOID
185 (NTAPI *PHCI_ENABLE_INTERRUPTS)(PVOID);
186
187 typedef VOID
188 (NTAPI *PHCI_DISABLE_INTERRUPTS)(PVOID);
189
190 typedef VOID
191 (NTAPI *PHCI_POLL_CONTROLLER)(PVOID);
192
193 typedef VOID
194 (NTAPI *PHCI_SET_ENDPOINT_DATA_TOGGLE)(
195 PVOID,
196 PVOID,
197 ULONG);
198
199 typedef ULONG
200 (NTAPI *PHCI_GET_ENDPOINT_STATUS)(
201 PVOID,
202 PVOID);
203
204 typedef VOID
205 (NTAPI *PHCI_SET_ENDPOINT_STATUS)(
206 PVOID,
207 PVOID,
208 ULONG);
209
210 typedef VOID
211 (NTAPI *PHCI_RESET_CONTROLLER)(PVOID);
212
213 /* Roothub functions */
214 typedef VOID
215 (NTAPI *PHCI_RH_GET_ROOT_HUB_DATA)(
216 PVOID,
217 PVOID);
218
219 typedef MPSTATUS
220 (NTAPI *PHCI_RH_GET_STATUS)(
221 PVOID,
222 PUSHORT);
223
224 typedef MPSTATUS
225 (NTAPI *PHCI_RH_GET_PORT_STATUS)(
226 PVOID,
227 USHORT,
228 PUSB_PORT_STATUS_AND_CHANGE);
229
230 typedef MPSTATUS
231 (NTAPI *PHCI_RH_GET_HUB_STATUS)(
232 PVOID,
233 PUSB_HUB_STATUS_AND_CHANGE);
234
235 typedef MPSTATUS
236 (NTAPI *PHCI_RH_SET_FEATURE_PORT_RESET)(
237 PVOID,
238 USHORT);
239
240 typedef MPSTATUS
241 (NTAPI *PHCI_RH_SET_FEATURE_PORT_POWER)(
242 PVOID,
243 USHORT);
244
245 typedef MPSTATUS
246 (NTAPI *PHCI_RH_SET_FEATURE_PORT_ENABLE)(
247 PVOID,
248 USHORT);
249
250 typedef MPSTATUS
251 (NTAPI *PHCI_RH_SET_FEATURE_PORT_SUSPEND)(
252 PVOID,
253 USHORT);
254
255 typedef MPSTATUS
256 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_ENABLE)(
257 PVOID,
258 USHORT);
259
260 typedef MPSTATUS
261 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_POWER)(
262 PVOID,
263 USHORT);
264
265 typedef MPSTATUS
266 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_SUSPEND)(
267 PVOID,
268 USHORT);
269
270 typedef MPSTATUS
271 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_ENABLE_CHANGE)(
272 PVOID,
273 USHORT);
274
275 typedef MPSTATUS
276 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_CONNECT_CHANGE)(
277 PVOID,
278 USHORT);
279
280 typedef MPSTATUS
281 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_RESET_CHANGE)(
282 PVOID,
283 USHORT);
284
285 typedef MPSTATUS
286 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_SUSPEND_CHANGE)(
287 PVOID,
288 USHORT);
289
290 typedef MPSTATUS
291 (NTAPI *PHCI_RH_CLEAR_FEATURE_PORT_OVERCURRENT_CHANGE)(
292 PVOID,
293 USHORT);
294
295 typedef VOID
296 (NTAPI *PHCI_RH_DISABLE_IRQ)(PVOID);
297
298 typedef VOID
299 (NTAPI *PHCI_RH_ENABLE_IRQ)(PVOID);
300
301 /* Miniport ioctl functions */
302 typedef MPSTATUS
303 (NTAPI *PHCI_START_SEND_ONE_PACKET)(
304 PVOID,
305 PVOID,
306 PVOID,
307 PULONG,
308 PVOID,
309 PVOID,
310 ULONG,
311 USBD_STATUS *);
312
313 typedef MPSTATUS
314 (NTAPI *PHCI_END_SEND_ONE_PACKET)(
315 PVOID,
316 PVOID,
317 PVOID,
318 PULONG,
319 PVOID,
320 PVOID,
321 ULONG,
322 USBD_STATUS *);
323
324 typedef MPSTATUS
325 (NTAPI *PHCI_PASS_THRU)(
326 PVOID,
327 PVOID,
328 ULONG,
329 PVOID);
330
331 /* Port functions */
332 typedef ULONG
333 (NTAPI *PUSBPORT_DBG_PRINT)(
334 PVOID,
335 ULONG,
336 PCH,
337 ...);
338
339 typedef ULONG
340 (NTAPI *PUSBPORT_TEST_DEBUG_BREAK)(PVOID);
341
342 typedef ULONG
343 (NTAPI *PUSBPORT_ASSERT_FAILURE)(
344 PVOID,
345 PVOID,
346 PVOID,
347 ULONG,
348 PCHAR);
349
350 typedef MPSTATUS
351 (NTAPI *PUSBPORT_GET_MINIPORT_REGISTRY_KEY_VALUE)(
352 PVOID,
353 BOOL,
354 PCWSTR,
355 SIZE_T,
356 PVOID,
357 SIZE_T);
358
359 typedef ULONG
360 (NTAPI *PUSBPORT_INVALIDATE_ROOT_HUB)(PVOID);
361
362 typedef ULONG
363 (NTAPI *PUSBPORT_INVALIDATE_ENDPOINT)(
364 PVOID,
365 PVOID);
366
367 typedef ULONG
368 (NTAPI *PUSBPORT_COMPLETE_TRANSFER)(
369 PVOID,
370 PVOID,
371 PVOID,
372 USBD_STATUS,
373 SIZE_T);
374
375 typedef ULONG
376 (NTAPI *PUSBPORT_COMPLETE_ISO_TRANSFER)(
377 PVOID,
378 PVOID,
379 PVOID,
380 ULONG);
381
382 typedef ULONG
383 (NTAPI *PUSBPORT_LOG_ENTRY)(
384 PVOID,
385 ULONG,
386 ULONG,
387 ULONG,
388 ULONG,
389 ULONG);
390
391 typedef PVOID
392 (NTAPI *PUSBPORT_GET_MAPPED_VIRTUAL_ADDRESS)(
393 PVOID,
394 PVOID,
395 PVOID);
396
397 typedef VOID
398 (NTAPI ASYNC_TIMER_CALLBACK)(
399 IN PVOID MiniportExtension,
400 IN PVOID CallBackContext);
401
402 typedef ULONG
403 (NTAPI *PUSBPORT_REQUEST_ASYNC_CALLBACK)(
404 PVOID,
405 ULONG,
406 PVOID,
407 SIZE_T,
408 ASYNC_TIMER_CALLBACK *);
409
410 typedef MPSTATUS
411 (NTAPI *PUSBPORT_READ_WRITE_CONFIG_SPACE)(
412 PVOID,
413 BOOLEAN,
414 PVOID,
415 ULONG,
416 ULONG);
417
418 typedef NTSTATUS
419 (NTAPI *PUSBPORT_WAIT)(
420 PVOID,
421 ULONG);
422
423 #define USBPORT_INVALIDATE_CONTROLLER_RESET 1
424 #define USBPORT_INVALIDATE_CONTROLLER_SURPRISE_REMOVE 2
425 #define USBPORT_INVALIDATE_CONTROLLER_SOFT_INTERRUPT 3
426
427 typedef ULONG
428 (NTAPI *PUSBPORT_INVALIDATE_CONTROLLER)(
429 PVOID,
430 ULONG);
431
432 typedef VOID
433 (NTAPI *PUSBPORT_BUG_CHECK)(PVOID);
434
435 typedef ULONG
436 (NTAPI *PUSBPORT_NOTIFY_DOUBLE_BUFFER)(
437 PVOID,
438 PVOID,
439 PVOID,
440 SIZE_T);
441
442 /* Miniport functions */
443 typedef VOID
444 (NTAPI *PHCI_REBALANCE_ENDPOINT)(
445 PVOID,
446 PVOID,
447 PVOID);
448
449 typedef VOID
450 (NTAPI *PHCI_FLUSH_INTERRUPTS)(PVOID);
451
452 typedef MPSTATUS
453 (NTAPI *PHCI_RH_CHIRP_ROOT_PORT)(
454 PVOID,
455 USHORT);
456
457 typedef VOID
458 (NTAPI *PHCI_TAKE_PORT_CONTROL)(PVOID);
459
460 #define USB_MINIPORT_VERSION_OHCI 0x01
461 #define USB_MINIPORT_VERSION_UHCI 0x02
462 #define USB_MINIPORT_VERSION_EHCI 0x03
463 #define USB_MINIPORT_VERSION_XHCI 0x04
464
465 #define USB_MINIPORT_FLAGS_INTERRUPT 0x0001
466 #define USB_MINIPORT_FLAGS_PORT_IO 0x0002
467 #define USB_MINIPORT_FLAGS_MEMORY_IO 0x0004
468 #define USB_MINIPORT_FLAGS_USB2 0x0010
469 #define USB_MINIPORT_FLAGS_DISABLE_SS 0x0020
470 #define USB_MINIPORT_FLAGS_NOT_LOCK_INT 0x0040
471 #define USB_MINIPORT_FLAGS_POLLING 0x0080
472 #define USB_MINIPORT_FLAGS_NO_DMA 0x0100
473 #define USB_MINIPORT_FLAGS_WAKE_SUPPORT 0x0200
474
475 #define TOTAL_USB11_BUS_BANDWIDTH 12000
476 #define TOTAL_USB20_BUS_BANDWIDTH 400000
477
478 typedef struct _USBPORT_REGISTRATION_PACKET {
479 ULONG MiniPortVersion;
480 ULONG MiniPortFlags;
481 ULONG MiniPortBusBandwidth;
482 ULONG Reserved1;
483 SIZE_T MiniPortExtensionSize;
484 SIZE_T MiniPortEndpointSize;
485 SIZE_T MiniPortTransferSize;
486 ULONG Reserved2;
487 ULONG Reserved3;
488 SIZE_T MiniPortResourcesSize;
489
490 /* Miniport */
491 PHCI_OPEN_ENDPOINT OpenEndpoint;
492 PHCI_REOPEN_ENDPOINT ReopenEndpoint;
493 PHCI_QUERY_ENDPOINT_REQUIREMENTS QueryEndpointRequirements;
494 PHCI_CLOSE_ENDPOINT CloseEndpoint;
495 PHCI_START_CONTROLLER StartController;
496 PHCI_STOP_CONTROLLER StopController;
497 PHCI_SUSPEND_CONTROLLER SuspendController;
498 PHCI_RESUME_CONTROLLER ResumeController;
499 PHCI_INTERRUPT_SERVICE InterruptService;
500 PHCI_INTERRUPT_DPC InterruptDpc;
501 PHCI_SUBMIT_TRANSFER SubmitTransfer;
502 PHCI_SUBMIT_ISO_TRANSFER SubmitIsoTransfer;
503 PHCI_ABORT_TRANSFER AbortTransfer;
504 PHCI_GET_ENDPOINT_STATE GetEndpointState;
505 PHCI_SET_ENDPOINT_STATE SetEndpointState;
506 PHCI_POLL_ENDPOINT PollEndpoint;
507 PHCI_CHECK_CONTROLLER CheckController;
508 PHCI_GET_32BIT_FRAME_NUMBER Get32BitFrameNumber;
509 PHCI_INTERRUPT_NEXT_SOF InterruptNextSOF;
510 PHCI_ENABLE_INTERRUPTS EnableInterrupts;
511 PHCI_DISABLE_INTERRUPTS DisableInterrupts;
512 PHCI_POLL_CONTROLLER PollController;
513 PHCI_SET_ENDPOINT_DATA_TOGGLE SetEndpointDataToggle;
514 PHCI_GET_ENDPOINT_STATUS GetEndpointStatus;
515 PHCI_SET_ENDPOINT_STATUS SetEndpointStatus;
516 PHCI_RESET_CONTROLLER ResetController;
517
518 /* Roothub */
519 PHCI_RH_GET_ROOT_HUB_DATA RH_GetRootHubData;
520 PHCI_RH_GET_STATUS RH_GetStatus;
521 PHCI_RH_GET_PORT_STATUS RH_GetPortStatus;
522 PHCI_RH_GET_HUB_STATUS RH_GetHubStatus;
523 PHCI_RH_SET_FEATURE_PORT_RESET RH_SetFeaturePortReset;
524 PHCI_RH_SET_FEATURE_PORT_POWER RH_SetFeaturePortPower;
525 PHCI_RH_SET_FEATURE_PORT_ENABLE RH_SetFeaturePortEnable;
526 PHCI_RH_SET_FEATURE_PORT_SUSPEND RH_SetFeaturePortSuspend;
527 PHCI_RH_CLEAR_FEATURE_PORT_ENABLE RH_ClearFeaturePortEnable;
528 PHCI_RH_CLEAR_FEATURE_PORT_POWER RH_ClearFeaturePortPower;
529 PHCI_RH_CLEAR_FEATURE_PORT_SUSPEND RH_ClearFeaturePortSuspend;
530 PHCI_RH_CLEAR_FEATURE_PORT_ENABLE_CHANGE RH_ClearFeaturePortEnableChange;
531 PHCI_RH_CLEAR_FEATURE_PORT_CONNECT_CHANGE RH_ClearFeaturePortConnectChange;
532 PHCI_RH_CLEAR_FEATURE_PORT_RESET_CHANGE RH_ClearFeaturePortResetChange;
533 PHCI_RH_CLEAR_FEATURE_PORT_SUSPEND_CHANGE RH_ClearFeaturePortSuspendChange;
534 PHCI_RH_CLEAR_FEATURE_PORT_OVERCURRENT_CHANGE RH_ClearFeaturePortOvercurrentChange;
535 PHCI_RH_DISABLE_IRQ RH_DisableIrq;
536 PHCI_RH_ENABLE_IRQ RH_EnableIrq;
537
538 /* Miniport ioctl */
539 PHCI_START_SEND_ONE_PACKET StartSendOnePacket;
540 PHCI_END_SEND_ONE_PACKET EndSendOnePacket;
541 PHCI_PASS_THRU PassThru;
542
543 /* Port */
544 PUSBPORT_DBG_PRINT UsbPortDbgPrint;
545 PUSBPORT_TEST_DEBUG_BREAK UsbPortTestDebugBreak;
546 PUSBPORT_ASSERT_FAILURE UsbPortAssertFailure;
547 PUSBPORT_GET_MINIPORT_REGISTRY_KEY_VALUE UsbPortGetMiniportRegistryKeyValue;
548 PUSBPORT_INVALIDATE_ROOT_HUB UsbPortInvalidateRootHub;
549 PUSBPORT_INVALIDATE_ENDPOINT UsbPortInvalidateEndpoint;
550 PUSBPORT_COMPLETE_TRANSFER UsbPortCompleteTransfer;
551 PUSBPORT_COMPLETE_ISO_TRANSFER UsbPortCompleteIsoTransfer;
552 PUSBPORT_LOG_ENTRY UsbPortLogEntry;
553 PUSBPORT_GET_MAPPED_VIRTUAL_ADDRESS UsbPortGetMappedVirtualAddress;
554 PUSBPORT_REQUEST_ASYNC_CALLBACK UsbPortRequestAsyncCallback;
555 PUSBPORT_READ_WRITE_CONFIG_SPACE UsbPortReadWriteConfigSpace;
556 PUSBPORT_WAIT UsbPortWait;
557 PUSBPORT_INVALIDATE_CONTROLLER UsbPortInvalidateController;
558 PUSBPORT_BUG_CHECK UsbPortBugCheck;
559 PUSBPORT_NOTIFY_DOUBLE_BUFFER UsbPortNotifyDoubleBuffer;
560
561 /* Miniport */
562 PHCI_REBALANCE_ENDPOINT RebalanceEndpoint;
563 PHCI_FLUSH_INTERRUPTS FlushInterrupts;
564 PHCI_RH_CHIRP_ROOT_PORT RH_ChirpRootPort;
565 PHCI_TAKE_PORT_CONTROL TakePortControl;
566 ULONG Reserved4;
567 ULONG Reserved5;
568 } USBPORT_REGISTRATION_PACKET, *PUSBPORT_REGISTRATION_PACKET;
569
570 #define USB10_MINIPORT_INTERFACE_VERSION 100
571 #define USB20_MINIPORT_INTERFACE_VERSION 200
572
573 typedef struct _USBPORT_MINIPORT_INTERFACE {
574 PDRIVER_OBJECT DriverObject;
575 LIST_ENTRY DriverLink;
576 PDRIVER_UNLOAD DriverUnload;
577 ULONG Version;
578 USBPORT_REGISTRATION_PACKET Packet;
579 } USBPORT_MINIPORT_INTERFACE, *PUSBPORT_MINIPORT_INTERFACE;
580
581 C_ASSERT(sizeof(USBPORT_MINIPORT_INTERFACE) == 336);
582
583 #define USBPORT_TRANSFER_DIRECTION_OUT 1 // From host to device
584 typedef struct _USBPORT_ENDPOINT_PROPERTIES {
585 USHORT DeviceAddress;
586 USHORT EndpointAddress;
587 USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
588 UCHAR Period;
589 UCHAR Reserved1;
590 USB_DEVICE_SPEED DeviceSpeed;
591 ULONG UsbBandwidth;
592 ULONG ScheduleOffset;
593 ULONG TransferType;
594 ULONG Direction;
595 ULONG_PTR BufferVA;
596 ULONG_PTR BufferPA;
597 ULONG BufferLength;
598 ULONG Reserved3;
599 ULONG MaxTransferSize;
600 USHORT HubAddr;
601 USHORT PortNumber;
602 UCHAR InterruptScheduleMask;
603 UCHAR SplitCompletionMask;
604 UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 1 to 3)
605 UCHAR Reserved4;
606 ULONG MaxPacketSize;
607 ULONG Reserved6;
608 } USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
609
610 C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 64);
611
612 typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
613 PHYSICAL_ADDRESS SgPhysicalAddress;
614 ULONG Reserved1;
615 ULONG SgTransferLength;
616 ULONG SgOffset;
617 ULONG Reserved2;
618 } USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
619
620 C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
621
622 typedef struct _USBPORT_SCATTER_GATHER_LIST {
623 ULONG Flags;
624 ULONG_PTR CurrentVa;
625 PVOID MappedSystemVa;
626 ULONG SgElementCount;
627 USBPORT_SCATTER_GATHER_ELEMENT SgElement[1];
628 } USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
629
630 C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 40);
631
632 typedef struct _USBPORT_TRANSFER_PARAMETERS {
633 ULONG TransferFlags;
634 ULONG TransferBufferLength;
635 ULONG TransferCounter;
636 ULONG Reserved1;
637 ULONG Reserved2;
638 USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
639 } USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
640
641 C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
642
643 /* For USB1.1 or USB3 Hub Descriptors */
644 typedef union _USBPORT_HUB_11_CHARACTERISTICS {
645 struct {
646 USHORT PowerControlMode :1;
647 USHORT NoPowerSwitching :1; // Reserved. Used only on 1.0 compliant hubs that implement no power switching.
648 USHORT PartOfCompoundDevice :1;
649 USHORT OverCurrentProtectionMode :1;
650 USHORT NoOverCurrentProtection :1;
651 USHORT Reserved1 :11;
652 };
653 USHORT AsUSHORT;
654 } USBPORT_HUB_11_CHARACTERISTICS;
655
656 C_ASSERT(sizeof(USBPORT_HUB_11_CHARACTERISTICS) == sizeof(USHORT));
657
658 /* For USB2.0 Hub Descriptors */
659 typedef union _USBPORT_HUB_20_CHARACTERISTICS {
660 struct {
661 USHORT PowerControlMode :1;
662 USHORT NoPowerSwitching :1; // Reserved. Used only on 1.0 compliant hubs that implement no power switching.
663 USHORT PartOfCompoundDevice :1;
664 USHORT OverCurrentProtectionMode :1;
665 USHORT NoOverCurrentProtection :1;
666 USHORT TtThinkTime :2;
667 USHORT PortIndicatorsSupported :1;
668 USHORT Reserved1 :8;
669 };
670 USHORT AsUSHORT;
671 } USBPORT_HUB_20_CHARACTERISTICS;
672
673 C_ASSERT(sizeof(USBPORT_HUB_20_CHARACTERISTICS) == sizeof(USHORT));
674
675 typedef USBPORT_HUB_11_CHARACTERISTICS USBPORT_HUB_30_CHARACTERISTICS;
676
677 typedef union _USBPORT_HUB_CHARACTERISTICS {
678 USHORT AsUSHORT;
679 USBPORT_HUB_11_CHARACTERISTICS Usb11HubCharacteristics;
680 USBPORT_HUB_20_CHARACTERISTICS Usb20HubCharacteristics;
681 USBPORT_HUB_30_CHARACTERISTICS Usb30HubCharacteristics;
682 } USBPORT_HUB_CHARACTERISTICS;
683
684 C_ASSERT(sizeof(USBPORT_HUB_CHARACTERISTICS) == sizeof(USHORT));
685
686 typedef struct _USBPORT_ROOT_HUB_DATA {
687 ULONG NumberOfPorts;
688 USBPORT_HUB_CHARACTERISTICS HubCharacteristics;
689 USHORT Padded1;
690 ULONG PowerOnToPowerGood;
691 ULONG HubControlCurrent;
692 } USBPORT_ROOT_HUB_DATA, *PUSBPORT_ROOT_HUB_DATA;
693
694 C_ASSERT(sizeof(USBPORT_ROOT_HUB_DATA) == 16);
695
696 ULONG
697 NTAPI
698 USBPORT_GetHciMn(VOID);
699
700 NTSTATUS
701 NTAPI
702 USBPORT_RegisterUSBPortDriver(
703 IN PDRIVER_OBJECT DriverObject,
704 IN ULONG Version,
705 IN PUSBPORT_REGISTRATION_PACKET RegistrationPacket);
706
707 #endif /* USBMPORT_H__ */