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