ReactOS 0.4.17-dev-1281-g065abb3
mmio.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS xHCI Host Controller Driver
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Register block mapping, capability parsing and halt/reset/run
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#include "xhcidrv.h"
9
10#define NDEBUG
11#include <debug.h>
12
13/* Vendor registers touched by errata and internal fixes */
14#define XHCI_VENDOR_ETRON_FIRMWARE 0x4000
15#define XHCI_VENDOR_ETRON_CONTROL 0x4074
16#define XHCI_VENDOR_TI_FIRMWARE 0xC120
17#define XHCI_VENDOR_FRESCO_CONTROL 0x8090
18#define XHCI_VENDOR_PPT_BULK 0x8094
19#define XHCI_VENDOR_FRESCO_SHADOW 0x80DC
20#define XHCI_VENDOR_PME 0x80A4
21#define XHCI_VENDOR_SSIC_PORT 0x883C
22#define XHCI_SSIC_PROG_DONE 0x40000000
23#define XHCI_SSIC_PROG_UNUSED 0x80000000
24#define XHCI_VENDOR_SAVED_BIT 0x02000000
25
26static const ULONG XhciVendorBitRegisters[] = { 0x8904, 0x8A14, 0x8B24 };
27
28/* Timing limits */
29#define XHCI_HANDOFF_WAITS 20
30#define XHCI_HANDOFF_WAIT_MS 100
31#define XHCI_CNR_WAITS 100
32#define XHCI_CNR_WAIT_MS 100
33#define XHCI_HALT_WAITS 16
34#define XHCI_RESET_WAITS 100
35#define XHCI_RESET_MAX_STEP_MS 16
36#define XHCI_RESET_SLOW_MS 50
37#define XHCI_RUN_STALLS 50
38#define XHCI_RUN_STALL_US 100
39#define XHCI_RUN_WAITS 7
40#define XHCI_RUN_WAIT_MS 5
41#define XHCI_STATE_WAITS 20
42
43static
44VOID
47 _In_ ULONG Milliseconds)
48{
50
52}
53
54/* Mapping ********************************************************************/
55
58 _In_ WDFCMRESLIST Translated)
59{
61 ULONG Count = WdfCmResourceListGetCount(Translated);
63
64 for (Index = 0; Index < Count; Index++)
65 {
66 Descriptor = WdfCmResourceListGetDescriptor(Translated, Index);
68 continue;
69
70 /* Only the first memory range is the register BAR */
71 m_Base = (PUCHAR)MmMapIoSpace(Descriptor->u.Memory.Start,
72 Descriptor->u.Memory.Length,
74 if (m_Base == NULL)
75 {
76 DPRINT1("Mapping %lu register bytes at 0x%I64x failed\n",
77 Descriptor->u.Memory.Length, Descriptor->u.Memory.Start.QuadPart);
79 }
80
81 m_Length = Descriptor->u.Memory.Length;
82 m_Mapped = TRUE;
83 return STATUS_SUCCESS;
84 }
85
86 /* QUIRK: a missing memory resource reports STATUS_UNSUCCESSFUL */
87 DPRINT1("No memory resource for the register BAR\n");
89}
90
94 _In_ WDFCMRESLIST Translated)
95{
97
99
100 Status = MapRegisters(Translated);
101 if (!NT_SUCCESS(Status))
102 return Status;
103
105 if (!NT_SUCCESS(Status))
106 {
107 DPRINT1("Capability registers rejected 0x%lx\n", Status);
108 return Status;
109 }
110
112 if (!NT_SUCCESS(Status))
113 {
114 DPRINT1("BIOS handoff failed 0x%lx\n", Status);
115 return Status;
116 }
117
119 if (!NT_SUCCESS(Status))
120 DPRINT1("Initial controller reset failed 0x%lx\n", Status);
121
122 return Status;
123}
124
125VOID
127{
128 if (m_Mapped)
129 {
131 m_Mapped = FALSE;
132 }
133
134 m_Base = NULL;
135 m_Length = 0;
137 m_Runtime = NULL;
139 m_ExtendedList = 0;
140 m_LegacySupport = 0;
142}
143
144/* Capability parsing *********************************************************/
145
146VOID
148{
150 BOOLEAN Qualcomm;
151
152 if (Id->FirmwareVersion != XHCI_FIRMWARE_UNKNOWN)
153 return;
154
155 Qualcomm = (Id->ParentBus == UcxControllerParentBusTypeAcpi &&
156 _strnicmp(Id->AcpiVendorId, "QCOM", 4) == 0);
157
158 if (Id->PciVendorId == 0x1B6F)
159 {
162 }
163 else if (Id->PciVendorId == 0x104C || Qualcomm)
164 {
166 Id->FirmwareVersion = ReadCapability32(XHCI_VENDOR_TI_FIRMWARE) & 0xFFFF;
167 }
168}
169
172{
173 ULONG Value;
174 ULONG Psa;
176
178
183
184 if (m_VersionMajor == 0)
185 m_Controller->SetErrata(XhciErrata::IntPrimaryOnly);
186 else if (m_VersionMinor >= 0x10 || m_VersionMajor > 1)
188
190
195 if (m_MaxSlots == 0)
196 {
197 DPRINT1("HCSPARAMS1 0x%08lx reports no device slots\n", Value);
199 }
200 if (m_MaxInterrupters == 0 || m_MaxInterrupters > 0x400)
201 {
202 DPRINT1("HCSPARAMS1 0x%08lx reports %lu interrupters\n", Value, m_MaxInterrupters);
204 }
205 if (m_MaxPorts == 0)
206 {
207 DPRINT1("HCSPARAMS1 0x%08lx reports no ports\n", Value);
209 }
210
215
218 {
219 DPRINT1("HCSPARAMS3 0x%08lx U1 exit latency out of range\n", m_Hcsparams3);
221 }
223 {
224 DPRINT1("HCSPARAMS3 0x%08lx U2 exit latency out of range\n", m_Hcsparams3);
226 }
227
230
231 /* A 4 KB stream context array holds at most 256 entries */
233 if (Psa > 7)
234 Psa = 7;
235 if (Psa == 0 || m_Controller->HasErrata(XhciErrata::StrmUnsupported))
236 m_Streams = 0;
237 else
238 m_Streams = (2UL << Psa) - 1;
239
241 if (Offset == 0 || Offset >= m_Length)
242 {
243 DPRINT1("Extended capability pointer 0x%lx outside the %lu byte BAR\n", Offset, m_Length);
245 }
249
250 /* DBOFF and RTSOFF must fall inside the mapping */
252 if (Offset == 0 || !InRange(Offset, XHCI_DOORBELL_STRIDE * (m_MaxSlots + 1)))
253 {
254 DPRINT1("Doorbell offset 0x%lx invalid for a %lu byte BAR\n", Offset, m_Length);
256 }
258
260 if (Offset == 0 ||
262 {
263 DPRINT1("Runtime offset 0x%lx invalid for a %lu byte BAR\n", Offset, m_Length);
265 }
267
269 if (Value != XHCI_PAGESIZE_4K)
270 {
271 DPRINT1("PAGESIZE 0x%lx is not 4 KB only\n", Value);
273 }
274
275 DPRINT("xHCI %x.%02x: %lu slots, %lu interrupters, %lu ports, %lu scratchpads, HCC 0x%08lx/0x%08lx\n",
278 return STATUS_SUCCESS;
279}
280
281/* Extended capabilities ******************************************************/
282
283ULONG
285 _In_ ULONG Id,
286 _In_ ULONG Start) const
287{
290 ULONG Next;
291
292 if (!m_Mapped || m_ExtendedList == 0)
293 return 0;
294
295 Offset = (Start == 0) ? m_ExtendedList : Start;
297
298 /* A given start is skipped; only entries after it are candidates */
299 if (Start == 0 && (Header & XHCI_EXTCAP_ID_MASK) == Id)
300 return Offset;
301
302 for (;;)
303 {
305 if (Next == 0)
306 return 0;
307
308 Offset += Next;
309 if (Offset >= m_Length)
310 return 0;
311
313 if ((Header & XHCI_EXTCAP_ID_MASK) == Id)
314 return Offset;
315 }
316}
317
318ULONG
320 _In_ ULONG Offset) const
321{
322 if (!InRange(Offset, sizeof(ULONG)))
323 {
324 DPRINT1("Extended capability read at 0x%lx outside the BAR\n", Offset);
325 return MAXULONG;
326 }
327
329}
330
331VOID
335{
336 if (!InRange(Offset, sizeof(ULONG)))
337 {
338 DPRINT1("Extended capability write at 0x%lx outside the BAR\n", Offset);
339 return;
340 }
341
343}
344
345/* Raw access *****************************************************************/
346
350 _In_ ULONG Size) const
351{
352 return m_Mapped && Offset < m_Length && Size <= m_Length - Offset;
353}
354
355UCHAR
357 _In_ ULONG Offset) const
358{
360}
361
362VOID
366{
368}
369
370VOID
374 _In_ ULONG Set)
375{
377
378 if (!InRange(Offset, sizeof(ULONG)))
379 return;
380
383}
384
387 _In_ PUCHAR Address) const
388{
389 ULONG Low;
390 ULONG High;
391
392#ifdef _WIN64
393 if (!m_Controller->HasErrata(XhciErrata::RegSplit64BitAccess))
394 return READ_REGISTER_ULONG64((PULONG64)Address);
395#endif
396
399 return ((ULONG64)High << 32) | Low;
400}
401
402VOID
406{
407#ifdef _WIN64
408 if (!m_Controller->HasErrata(XhciErrata::RegSplit64BitAccess))
409 {
410 WRITE_REGISTER_ULONG64((PULONG64)Address, Value);
411 return;
412 }
413#endif
414
415 /* Low dword first; CRCR, ERSTBA and ERDP latch on the high dword write */
417 WRITE_REGISTER_ULONG((PULONG)(Address + sizeof(ULONG)), (ULONG)(Value >> 32));
418}
419
420ULONG
422 _In_ ULONG Offset) const
423{
424 if (!m_Mapped)
425 return MAXULONG;
426
428}
429
430ULONG
432 _In_ ULONG Offset) const
433{
434 if (!m_Mapped)
435 return MAXULONG;
436
438}
439
440VOID
444{
445 if (m_Mapped)
447}
448
451 _In_ ULONG Offset) const
452{
453 if (!m_Mapped)
454 return ~0ULL;
455
456 return Read64(m_Operational + Offset);
457}
458
459VOID
463{
464 if (m_Mapped)
466}
467
468ULONG
470 _In_ ULONG Offset) const
471{
472 if (!m_Mapped)
473 return MAXULONG;
474
476}
477
478VOID
482{
483 if (m_Mapped)
485}
486
489 _In_ ULONG Offset) const
490{
491 if (!m_Mapped)
492 return ~0ULL;
493
494 return Read64(m_Runtime + Offset);
495}
496
497VOID
501{
502 if (m_Mapped)
504}
505
506VOID
510{
511 if (m_Mapped && Index <= m_MaxSlots)
513}
514
515ULONG
518 _In_ ULONG Offset) const
519{
520 if (!m_Mapped || Port == 0 || Port > m_MaxPorts)
521 return MAXULONG;
522
524 XHCI_OP_PORT_STRIDE * (Port - 1) + Offset));
525}
526
527VOID
532{
533 if (!m_Mapped || Port == 0 || Port > m_MaxPorts)
534 return;
535
538}
539
540/* Parsed values **************************************************************/
541
542ULONG
544{
545 return m_MaxSlots;
546}
547
548ULONG
550{
551 return m_MaxInterrupters;
552}
553
554ULONG
556{
557 return m_MaxPorts;
558}
559
560ULONG
562{
564}
565
566ULONG
568{
570}
571
572ULONG
574{
575 return m_Scratchpads;
576}
577
578ULONG
580{
581 return PAGE_SIZE;
582}
583
584ULONG
586{
587 return m_Streams;
588}
589
590ULONG
592{
593 return m_Hcsparams3;
594}
595
596ULONG
598{
599 return m_Hccparams1;
600}
601
602ULONG
604{
605 return m_Hccparams2;
606}
607
608ULONG
610{
611 return m_CapLength;
612}
613
614UCHAR
616{
617 return m_VersionMajor;
618}
619
620UCHAR
622{
623 return m_VersionMinor;
624}
625
628{
629 return m_MseLengthUsable;
630}
631
634{
635 return m_Mapped;
636}
637
638ULONG
640{
641 return m_LegacySupport;
642}
643
644ULONG
646{
647 return m_DebugCapability;
648}
649
650ULONG
652{
653 return (m_Hccparams1 & XHCI_HCC1_CSZ) ? 64 : 32;
654}
655
656USHORT
658{
659 return (USHORT)((m_VersionMajor << 8) | m_VersionMinor);
660}
661
664{
665 /* Read live, as the reference does */
667}
668
671{
672 if (m_Controller->HasErrata(XhciErrata::IsochNoFrameIdContinuity))
673 return FALSE;
674
675 return (m_Hccparams1 & XHCI_HCC1_CFC) != 0;
676}
677
678ULONG
680 _In_ ULONG Increment) const
681{
683
684 return ((Index + Increment) >> 3) & 0x7FF;
685}
686
687/* Sequences ******************************************************************/
688
691{
692 ULONG Waits;
693
695 return STATUS_SUCCESS;
696
697 for (Waits = 0; ReadOperational32(XHCI_OP_USBSTS) & XHCI_USBSTS_CNR; Waits++)
698 {
699 if (Waits == XHCI_CNR_WAITS)
700 {
701 DPRINT1("Controller Not Ready still set after %lu ms\n", XHCI_CNR_WAITS * XHCI_CNR_WAIT_MS);
702 return STATUS_UNSUCCESSFUL;
703 }
704
706 }
707
708 return STATUS_SUCCESS;
709}
710
713{
714 ULONG Waits;
716
718 return STATUS_SUCCESS;
719
720 if (m_LegacySupport != 0)
721 {
724
726 {
727 if (Waits == XHCI_HANDOFF_WAITS)
728 {
729 if (!m_Controller->HasErrata(XhciErrata::BootTolerateBiosHold))
730 {
731 DPRINT1("BIOS kept ownership of the controller\n");
732 return STATUS_UNSUCCESSFUL;
733 }
734
735 DPRINT1("BIOS kept ownership of the controller, continuing\n");
736 break;
737 }
738
740 }
741 }
742 else
743 {
744 DPRINT1("No USB legacy support capability, skipping the BIOS handoff\n");
745 }
746
748 {
749 if (m_Controller->HasErrata(XhciErrata::BootStrictBiosRelease))
750 {
751 DPRINT1("Controller still running after the BIOS handoff\n");
752 return STATUS_UNSUCCESSFUL;
753 }
754
755 Status = Stop();
756 if (!NT_SUCCESS(Status))
757 {
758 DPRINT1("Stopping the controller after the BIOS handoff failed 0x%lx\n", Status);
759 return Status;
760 }
761 }
762
763 /* Keeps the BIOS SMI handler quiet, notably on S3 resume */
764 if (m_LegacySupport != 0)
765 {
767
769 }
770
771 return STATUS_SUCCESS;
772}
773
776{
777 ULONG Waits;
778
780 return STATUS_SUCCESS;
781
783
784 /* QUIRK: each 1 ms wait lasts a full timer tick */
785 for (Waits = 0; !(ReadOperational32(XHCI_OP_USBSTS) & XHCI_USBSTS_HCH); Waits++)
786 {
787 if (Waits == XHCI_HALT_WAITS)
788 {
789 DPRINT1("Controller did not halt, USBSTS 0x%08lx\n", ReadOperational32(XHCI_OP_USBSTS));
790 return STATUS_UNSUCCESSFUL;
791 }
792
793 XhciSleepMs(1);
794 }
795
796 return STATUS_SUCCESS;
797}
798
801{
802 return ResetController(FALSE);
803}
804
807 _In_ BOOLEAN AllowRunning)
808{
809 ULONG Waits;
810 ULONG Step = 1;
811 ULONG Elapsed = 0;
813
815 return STATUS_SUCCESS;
816
818 if (!NT_SUCCESS(Status))
819 {
820 DPRINT1("Controller not ready before reset\n");
821 return Status;
822 }
823
824 if (!AllowRunning && !(ReadOperational32(XHCI_OP_USBSTS) & XHCI_USBSTS_HCH))
825 {
826 DPRINT1("Reset refused, controller not halted\n");
827 return STATUS_UNSUCCESSFUL;
828 }
829
831
833
834 /* QUIRK: Intel controllers can hang the system if a register is read within 1 ms of HCRST */
836
837 for (Waits = 0; ReadOperational32(XHCI_OP_USBCMD) & XHCI_USBCMD_HCRST; Waits++)
838 {
839 if (Waits == XHCI_RESET_WAITS)
840 {
841 DPRINT1("Host controller reset did not finish in %lu ms\n", Elapsed);
842 return STATUS_UNSUCCESSFUL;
843 }
844
845 XhciSleepMs(Step);
846 Elapsed += Step;
847 if (Step < XHCI_RESET_MAX_STEP_MS)
848 Step *= 2;
849 }
850
851 if (Elapsed > XHCI_RESET_SLOW_MS)
852 DPRINT1("Host controller reset took %lu ms, over the %u ms limit\n", Elapsed, XHCI_RESET_SLOW_MS);
853
855 if (!NT_SUCCESS(Status))
856 {
857 DPRINT1("Controller not ready after reset\n");
858 return Status;
859 }
860
862 XhciSleepMs(100);
863
864 return STATUS_SUCCESS;
865}
866
869{
871 ULONG Index;
872
874 return STATUS_SUCCESS;
875
877 {
878 DPRINT1("Start refused, controller not halted\n");
880 }
881
883
884 /* QUIRK: HSEE is left as it reads */
892
893 for (Index = 0; Index < XHCI_RUN_STALLS; Index++)
894 {
897 return STATUS_SUCCESS;
898 }
899
900 /* Then poll with 5 ms sleeps */
901 for (Index = 0; Index < XHCI_RUN_WAITS; Index++)
902 {
905 return STATUS_SUCCESS;
906 }
907
908 /* QUIRK: still halted is only reported */
909 DPRINT1("Controller still halted after start, USBSTS 0x%08lx\n", ReadOperational32(XHCI_OP_USBSTS));
910 return STATUS_SUCCESS;
911}
912
915{
917
918 if (!(Usbsts & XHCI_USBSTS_HCH))
919 {
920 DPRINT1("State save or restore refused, controller running\n");
922 }
923
924 if (Usbsts & (XHCI_USBSTS_SSS | XHCI_USBSTS_RSS))
925 {
926 DPRINT1("State save or restore already in progress, USBSTS 0x%08lx\n", Usbsts);
928 }
929
930 return STATUS_SUCCESS;
931}
932
935 _In_ ULONG BusyBit)
936{
938 ULONG Usbsts;
939 ULONG Waits = 0;
940
941 Interval.QuadPart = -2000;
942
943 for (;;)
944 {
946 if (Usbsts & XHCI_USBSTS_SRE)
947 {
948 DPRINT1("Save/Restore Error reported, USBSTS 0x%08lx\n", Usbsts);
951 }
952
953 if (!(Usbsts & BusyBit))
954 return STATUS_SUCCESS;
955
956 if (Waits == XHCI_STATE_WAITS)
957 {
958 DPRINT1("State save or restore timed out, USBSTS 0x%08lx\n", Usbsts);
960 }
961
962 Waits++;
964 }
965}
966
969{
971
973 return STATUS_SUCCESS;
974
976 if (!NT_SUCCESS(Status))
977 return Status;
978
981}
982
985{
987
989 return STATUS_SUCCESS;
990
992 if (!NT_SUCCESS(Status))
993 return Status;
994
995 /* DNCTRL is not part of the saved state and must be back before CRS */
999}
1000
1001/* Vendor sequences ***********************************************************/
1002
1003VOID
1006{
1007 if (!m_Controller->HasErrata(XhciErrata::PortParkIdleSsic))
1008 return;
1009
1011 if (PowerDown)
1013 else
1016}
1017
1018VOID
1020{
1021 ULONG Index;
1022
1023 if (!m_Controller->HasErrata(XhciErrata::PwrPreserveVendorRegs))
1024 return;
1025
1026 m_VendorBits = 0;
1028 {
1030 m_VendorBits |= 1UL << Index;
1031 }
1032}
1033
1034VOID
1036{
1037 ULONG Index;
1038
1039 if (!m_Controller->HasErrata(XhciErrata::PwrPreserveVendorRegs))
1040 return;
1041
1043 {
1044 if (m_VendorBits & (1UL << Index))
1046 else
1048 }
1049}
1050
1051VOID
1053{
1055
1059 ModifyCapability32(XHCI_VENDOR_FRESCO_SHADOW, (1UL << 1) | (1UL << 7), 0);
1060 if (m_Controller->HasErrata(XhciErrata::IntelPchAsyncOrderingFix))
1062 if (Fixes & XhciController::FixEtronSet)
1066
1067 if (m_Controller->HasErrata(XhciErrata::PwrTogglePmeEnable))
1068 {
1069 ModifyCapability32(XHCI_VENDOR_PME, 0, 1UL << 28);
1071 ModifyCapability32(XHCI_VENDOR_PME, 1UL << 28, 0);
1072 }
1073}
DWORD Id
static _Out_opt_ PULONGLONG Start
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
unsigned char BOOLEAN
Definition: actypes.h:127
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:11
#define READ_REGISTER_ULONG(r)
Definition: arm.h:10
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: Header.h:9
@ FixFrescoShadow
Definition: hc.h:105
@ FixAsmediaResetDelay
Definition: hc.h:109
@ FixEtronClear
Definition: hc.h:108
@ FixFrescoControl
Definition: hc.h:106
@ FixEtronSet
Definition: hc.h:107
BOOLEAN HasErrata(_In_ XhciErrata Bit) const
Definition: hc.h:58
XhciIdentity m_Identity
Definition: hc.h:100
ULONG64 m_InternalFlags
Definition: hc.h:111
BOOLEAN IsAccessible() const
Definition: hc.cpp:193
VOID SetErrata(_In_ XhciErrata Bit)
Definition: hc.cpp:183
NTSTATUS Stop()
Definition: mmio.cpp:775
UCHAR m_VersionMinor
Definition: mmio.h:196
ULONG ReadOperational32(_In_ ULONG Offset) const
Definition: mmio.cpp:431
ULONG m_Hccparams1
Definition: mmio.h:204
ULONG m_ExtendedList
Definition: mmio.h:190
ULONG ReadCapability32(_In_ ULONG Offset) const
Definition: mmio.cpp:421
ULONG m_VendorBits
Definition: mmio.h:209
VOID SaveVendorBits()
Definition: mmio.cpp:1019
NTSTATUS ParseCapabilities()
Definition: mmio.cpp:171
NTSTATUS RestoreState()
Definition: mmio.cpp:984
ULONG MaxSlots() const
Definition: mmio.cpp:543
BOOLEAN ContiguousFrameId() const
Definition: mmio.cpp:670
BOOLEAN Addressing64() const
Definition: mmio.cpp:663
NTSTATUS CheckStateOperationAllowed() const
Definition: mmio.cpp:914
ULONG MaxPorts() const
Definition: mmio.cpp:555
NTSTATUS Reset()
Definition: mmio.cpp:800
ULONG m_MaxInterrupters
Definition: mmio.h:199
UCHAR m_VersionMajor
Definition: mmio.h:195
UCHAR VersionMajor() const
Definition: mmio.cpp:615
ULONG DebugCapabilityOffset() const
Definition: mmio.cpp:645
NTSTATUS Run()
Definition: mmio.cpp:868
VOID Write64(_In_ PUCHAR Address, _In_ ULONG64 Value)
Definition: mmio.cpp:403
NTSTATUS ResetController(_In_ BOOLEAN AllowRunning)
Definition: mmio.cpp:806
VOID RestoreVendorBits()
Definition: mmio.cpp:1035
ULONG ReadRuntime32(_In_ ULONG Offset) const
Definition: mmio.cpp:469
NTSTATUS Prepare(_In_ XhciController *Controller, _In_ WDFCMRESLIST Translated)
Definition: mmio.cpp:92
VOID WriteRuntime64(_In_ ULONG Offset, _In_ ULONG64 Value)
Definition: mmio.cpp:498
ULONG m_Streams
Definition: mmio.h:206
ULONG ReadPort32(_In_ ULONG Port, _In_ ULONG Offset) const
Definition: mmio.cpp:516
VOID ProgramSsicPortUnused(_In_ BOOLEAN PowerDown)
Definition: mmio.cpp:1004
ULONG FindExtendedCapability(_In_ ULONG Id, _In_ ULONG Start) const
Definition: mmio.cpp:284
NTSTATUS SaveState()
Definition: mmio.cpp:968
UCHAR VersionMinor() const
Definition: mmio.cpp:621
ULONG m_LegacySupport
Definition: mmio.h:191
ULONG SupportedStreams() const
Definition: mmio.cpp:585
BOOLEAN m_MseLengthUsable
Definition: mmio.h:197
VOID Release()
Definition: mmio.cpp:126
ULONG m_Hcsparams3
Definition: mmio.h:203
ULONG LegacySupportOffset() const
Definition: mmio.cpp:639
ULONG64 Read64(_In_ PUCHAR Address) const
Definition: mmio.cpp:386
VOID WriteByte(_In_ ULONG Offset, _In_ UCHAR Value)
Definition: mmio.cpp:363
NTSTATUS WaitForStateOperation(_In_ ULONG BusyBit)
Definition: mmio.cpp:934
ULONG m_Length
Definition: mmio.h:184
ULONG m_MaxSlots
Definition: mmio.h:198
ULONG m_MaxPorts
Definition: mmio.h:200
VOID WriteExtended32(_In_ ULONG Offset, _In_ ULONG Value)
Definition: mmio.cpp:332
ULONG ScratchpadCount() const
Definition: mmio.cpp:573
USHORT InterfaceVersion() const
Definition: mmio.cpp:657
NTSTATUS WaitForReady()
Definition: mmio.cpp:690
ULONG MaxInterrupters() const
Definition: mmio.cpp:549
ULONG Hcsparams3() const
Definition: mmio.cpp:591
ULONG CurrentFrame(_In_ ULONG Increment) const
Definition: mmio.cpp:679
VOID ApplyD0Workarounds()
Definition: mmio.cpp:1052
ULONG64 ReadOperational64(_In_ ULONG Offset) const
Definition: mmio.cpp:450
UCHAR ReadByte(_In_ ULONG Offset) const
Definition: mmio.cpp:356
ULONG m_Hccparams2
Definition: mmio.h:205
ULONG EventRingSegmentTableMax() const
Definition: mmio.cpp:561
ULONG MaxEventRingSegments() const
Definition: mmio.cpp:567
ULONG Hccparams1() const
Definition: mmio.cpp:597
ULONG m_CapLength
Definition: mmio.h:194
ULONG CapLength() const
Definition: mmio.cpp:609
ULONG PageSize() const
Definition: mmio.cpp:579
NTSTATUS MapRegisters(_In_ WDFCMRESLIST Translated)
Definition: mmio.cpp:57
ULONG ReadExtended32(_In_ ULONG Offset) const
Definition: mmio.cpp:319
BOOLEAN InRange(_In_ ULONG Offset, _In_ ULONG Size) const
Definition: mmio.cpp:348
PUCHAR m_Doorbells
Definition: mmio.h:188
ULONG Hccparams2() const
Definition: mmio.cpp:603
VOID WriteOperational64(_In_ ULONG Offset, _In_ ULONG64 Value)
Definition: mmio.cpp:460
XhciController * m_Controller
Definition: mmio.h:182
VOID WriteRuntime32(_In_ ULONG Offset, _In_ ULONG Value)
Definition: mmio.cpp:479
VOID ReadFirmwareVersion()
Definition: mmio.cpp:147
VOID WritePort32(_In_ ULONG Port, _In_ ULONG Offset, _In_ ULONG Value)
Definition: mmio.cpp:528
ULONG m_MaxEventRingSegments
Definition: mmio.h:201
ULONG64 ReadRuntime64(_In_ ULONG Offset) const
Definition: mmio.cpp:488
ULONG m_DebugCapability
Definition: mmio.h:192
BOOLEAN MseLengthUsable() const
Definition: mmio.cpp:627
PUCHAR m_Runtime
Definition: mmio.h:187
BOOLEAN m_Mapped
Definition: mmio.h:185
VOID RingDoorbell(_In_ ULONG Index, _In_ ULONG Value)
Definition: mmio.cpp:507
ULONG ContextSize() const
Definition: mmio.cpp:651
VOID WriteOperational32(_In_ ULONG Offset, _In_ ULONG Value)
Definition: mmio.cpp:441
ULONG m_Scratchpads
Definition: mmio.h:202
VOID ModifyCapability32(_In_ ULONG Offset, _In_ ULONG Clear, _In_ ULONG Set)
Definition: mmio.cpp:371
BOOLEAN IsMapped() const
Definition: mmio.cpp:633
PUCHAR m_Base
Definition: mmio.h:183
PUCHAR m_Operational
Definition: mmio.h:186
NTSTATUS BiosHandoff()
Definition: mmio.cpp:712
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:46
Status
Definition: gdiplustypes.h:24
#define XHCI_FIRMWARE_UNKNOWN
Definition: hc.h:21
CPPORT Port[4]
Definition: headless.c:38
Config Register
Definition: hubwmi.cpp:126
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:192
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
#define XHCI_VENDOR_FRESCO_CONTROL
Definition: mmio.cpp:17
#define XHCI_SSIC_PROG_UNUSED
Definition: mmio.cpp:23
static VOID NTAPI XhciSleepMs(_In_ ULONG Milliseconds)
Definition: mmio.cpp:46
#define XHCI_RESET_MAX_STEP_MS
Definition: mmio.cpp:35
#define XHCI_RUN_STALL_US
Definition: mmio.cpp:38
#define XHCI_RUN_WAITS
Definition: mmio.cpp:39
#define XHCI_VENDOR_PPT_BULK
Definition: mmio.cpp:18
#define XHCI_VENDOR_ETRON_FIRMWARE
Definition: mmio.cpp:14
#define XHCI_VENDOR_ETRON_CONTROL
Definition: mmio.cpp:15
#define XHCI_CNR_WAITS
Definition: mmio.cpp:31
#define XHCI_VENDOR_TI_FIRMWARE
Definition: mmio.cpp:16
#define XHCI_VENDOR_PME
Definition: mmio.cpp:20
#define XHCI_HALT_WAITS
Definition: mmio.cpp:33
#define XHCI_RUN_STALLS
Definition: mmio.cpp:37
#define XHCI_VENDOR_SSIC_PORT
Definition: mmio.cpp:21
#define XHCI_VENDOR_SAVED_BIT
Definition: mmio.cpp:24
#define XHCI_VENDOR_FRESCO_SHADOW
Definition: mmio.cpp:19
#define XHCI_HANDOFF_WAIT_MS
Definition: mmio.cpp:30
#define XHCI_HANDOFF_WAITS
Definition: mmio.cpp:29
#define XHCI_RUN_WAIT_MS
Definition: mmio.cpp:40
#define XHCI_STATE_WAITS
Definition: mmio.cpp:41
#define XHCI_RESET_WAITS
Definition: mmio.cpp:34
#define XHCI_CNR_WAIT_MS
Definition: mmio.cpp:32
#define XHCI_SSIC_PROG_DONE
Definition: mmio.cpp:22
#define XHCI_RESET_SLOW_MS
Definition: mmio.cpp:36
static const ULONG XhciVendorBitRegisters[]
Definition: mmio.cpp:26
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned __int64 * PULONG64
Definition: imports.h:198
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
static void Clear(void)
Definition: treeview.c:388
#define ULL(a, b)
Definition: format_msg.c:27
#define KernelMode
Definition: asm.h:38
DWORD Interval
Definition: netstat.c:28
#define _In_
Definition: no_sal2.h:158
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_ADAPTER_HARDWARE_ERROR
Definition: ntstatus.h:524
static BOOL Set
Definition: pageheap.c:10
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
#define CmResourceTypeMemory
Definition: restypes.h:106
#define STATUS_SUCCESS
Definition: shellext.h:65
PACPI_METHOD_ARGUMENT Next
Definition: slotdev.cpp:96
#define DPRINT
Definition: sndvol32.h:73
@ High
Definition: strmini.h:378
@ Low
Definition: strmini.h:380
Definition: shell.h:41
#define MAXULONG
Definition: typedefs.h:251
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
@ UcxControllerParentBusTypeAcpi
Definition: ucxcontroller.h:18
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT Count
Definition: userreq.cpp:200
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
@ MmNonCached
Definition: mmtypes.h:129
#define XHCI_LEGSUP_OWNED
Definition: xhcihw.h:433
#define XHCI_EXTCAP_DEBUG
Definition: xhcihw.h:311
#define XHCI_CAP_HCSPARAMS1
Definition: xhcihw.h:336
#define XHCI_EXTCAP_ID_MASK
Definition: xhcihw.h:425
#define XHCI_HCS1_MAX_INTRS_SHIFT
Definition: xhcihw.h:350
#define XHCI_DNCTRL_FUNCTION_WAKE
Definition: xhcihw.h:415
#define XHCI_OP_PAGESIZE
Definition: xhcihw.h:383
#define XHCI_HCS2_ERST_MAX_MASK
Definition: xhcihw.h:357
#define XHCI_HCS3_U2_LATENCY_SHIFT
Definition: xhcihw.h:365
#define XHCI_HCC1_CSZ
Definition: xhcihw.h:369
#define XHCI_USBSTS_RSS
Definition: xhcihw.h:406
#define XHCI_CAP_DBOFF
Definition: xhcihw.h:340
#define XHCI_USBSTS_SRE
Definition: xhcihw.h:407
#define XHCI_LEGCTLSTS_KEEP_MASK
Definition: xhcihw.h:437
#define XHCI_HCC1_XECP_SHIFT
Definition: xhcihw.h:373
#define XHCI_HCC1_CFC
Definition: xhcihw.h:370
#define XHCI_HCIVERSION_MAJOR_SHIFT
Definition: xhcihw.h:345
#define XHCI_INTERRUPTER_STRIDE
Definition: xhcihw.h:152
#define XHCI_LEGSUP_CTLSTS
Definition: xhcihw.h:434
#define XHCI_CAP_HCSPARAMS3
Definition: xhcihw.h:338
#define XHCI_CAP_HCSPARAMS2
Definition: xhcihw.h:337
#define XHCI_HCIVERSION_MINOR_SHIFT
Definition: xhcihw.h:346
#define XHCI_USBCMD_INTE
Definition: xhcihw.h:392
#define XHCI_USBCMD_HCRST
Definition: xhcihw.h:391
#define XHCI_HCS1_MAX_PORTS_SHIFT
Definition: xhcihw.h:352
#define XHCI_LEGSUP_BIOS_OWNED_BYTE
Definition: xhcihw.h:431
#define XHCI_USBCMD_CME
Definition: xhcihw.h:397
#define XHCI_CAP_RTSOFF
Definition: xhcihw.h:341
#define XHCI_OP_DNCTRL
Definition: xhcihw.h:384
#define XHCI_CAPLENGTH_MASK
Definition: xhcihw.h:344
#define XHCI_HCC1_MAX_PSA_MASK
Definition: xhcihw.h:372
#define XHCI_USBCMD_ETE
Definition: xhcihw.h:398
#define XHCI_HCS2_SCRATCH_HI_MASK
Definition: xhcihw.h:359
#define XHCI_HCS2_ERST_MAX_SHIFT
Definition: xhcihw.h:356
#define XHCI_MFINDEX_MASK
Definition: xhcihw.h:419
#define XHCI_HCS1_MAX_SLOTS_MASK
Definition: xhcihw.h:349
#define XHCI_HCS1_MAX_INTRS_MASK
Definition: xhcihw.h:351
#define XHCI_CAP_HCCPARAMS2
Definition: xhcihw.h:342
#define XHCI_RUNTIME_INTERRUPTER_BASE
Definition: xhcihw.h:151
#define XHCI_EXTCAP_LEGACY
Definition: xhcihw.h:428
#define XHCI_USBSTS_CNR
Definition: xhcihw.h:408
#define XHCI_HCS2_SCRATCH_HI_SHIFT
Definition: xhcihw.h:358
#define XHCI_OP_PORT_STRIDE
Definition: xhcihw.h:387
#define XHCI_USBCMD_CSS
Definition: xhcihw.h:394
#define XHCI_HCC1_MAX_PSA_SHIFT
Definition: xhcihw.h:371
#define XHCI_HCC2_CMC
Definition: xhcihw.h:376
#define XHCI_OP_USBCMD
Definition: xhcihw.h:381
#define XHCI_LEGSUP_OS_OWNED_BYTE
Definition: xhcihw.h:432
#define XHCI_OP_USBSTS
Definition: xhcihw.h:382
#define XHCI_USBSTS_SSS
Definition: xhcihw.h:405
#define XHCI_EXTCAP_NEXT_MASK
Definition: xhcihw.h:427
#define XHCI_OP_PORT_BASE
Definition: xhcihw.h:386
#define XHCI_HCS2_SCRATCH_LO_SHIFT
Definition: xhcihw.h:361
#define XHCI_USBSTS_HCH
Definition: xhcihw.h:401
#define XHCI_CAP_HCCPARAMS1
Definition: xhcihw.h:339
#define XHCI_USBCMD_CRS
Definition: xhcihw.h:395
#define XHCI_DOORBELL_STRIDE
Definition: xhcihw.h:422
#define XHCI_EXTCAP_NEXT_SHIFT
Definition: xhcihw.h:426
#define XHCI_RT_MFINDEX
Definition: xhcihw.h:418
#define XHCI_HCS3_U1_LATENCY_MASK
Definition: xhcihw.h:364
#define XHCI_USBCMD_RS
Definition: xhcihw.h:390
#define XHCI_PAGESIZE_4K
Definition: xhcihw.h:412
#define XHCI_HCC1_AC64
Definition: xhcihw.h:368
#define XHCI_HCC2_ETC
Definition: xhcihw.h:378
#define XHCI_HCC2_LEC
Definition: xhcihw.h:377
#define XHCI_CAP_LENGTH_VERSION
Definition: xhcihw.h:335
FORCEINLINE LARGE_INTEGER NTAPI XhciRelativeMs(_In_ ULONG Milliseconds)
Definition: xhciutil.h:137