ReactOS 0.4.16-dev-297-gc569aee
roothub.c File Reference
#include "usbehci.h"
#include <debug.h>
#include "dbg_ehci.h"
Include dependency graph for roothub.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NDEBUG_EHCI_ROOT_HUB
 

Functions

MPSTATUS NTAPI EHCI_RH_ChirpRootPort (IN PVOID ehciExtension, IN USHORT Port)
 
VOID NTAPI EHCI_RH_GetRootHubData (IN PVOID ehciExtension, IN PVOID rootHubData)
 
MPSTATUS NTAPI EHCI_RH_GetStatus (IN PVOID ehciExtension, IN PUSHORT Status)
 
MPSTATUS NTAPI EHCI_RH_GetPortStatus (IN PVOID ehciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
 
MPSTATUS NTAPI EHCI_RH_GetHubStatus (IN PVOID ehciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
 
VOID NTAPI EHCI_RH_FinishReset (IN PVOID ehciExtension, IN PVOID Context)
 
VOID NTAPI EHCI_RH_PortResetComplete (IN PVOID ehciExtension, IN PVOID Context)
 
MPSTATUS NTAPI EHCI_RH_SetFeaturePortReset (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_SetFeaturePortPower (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_SetFeaturePortEnable (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_SetFeaturePortSuspend (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnable (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortPower (IN PVOID ehciExtension, IN USHORT Port)
 
VOID NTAPI EHCI_RH_PortResumeComplete (IN PVOID ehciExtension, IN PVOID Context)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspend (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnableChange (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortConnectChange (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortResetChange (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspendChange (IN PVOID ehciExtension, IN USHORT Port)
 
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortOvercurrentChange (IN PVOID ehciExtension, IN USHORT Port)
 
VOID NTAPI EHCI_RH_DisableIrq (IN PVOID ehciExtension)
 
VOID NTAPI EHCI_RH_EnableIrq (IN PVOID ehciExtension)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file roothub.c.

◆ NDEBUG_EHCI_ROOT_HUB

#define NDEBUG_EHCI_ROOT_HUB

Definition at line 13 of file roothub.c.

Function Documentation

◆ EHCI_RH_ChirpRootPort()

MPSTATUS NTAPI EHCI_RH_ChirpRootPort ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 18 of file roothub.c.

20{
21 PEHCI_EXTENSION EhciExtension = ehciExtension;
22 PULONG PortStatusReg;
24 ULONG PortBit;
25 ULONG ix;
26
27 DPRINT_RH("EHCI_RH_ChirpRootPort: Port - %x\n", Port);
28 ASSERT(Port != 0);
29
30 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
31 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
32 DPRINT_RH("EHCI_RH_ChirpRootPort: PortSC - %X\n", PortSC.AsULONG);
33
34 PortBit = 1 << (Port - 1);
35
36 if (PortBit & EhciExtension->ResetPortBits)
37 {
38 DPRINT_RH("EHCI_RH_ChirpRootPort: Skip port - %x\n", Port);
39 return MP_STATUS_SUCCESS;
40 }
41
42 if (PortSC.PortPower == 0)
43 {
44 DPRINT_RH("EHCI_RH_ChirpRootPort: Skip port - %x\n", Port);
45 return MP_STATUS_SUCCESS;
46 }
47
48 if (PortSC.CurrentConnectStatus == 0 ||
49 PortSC.PortEnabledDisabled == 1 ||
51 {
52 DPRINT_RH("EHCI_RH_ChirpRootPort: No port - %x\n", Port);
53 return MP_STATUS_SUCCESS;
54 }
55
57 PortSC.Suspend == 0 &&
58 PortSC.CurrentConnectStatus == 1)
59 {
60 /* Attached device is not a high-speed device.
61 Release ownership of the port to a selected HC.
62 Companion HC owns and controls the port. Section 4.2 */
64 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
65
66 DPRINT_RH("EHCI_RH_ChirpRootPort: Companion HC port - %x\n", Port);
67 return MP_STATUS_SUCCESS;
68 }
69
70 DPRINT("EHCI_RH_ChirpRootPort: EhciExtension - %p, Port - %x\n",
71 EhciExtension,
72 Port);
73
74 PortSC.PortEnabledDisabled = 0;
75 PortSC.PortReset = 1;
76 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
77
78 RegPacket.UsbPortWait(EhciExtension, 10);
79
80 do
81 {
82 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
83
84 PortSC.ConnectStatusChange = 0;
85 PortSC.PortEnableDisableChange = 0;
86 PortSC.OverCurrentChange = 0;
87 PortSC.PortReset = 0;
88
89 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
90
91 for (ix = 0; ix <= 500; ix += 20)
92 {
94 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
95
96 DPRINT_RH("EHCI_RH_ChirpRootPort: Reset port - %x\n", Port);
97
98 if (PortSC.PortReset == 0)
99 break;
100 }
101 }
102 while (PortSC.PortReset == 1);
103
104 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
105
106 if (PortSC.PortEnabledDisabled == 1)
107 {
108 PortSC.ConnectStatusChange = 0;
109 PortSC.PortEnabledDisabled = 0;
110 PortSC.PortEnableDisableChange = 0;
111 PortSC.OverCurrentChange = 0;
112
113 RegPacket.UsbPortWait(EhciExtension, 10);
114
115 EhciExtension->ResetPortBits |= PortBit;
116
117 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
118 DPRINT_RH("EHCI_RH_ChirpRootPort: Disable port - %x\n", Port);
119 }
120 else
121 {
123 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
124 DPRINT_RH("EHCI_RH_ChirpRootPort: Companion HC port - %x\n", Port);
125 }
126
127 return MP_STATUS_SUCCESS;
128}
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:27
#define READ_REGISTER_ULONG(r)
Definition: arm.h:26
#define DPRINT_RH(...)
Definition: dbg_ehci.h:46
#define EHCI_PORT_OWNER_COMPANION_CONTROLLER
Definition: hardware.h:138
#define EHCI_LINE_STATUS_K_STATE_LOW_SPEED
Definition: hardware.h:137
CPPORT Port[4]
Definition: headless.c:35
#define ASSERT(a)
Definition: mode.c:44
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
#define DPRINT
Definition: sndvol32.h:73
ULONG ResetPortBits
Definition: usbehci.h:197
PEHCI_HW_REGISTERS OperationalRegs
Definition: usbehci.h:176
EHCI_PORT_STATUS_CONTROL PortControl[15]
Definition: hardware.h:183
PUSBPORT_WAIT UsbPortWait
Definition: usbmport.h:622
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
#define MP_STATUS_SUCCESS
Definition: usbmport.h:134

Referenced by DriverEntry(), and EHCI_StartController().

◆ EHCI_RH_ClearFeaturePortConnectChange()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortConnectChange ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 591 of file roothub.c.

593{
594 PEHCI_EXTENSION EhciExtension = ehciExtension;
595 PULONG PortStatusReg;
597
598 DPRINT_RH("EHCI_RH_ClearFeaturePortConnectChange: Port - %x\n", Port);
599 ASSERT(Port != 0);
600
601 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
602
603 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
604
605 if (PortSC.ConnectStatusChange)
606 {
607 PortSC.ConnectStatusChange = 1;
608 PortSC.PortEnableDisableChange = 0;
609 PortSC.OverCurrentChange = 0;
610
611 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
612 }
613
614 EhciExtension->ConnectPortBits &= ~(1 << (Port - 1));
615
616 return MP_STATUS_SUCCESS;
617}
ULONG ConnectPortBits
Definition: usbehci.h:195

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortEnable()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnable ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 462 of file roothub.c.

464{
465 PEHCI_EXTENSION EhciExtension = ehciExtension;
466 PULONG PortStatusReg;
468
469 DPRINT("EHCI_RH_ClearFeaturePortEnable: Port - %x\n", Port);
470 ASSERT(Port != 0);
471
472 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
473
474 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
475
476 PortSC.ConnectStatusChange = 0;
477 PortSC.PortEnabledDisabled = 0;
478 PortSC.PortEnableDisableChange = 0;
479 PortSC.OverCurrentChange = 0;
480
481 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
482
483 return MP_STATUS_SUCCESS;
484}

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortEnableChange()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnableChange ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 566 of file roothub.c.

568{
569 PEHCI_EXTENSION EhciExtension = ehciExtension;
570 PULONG PortStatusReg;
572
573 DPRINT("EHCI_RH_ClearFeaturePortEnableChange: Port - %p\n", Port);
574 ASSERT(Port != 0);
575
576 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
577
578 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
579
580 PortSC.ConnectStatusChange = 0;
581 PortSC.OverCurrentChange = 0;
582 PortSC.PortEnableDisableChange = 1;
583
584 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
585
586 return MP_STATUS_SUCCESS;
587}

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortOvercurrentChange()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortOvercurrentChange ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 649 of file roothub.c.

651{
652 PEHCI_EXTENSION EhciExtension = ehciExtension;
653 PULONG PortStatusReg;
655
656 DPRINT_RH("EHCI_RH_ClearFeaturePortOvercurrentChange: Port - %x\n", Port);
657 ASSERT(Port != 0);
658
659 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
660
661 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
662
663 PortSC.ConnectStatusChange = 0;
664 PortSC.PortEnableDisableChange = 0;
665 PortSC.OverCurrentChange = 1;
666
667 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
668
669 return MP_STATUS_SUCCESS;
670}

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortPower()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortPower ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 488 of file roothub.c.

490{
491 PEHCI_EXTENSION EhciExtension = ehciExtension;
492 PULONG PortStatusReg;
494
495 DPRINT("EHCI_RH_ClearFeaturePortPower: Port - %x\n", Port);
496 ASSERT(Port != 0);
497
498 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
499
500 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
501 PortSC.PortPower = 0;
502 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
503
504 return MP_STATUS_SUCCESS;
505}

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortResetChange()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortResetChange ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 621 of file roothub.c.

623{
624 PEHCI_EXTENSION EhciExtension = ehciExtension;
625
626 DPRINT("EHCI_RH_ClearFeaturePortConnectChange: Port - %x\n", Port);
627 ASSERT(Port != 0);
628
629 EhciExtension->FinishResetPortBits &= ~(1 << (Port - 1));
630 return MP_STATUS_SUCCESS;
631}
ULONG FinishResetPortBits
Definition: usbehci.h:198

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortSuspend()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspend ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 538 of file roothub.c.

540{
541 PEHCI_EXTENSION EhciExtension = ehciExtension;
542 PULONG PortStatusReg;
544
545 DPRINT("EHCI_RH_ClearFeaturePortSuspend: Port - %x\n", Port);
546 ASSERT(Port != 0);
547
548 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
549 EhciExtension->ResetPortBits |= 1 << (Port - 1);
550
551 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
552 PortSC.ForcePortResume = 1;
553 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
554
556 50, // TimerValue
557 &Port,
558 sizeof(Port),
560
561 return MP_STATUS_SUCCESS;
562}
PUSBPORT_REQUEST_ASYNC_CALLBACK UsbPortRequestAsyncCallback
Definition: usbmport.h:620
VOID NTAPI EHCI_RH_PortResumeComplete(IN PVOID ehciExtension, IN PVOID Context)
Definition: roothub.c:509

Referenced by DriverEntry().

◆ EHCI_RH_ClearFeaturePortSuspendChange()

MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspendChange ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 635 of file roothub.c.

637{
638 PEHCI_EXTENSION EhciExtension = ehciExtension;
639
640 DPRINT("EHCI_RH_ClearFeaturePortSuspendChange: Port - %x\n", Port);
641 ASSERT(Port != 0);
642
643 EhciExtension->SuspendPortBits &= ~(1 << (Port - 1));
644 return MP_STATUS_SUCCESS;
645}
ULONG SuspendPortBits
Definition: usbehci.h:196

Referenced by DriverEntry().

◆ EHCI_RH_DisableIrq()

VOID NTAPI EHCI_RH_DisableIrq ( IN PVOID  ehciExtension)

Definition at line 674 of file roothub.c.

675{
676 PEHCI_EXTENSION EhciExtension = ehciExtension;
677 PULONG IntrStsReg;
678 EHCI_INTERRUPT_ENABLE IntrSts;
679
680 DPRINT_RH("EHCI_RH_DisableIrq: ... \n");
681
682 IntrStsReg = &EhciExtension->OperationalRegs->HcInterruptEnable.AsULONG;
683 IntrSts.AsULONG = READ_REGISTER_ULONG(IntrStsReg);
684
685 EhciExtension->InterruptMask.PortChangeInterrupt = 0;
686 IntrSts.PortChangeInterrupt = 0;
687
688 if (IntrSts.Interrupt)
689 WRITE_REGISTER_ULONG(IntrStsReg, IntrSts.AsULONG);
690}
EHCI_INTERRUPT_ENABLE InterruptMask
Definition: usbehci.h:183
EHCI_INTERRUPT_ENABLE HcInterruptEnable
Definition: hardware.h:176

Referenced by DriverEntry().

◆ EHCI_RH_EnableIrq()

VOID NTAPI EHCI_RH_EnableIrq ( IN PVOID  ehciExtension)

Definition at line 694 of file roothub.c.

695{
696 PEHCI_EXTENSION EhciExtension = ehciExtension;
697 PULONG IntrStsReg;
698 EHCI_INTERRUPT_ENABLE IntrSts;
699
700 DPRINT_RH("EHCI_RH_EnableIrq: ... \n");
701
702 IntrStsReg = &EhciExtension->OperationalRegs->HcInterruptEnable.AsULONG;
703 IntrSts.AsULONG = READ_REGISTER_ULONG(IntrStsReg);
704
705 EhciExtension->InterruptMask.PortChangeInterrupt = 1;
706 IntrSts.PortChangeInterrupt = 1;
707
708 if (IntrSts.Interrupt)
709 WRITE_REGISTER_ULONG(IntrStsReg, IntrSts.AsULONG);
710}

Referenced by DriverEntry().

◆ EHCI_RH_FinishReset()

VOID NTAPI EHCI_RH_FinishReset ( IN PVOID  ehciExtension,
IN PVOID  Context 
)

Definition at line 279 of file roothub.c.

281{
282 PEHCI_EXTENSION EhciExtension = ehciExtension;
283 PULONG PortStatusReg;
286
287 DPRINT("EHCI_RH_FinishReset: *Port - %x\n", *Port);
288
289 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[*Port - 1].AsULONG;
290 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
291
292 if (PortSC.AsULONG != -1)
293 {
294 if (!PortSC.CurrentConnectStatus)
295 DPRINT("EHCI_RH_FinishReset: PortSC.AsULONG - %X\n", PortSC.AsULONG);
296
297 if (PortSC.PortEnabledDisabled ||
298 !PortSC.CurrentConnectStatus ||
299 PortSC.ConnectStatusChange)
300 {
301 EhciExtension->FinishResetPortBits |= (1 << (*Port - 1));
302 RegPacket.UsbPortInvalidateRootHub(EhciExtension);
303 }
304 else
305 {
306 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
308 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
309 EhciExtension->FinishResetPortBits |= (1 << (*Port - 1));
310 }
311
312 EhciExtension->ResetPortBits &= ~(1 << (*Port - 1));
313 }
314}
PUSBPORT_INVALIDATE_ROOT_HUB UsbPortInvalidateRootHub
Definition: usbmport.h:614
uint16_t * PUSHORT
Definition: typedefs.h:56

Referenced by EHCI_RH_PortResetComplete().

◆ EHCI_RH_GetHubStatus()

MPSTATUS NTAPI EHCI_RH_GetHubStatus ( IN PVOID  ehciExtension,
IN PUSB_HUB_STATUS_AND_CHANGE  HubStatus 
)

Definition at line 269 of file roothub.c.

271{
272 DPRINT_RH("EHCI_RH_GetHubStatus: ... \n");
273 HubStatus->AsUlong32 = 0;
274 return MP_STATUS_SUCCESS;
275}

Referenced by DriverEntry().

◆ EHCI_RH_GetPortStatus()

MPSTATUS NTAPI EHCI_RH_GetPortStatus ( IN PVOID  ehciExtension,
IN USHORT  Port,
IN PUSB_PORT_STATUS_AND_CHANGE  PortStatus 
)

Definition at line 187 of file roothub.c.

190{
191 PEHCI_EXTENSION EhciExtension = ehciExtension;
192 PULONG PortStatusReg;
195 ULONG PortMaskBits;
196
197 ASSERT(Port != 0);
198
199 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
200 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
201
202 if (PortSC.CurrentConnectStatus)
203 {
204 DPRINT_RH("EHCI_RH_GetPortStatus: Port - %x, PortSC.AsULONG - %X\n",
205 Port,
206 PortSC.AsULONG);
207 }
208
209 PortStatus->AsUlong32 = 0;
210
213 (PortSC.PortEnabledDisabled | PortSC.Suspend) && // Enable or Suspend
214 PortSC.CurrentConnectStatus == 1) // Device is present
215 {
216 DPRINT("EHCI_RH_GetPortStatus: LowSpeed device detected\n");
217 PortSC.PortOwner = EHCI_PORT_OWNER_COMPANION_CONTROLLER; // release ownership
218 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
219 return MP_STATUS_SUCCESS;
220 }
221
222 status.AsUlong32 = 0;
223
224 status.PortStatus.Usb20PortStatus.CurrentConnectStatus = PortSC.CurrentConnectStatus;
225 status.PortStatus.Usb20PortStatus.PortEnabledDisabled = PortSC.PortEnabledDisabled;
226 status.PortStatus.Usb20PortStatus.Suspend = PortSC.Suspend;
227 status.PortStatus.Usb20PortStatus.OverCurrent = PortSC.OverCurrentActive;
228 status.PortStatus.Usb20PortStatus.Reset = PortSC.PortReset;
229 status.PortStatus.Usb20PortStatus.PortPower = PortSC.PortPower;
231 status.PortStatus.Usb20PortStatus.Reserved1 = USB20_PORT_STATUS_RESERVED1_OWNED_BY_COMPANION;
232
233 status.PortChange.Usb20PortChange.PortEnableDisableChange = PortSC.PortEnableDisableChange;
234 status.PortChange.Usb20PortChange.OverCurrentIndicatorChange = PortSC.OverCurrentChange;
235
236 PortMaskBits = 1 << (Port - 1);
237
238 if (status.PortStatus.Usb20PortStatus.CurrentConnectStatus)
239 status.PortStatus.Usb20PortStatus.LowSpeedDeviceAttached = 0;
240
241 status.PortStatus.Usb20PortStatus.HighSpeedDeviceAttached = 1;
242
243 if (PortSC.ConnectStatusChange)
244 EhciExtension->ConnectPortBits |= PortMaskBits;
245
246 if (EhciExtension->FinishResetPortBits & PortMaskBits)
247 status.PortChange.Usb20PortChange.ResetChange = 1;
248
249 if (EhciExtension->ConnectPortBits & PortMaskBits)
250 status.PortChange.Usb20PortChange.ConnectStatusChange = 1;
251
252 if (EhciExtension->SuspendPortBits & PortMaskBits)
253 status.PortChange.Usb20PortChange.SuspendChange = 1;
254
256
257 if (status.PortStatus.Usb20PortStatus.CurrentConnectStatus)
258 {
259 DPRINT_RH("EHCI_RH_GetPortStatus: Port - %x, status.AsULONG - %X\n",
260 Port,
261 status.AsUlong32);
262 }
263
264 return MP_STATUS_SUCCESS;
265}
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:42
Definition: ps.c:97
#define USB20_PORT_STATUS_RESERVED1_OWNED_BY_COMPANION
Definition: usbmport.h:288

Referenced by DriverEntry().

◆ EHCI_RH_GetRootHubData()

VOID NTAPI EHCI_RH_GetRootHubData ( IN PVOID  ehciExtension,
IN PVOID  rootHubData 
)

Definition at line 132 of file roothub.c.

134{
135 PEHCI_EXTENSION EhciExtension = ehciExtension;
136 PUSBPORT_ROOT_HUB_DATA RootHubData;
137 USBPORT_HUB_20_CHARACTERISTICS HubCharacteristics;
138
139 DPRINT_RH("EHCI_RH_GetRootHubData: EhciExtension - %p, rootHubData - %p\n",
140 EhciExtension,
141 rootHubData);
142
143 RootHubData = rootHubData;
144
145 RootHubData->NumberOfPorts = EhciExtension->NumberOfPorts;
146
147 HubCharacteristics.AsUSHORT = 0;
148
149 /* Logical Power Switching Mode */
150 if (EhciExtension->PortPowerControl == 1)
151 {
152 /* Individual port power switching */
153 HubCharacteristics.PowerControlMode = 1;
154 }
155 else
156 {
157 /* Ganged power switching (all ports' power at once) */
158 HubCharacteristics.PowerControlMode = 0;
159 }
160
161 HubCharacteristics.NoPowerSwitching = 0;
162
163 /* EHCI RH is not part of a compound device */
164 HubCharacteristics.PartOfCompoundDevice = 0;
165
166 /* Global Over-current Protection */
167 HubCharacteristics.OverCurrentProtectionMode = 0;
168
169 RootHubData->HubCharacteristics.Usb20HubCharacteristics = HubCharacteristics;
170
171 RootHubData->PowerOnToPowerGood = 2; // Time (in 2 ms intervals)
172 RootHubData->HubControlCurrent = 0;
173}
USHORT PortPowerControl
Definition: usbehci.h:182
USHORT NumberOfPorts
Definition: usbehci.h:181
USBPORT_HUB_CHARACTERISTICS HubCharacteristics
Definition: usbmport.h:697
USBPORT_HUB_20_CHARACTERISTICS Usb20HubCharacteristics
Definition: usbmport.h:689

Referenced by DriverEntry().

◆ EHCI_RH_GetStatus()

MPSTATUS NTAPI EHCI_RH_GetStatus ( IN PVOID  ehciExtension,
IN PUSHORT  Status 
)

Definition at line 177 of file roothub.c.

179{
180 DPRINT_RH("EHCI_RH_GetStatus: ... \n");
182 return MP_STATUS_SUCCESS;
183}
Status
Definition: gdiplustypes.h:25
#define USB_GETSTATUS_SELF_POWERED
Definition: usb100.h:45

Referenced by DriverEntry().

◆ EHCI_RH_PortResetComplete()

VOID NTAPI EHCI_RH_PortResetComplete ( IN PVOID  ehciExtension,
IN PVOID  Context 
)

Definition at line 318 of file roothub.c.

320{
321 PEHCI_EXTENSION EhciExtension = ehciExtension;
322 PULONG PortStatusReg;
324 ULONG ix;
326
327 DPRINT("EHCI_RH_PortResetComplete: *Port - %x\n", *Port);
328
329 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[*Port - 1].AsULONG;
330
331 do
332 {
333 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
334
335 PortSC.ConnectStatusChange = 0;
336 PortSC.PortEnableDisableChange = 0;
337 PortSC.OverCurrentChange = 0;
338 PortSC.PortReset = 0;
339
340 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
341
342 for (ix = 0; ix <= 500; ix += 20)
343 {
345 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
346
347 DPRINT("EHCI_RH_PortResetComplete: Reset port - %x\n", Port);
348
349 if (PortSC.PortReset == 0)
350 break;
351 }
352 }
353 while (PortSC.PortReset == 1 && (PortSC.AsULONG != -1));
354
356 50, // TimerValue
357 Port,
358 sizeof(*Port),
360}
VOID NTAPI EHCI_RH_FinishReset(IN PVOID ehciExtension, IN PVOID Context)
Definition: roothub.c:279

Referenced by EHCI_RH_SetFeaturePortReset().

◆ EHCI_RH_PortResumeComplete()

VOID NTAPI EHCI_RH_PortResumeComplete ( IN PVOID  ehciExtension,
IN PVOID  Context 
)

Definition at line 509 of file roothub.c.

511{
512 PEHCI_EXTENSION EhciExtension = ehciExtension;
513 PULONG PortStatusReg;
516
517 DPRINT("EHCI_RH_PortResumeComplete: *Port - %x\n", *Port);
518 ASSERT(Port != 0);
519
520 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[*Port - 1].AsULONG;
521
522 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
523
524 PortSC.ConnectStatusChange = 0;
525 PortSC.PortEnableDisableChange = 0;
526 PortSC.OverCurrentChange = 0;
527 PortSC.ForcePortResume = 0;
528 PortSC.Suspend = 0;
529
530 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
531 READ_REGISTER_ULONG(PortStatusReg);
532
533 EhciExtension->SuspendPortBits |= 1 << (*Port - 1);
534}

Referenced by EHCI_RH_ClearFeaturePortSuspend().

◆ EHCI_RH_SetFeaturePortEnable()

MPSTATUS NTAPI EHCI_RH_SetFeaturePortEnable ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 425 of file roothub.c.

427{
428 DPRINT_RH("EHCI_RH_SetFeaturePortEnable: Not supported\n");
429 ASSERT(Port != 0);
430 return MP_STATUS_SUCCESS;
431}

Referenced by DriverEntry().

◆ EHCI_RH_SetFeaturePortPower()

MPSTATUS NTAPI EHCI_RH_SetFeaturePortPower ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 399 of file roothub.c.

401{
402 PEHCI_EXTENSION EhciExtension = ehciExtension;
403 PULONG PortStatusReg;
405
406 DPRINT_RH("EHCI_RH_SetFeaturePortPower: Port - %x\n", Port);
407 ASSERT(Port != 0);
408
409 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
410
411 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
412
413 PortSC.ConnectStatusChange = 0;
414 PortSC.PortEnableDisableChange = 0;
415 PortSC.OverCurrentChange = 0;
416 PortSC.PortPower = 1;
417
418 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
419
420 return MP_STATUS_SUCCESS;
421}

Referenced by DriverEntry(), and EHCI_StartController().

◆ EHCI_RH_SetFeaturePortReset()

MPSTATUS NTAPI EHCI_RH_SetFeaturePortReset ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 364 of file roothub.c.

366{
367 PEHCI_EXTENSION EhciExtension = ehciExtension;
368 PULONG PortStatusReg;
370
371 DPRINT("EHCI_RH_SetFeaturePortReset: Port - %x\n", Port);
372 ASSERT(Port != 0);
373
374 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
375
376 EhciExtension->ResetPortBits |= 1 << (Port - 1);
377
378 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
379
380 PortSC.ConnectStatusChange = 0;
381 PortSC.PortEnabledDisabled = 0;
382 PortSC.PortEnableDisableChange = 0;
383 PortSC.OverCurrentChange = 0;
384 PortSC.PortReset = 1;
385
386 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
387
389 50, // TimerValue
390 &Port,
391 sizeof(Port),
393
394 return MP_STATUS_SUCCESS;
395}
VOID NTAPI EHCI_RH_PortResetComplete(IN PVOID ehciExtension, IN PVOID Context)
Definition: roothub.c:318

Referenced by DriverEntry().

◆ EHCI_RH_SetFeaturePortSuspend()

MPSTATUS NTAPI EHCI_RH_SetFeaturePortSuspend ( IN PVOID  ehciExtension,
IN USHORT  Port 
)

Definition at line 435 of file roothub.c.

437{
438 PEHCI_EXTENSION EhciExtension = ehciExtension;
439 PULONG PortStatusReg;
441
442 DPRINT("EHCI_RH_SetFeaturePortSuspend: Port - %x\n", Port);
443 ASSERT(Port != 0);
444
445 PortStatusReg = &EhciExtension->OperationalRegs->PortControl[Port - 1].AsULONG;
446
447 PortSC.AsULONG = READ_REGISTER_ULONG(PortStatusReg);
448
449 PortSC.ConnectStatusChange = 0;
450 PortSC.PortEnableDisableChange = 0;
451 PortSC.OverCurrentChange = 0;
452 PortSC.Suspend = 1;
453
454 WRITE_REGISTER_ULONG(PortStatusReg, PortSC.AsULONG);
456
457 return MP_STATUS_SUCCESS;
458}

Referenced by DriverEntry().