3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 // Two arrays used to translate the EHCI port state (change)
28 // to the UEFI protocol's port state (change).
30 USB_PORT_STATE_MAP mUsbPortStateMap
[] = {
31 {PORTSC_CONN
, USB_PORT_STAT_CONNECTION
},
32 {PORTSC_ENABLED
, USB_PORT_STAT_ENABLE
},
33 {PORTSC_SUSPEND
, USB_PORT_STAT_SUSPEND
},
34 {PORTSC_OVERCUR
, USB_PORT_STAT_OVERCURRENT
},
35 {PORTSC_RESET
, USB_PORT_STAT_RESET
},
36 {PORTSC_POWER
, USB_PORT_STAT_POWER
},
37 {PORTSC_OWNER
, USB_PORT_STAT_OWNER
}
40 USB_PORT_STATE_MAP mUsbPortChangeMap
[] = {
41 {PORTSC_CONN_CHANGE
, USB_PORT_STAT_C_CONNECTION
},
42 {PORTSC_ENABLE_CHANGE
, USB_PORT_STAT_C_ENABLE
},
43 {PORTSC_OVERCUR_CHANGE
, USB_PORT_STAT_C_OVERCURRENT
}
48 Retrieves the capablility of root hub ports.
50 @param This This EFI_USB_HC_PROTOCOL instance.
51 @param MaxSpeed Max speed supported by the controller
52 @param PortNumber Number of the root hub ports.
53 @param Is64BitCapable Whether the controller supports 64-bit memory
56 @return EFI_SUCCESS : host controller capability were retrieved successfully.
57 @return EFI_INVALID_PARAMETER : Either of the three capability pointer is NULL
64 IN EFI_USB2_HC_PROTOCOL
*This
,
66 OUT UINT8
*PortNumber
,
67 OUT UINT8
*Is64BitCapable
73 if ((MaxSpeed
== NULL
) || (PortNumber
== NULL
) || (Is64BitCapable
== NULL
)) {
74 return EFI_INVALID_PARAMETER
;
77 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
78 Ehc
= EHC_FROM_THIS (This
);
80 *MaxSpeed
= EFI_USB_SPEED_HIGH
;
81 *PortNumber
= (UINT8
) (Ehc
->HcStructParams
& HCSP_NPORTS
);
82 *Is64BitCapable
= (UINT8
) (Ehc
->HcCapParams
& HCCP_64BIT
);
84 EHC_DEBUG (("EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber
, *Is64BitCapable
));
86 gBS
->RestoreTPL (OldTpl
);
92 Provides software reset for the USB host controller.
94 @param This This EFI_USB2_HC_PROTOCOL instance.
95 @param Attributes A bit mask of the reset operation to perform.
97 @return EFI_SUCCESS : The reset operation succeeded.
98 @return EFI_INVALID_PARAMETER : Attributes is not valid.
99 @return EFI_UNSUPPOURTED : The type of reset specified by Attributes is
100 @return not currently supported by the host controller.
101 @return EFI_DEVICE_ERROR : Host controller isn't halted to reset.
108 IN EFI_USB2_HC_PROTOCOL
*This
,
116 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
117 Ehc
= EHC_FROM_THIS (This
);
119 switch (Attributes
) {
120 case EFI_USB_HC_RESET_GLOBAL
:
122 // Flow through, same behavior as Host Controller Reset
124 case EFI_USB_HC_RESET_HOST_CONTROLLER
:
126 // Host Controller must be Halt when Reset it
128 if (!EhcIsHalt (Ehc
)) {
129 Status
= EhcHaltHC (Ehc
, EHC_GENERIC_TIME
);
131 if (EFI_ERROR (Status
)) {
132 Status
= EFI_DEVICE_ERROR
;
138 // Clean up the asynchronous transfers, currently only
139 // interrupt supports asynchronous operation.
141 EhciDelAllAsyncIntTransfers (Ehc
);
142 EhcAckAllInterrupt (Ehc
);
145 Status
= EhcResetHC (Ehc
, EHC_STALL_1_SECOND
);
147 if (EFI_ERROR (Status
)) {
151 Status
= EhcInitHC (Ehc
);
154 case EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
:
155 case EFI_USB_HC_RESET_HOST_WITH_DEBUG
:
156 Status
= EFI_UNSUPPORTED
;
160 Status
= EFI_INVALID_PARAMETER
;
164 EHC_DEBUG (("EhcReset: exit status %r\n", Status
));
165 gBS
->RestoreTPL (OldTpl
);
171 Retrieve the current state of the USB host controller.
173 @param This This EFI_USB2_HC_PROTOCOL instance.
174 @param State Variable to return the current host controller
177 @return EFI_SUCCESS : Host controller state was returned in State.
178 @return EFI_INVALID_PARAMETER : State is NULL.
179 @return EFI_DEVICE_ERROR : An error was encountered while attempting to
180 @return retrieve the host controller's current state.
187 IN CONST EFI_USB2_HC_PROTOCOL
*This
,
188 OUT EFI_USB_HC_STATE
*State
195 return EFI_INVALID_PARAMETER
;
198 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
199 Ehc
= EHC_FROM_THIS (This
);
201 if (EHC_REG_BIT_IS_SET (Ehc
, EHC_USBSTS_OFFSET
, USBSTS_HALT
)) {
202 *State
= EfiUsbHcStateHalt
;
204 *State
= EfiUsbHcStateOperational
;
207 gBS
->RestoreTPL (OldTpl
);
209 EHC_DEBUG (("EhcGetState: current state %d\n", *State
));
215 Sets the USB host controller to a specific state.
217 @param This This EFI_USB2_HC_PROTOCOL instance.
218 @param State The state of the host controller that will be set.
220 @return EFI_SUCCESS : The USB host controller was successfully placed
221 @return in the state specified by State.
222 @return EFI_INVALID_PARAMETER : State is invalid.
223 @return EFI_DEVICE_ERROR : Failed to set the state due to device error.
230 IN EFI_USB2_HC_PROTOCOL
*This
,
231 IN EFI_USB_HC_STATE State
237 EFI_USB_HC_STATE CurState
;
239 Status
= EhcGetState (This
, &CurState
);
241 if (EFI_ERROR (Status
)) {
242 return EFI_DEVICE_ERROR
;
245 if (CurState
== State
) {
249 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
250 Ehc
= EHC_FROM_THIS (This
);
253 case EfiUsbHcStateHalt
:
254 Status
= EhcHaltHC (Ehc
, EHC_GENERIC_TIME
);
257 case EfiUsbHcStateOperational
:
258 if (EHC_REG_BIT_IS_SET (Ehc
, EHC_USBSTS_OFFSET
, USBSTS_SYS_ERROR
)) {
259 Status
= EFI_DEVICE_ERROR
;
263 Status
= EhcRunHC (Ehc
, EHC_GENERIC_TIME
);
266 case EfiUsbHcStateSuspend
:
267 Status
= EFI_UNSUPPORTED
;
271 Status
= EFI_INVALID_PARAMETER
;
274 EHC_DEBUG (("EhcSetState: exit status %r\n", Status
));
275 gBS
->RestoreTPL (OldTpl
);
281 Retrieves the current status of a USB root hub port.
283 @param This This EFI_USB2_HC_PROTOCOL instance.
284 @param PortNumber The root hub port to retrieve the state from. This
286 @param PortStatus Variable to receive the port state
288 @return EFI_SUCCESS : The status of the USB root hub port specified
289 @return by PortNumber was returned in PortStatus.
290 @return EFI_INVALID_PARAMETER : PortNumber is invalid.
291 @return EFI_DEVICE_ERROR : Can't read register
297 EhcGetRootHubPortStatus (
298 IN CONST EFI_USB2_HC_PROTOCOL
*This
,
299 IN CONST UINT8 PortNumber
,
300 OUT EFI_USB_PORT_STATUS
*PortStatus
312 if (PortStatus
== NULL
) {
313 return EFI_INVALID_PARAMETER
;
316 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
318 Ehc
= EHC_FROM_THIS (This
);
319 Status
= EFI_SUCCESS
;
321 TotalPort
= (Ehc
->HcStructParams
& HCSP_NPORTS
);
323 if (PortNumber
>= TotalPort
) {
324 Status
= EFI_INVALID_PARAMETER
;
328 Offset
= (UINT32
) (EHC_PORT_STAT_OFFSET
+ (4 * PortNumber
));
329 PortStatus
->PortStatus
= 0;
330 PortStatus
->PortChangeStatus
= 0;
332 State
= EhcReadOpReg (Ehc
, Offset
);
335 // Identify device speed. If in K state, it is low speed.
336 // If the port is enabled after reset, the device is of
337 // high speed. The USB bus driver should retrieve the actual
338 // port speed after reset.
340 if (EHC_BIT_IS_SET (State
, PORTSC_LINESTATE_K
)) {
341 PortStatus
->PortStatus
|= USB_PORT_STAT_LOW_SPEED
;
343 } else if (EHC_BIT_IS_SET (State
, PORTSC_ENABLED
)) {
344 PortStatus
->PortStatus
|= USB_PORT_STAT_HIGH_SPEED
;
348 // Convert the EHCI port/port change state to UEFI status
350 MapSize
= sizeof (mUsbPortStateMap
) / sizeof (USB_PORT_STATE_MAP
);
352 for (Index
= 0; Index
< MapSize
; Index
++) {
353 if (EHC_BIT_IS_SET (State
, mUsbPortStateMap
[Index
].HwState
)) {
354 PortStatus
->PortStatus
= (UINT16
) (PortStatus
->PortStatus
| mUsbPortStateMap
[Index
].UefiState
);
358 MapSize
= sizeof (mUsbPortChangeMap
) / sizeof (USB_PORT_STATE_MAP
);
360 for (Index
= 0; Index
< MapSize
; Index
++) {
361 if (EHC_BIT_IS_SET (State
, mUsbPortChangeMap
[Index
].HwState
)) {
362 PortStatus
->PortChangeStatus
= (UINT16
) (PortStatus
->PortChangeStatus
| mUsbPortChangeMap
[Index
].UefiState
);
367 gBS
->RestoreTPL (OldTpl
);
373 Sets a feature for the specified root hub port.
375 @param This This EFI_USB2_HC_PROTOCOL instance.
376 @param PortNumber Root hub port to set.
377 @param PortFeature Feature to set
379 @return EFI_SUCCESS : The feature specified by PortFeature was set
380 @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.
381 @return EFI_DEVICE_ERROR : Can't read register
387 EhcSetRootHubPortFeature (
388 IN EFI_USB2_HC_PROTOCOL
*This
,
390 IN EFI_USB_PORT_FEATURE PortFeature
400 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
401 Ehc
= EHC_FROM_THIS (This
);
402 Status
= EFI_SUCCESS
;
404 TotalPort
= (Ehc
->HcStructParams
& HCSP_NPORTS
);
406 if (PortNumber
>= TotalPort
) {
407 Status
= EFI_INVALID_PARAMETER
;
411 Offset
= (UINT32
) (EHC_PORT_STAT_OFFSET
+ (4 * PortNumber
));
412 State
= EhcReadOpReg (Ehc
, Offset
);
415 // Mask off the port status change bits, these bits are
418 State
&= ~PORTSC_CHANGE_MASK
;
420 switch (PortFeature
) {
421 case EfiUsbPortEnable
:
423 // Sofeware can't set this bit, Port can only be enable by
424 // EHCI as a part of the reset and enable
426 State
|= PORTSC_ENABLED
;
427 EhcWriteOpReg (Ehc
, Offset
, State
);
430 case EfiUsbPortSuspend
:
431 State
|= PORTSC_SUSPEND
;
432 EhcWriteOpReg (Ehc
, Offset
, State
);
435 case EfiUsbPortReset
:
437 // Make sure Host Controller not halt before reset it
439 if (EhcIsHalt (Ehc
)) {
440 Status
= EhcRunHC (Ehc
, EHC_GENERIC_TIME
);
442 if (EFI_ERROR (Status
)) {
443 EHC_DEBUG (("EhcSetRootHubPortFeature :failed to start HC - %r\n", Status
));
449 // Set one to PortReset bit must also set zero to PortEnable bit
451 State
|= PORTSC_RESET
;
452 State
&= ~PORTSC_ENABLED
;
453 EhcWriteOpReg (Ehc
, Offset
, State
);
456 case EfiUsbPortPower
:
458 // Not supported, ignore the operation
460 Status
= EFI_SUCCESS
;
463 case EfiUsbPortOwner
:
464 State
|= PORTSC_OWNER
;
465 EhcWriteOpReg (Ehc
, Offset
, State
);
469 Status
= EFI_INVALID_PARAMETER
;
473 EHC_DEBUG (("EhcSetRootHubPortFeature: exit status %r\n", Status
));
475 gBS
->RestoreTPL (OldTpl
);
481 Clears a feature for the specified root hub port.
483 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
484 @param PortNumber Specifies the root hub port whose feature is
485 requested to be cleared.
486 @param PortFeature Indicates the feature selector associated with the
487 feature clear request.
489 @return EFI_SUCCESS : The feature specified by PortFeature was cleared
490 @return for the USB root hub port specified by PortNumber.
491 @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.
492 @return EFI_DEVICE_ERROR : Can't read register
498 EhcClearRootHubPortFeature (
499 IN EFI_USB2_HC_PROTOCOL
*This
,
501 IN EFI_USB_PORT_FEATURE PortFeature
511 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
512 Ehc
= EHC_FROM_THIS (This
);
513 Status
= EFI_SUCCESS
;
515 TotalPort
= (Ehc
->HcStructParams
& HCSP_NPORTS
);
517 if (PortNumber
>= TotalPort
) {
518 Status
= EFI_INVALID_PARAMETER
;
522 Offset
= EHC_PORT_STAT_OFFSET
+ (4 * PortNumber
);
523 State
= EhcReadOpReg (Ehc
, Offset
);
524 State
&= ~PORTSC_CHANGE_MASK
;
526 switch (PortFeature
) {
527 case EfiUsbPortEnable
:
529 // Clear PORT_ENABLE feature means disable port.
531 State
&= ~PORTSC_ENABLED
;
532 EhcWriteOpReg (Ehc
, Offset
, State
);
535 case EfiUsbPortSuspend
:
537 // A write of zero to this bit is ignored by the host
538 // controller. The host controller will unconditionally
539 // set this bit to a zero when:
540 // 1. software sets the Forct Port Resume bit to a zero from a one.
541 // 2. software sets the Port Reset bit to a one frome a zero.
543 State
&= ~PORSTSC_RESUME
;
544 EhcWriteOpReg (Ehc
, Offset
, State
);
547 case EfiUsbPortReset
:
549 // Clear PORT_RESET means clear the reset signal.
551 State
&= ~PORTSC_RESET
;
552 EhcWriteOpReg (Ehc
, Offset
, State
);
555 case EfiUsbPortOwner
:
557 // Clear port owner means this port owned by EHC
559 State
&= ~PORTSC_OWNER
;
560 EhcWriteOpReg (Ehc
, Offset
, State
);
563 case EfiUsbPortConnectChange
:
565 // Clear connect status change
567 State
|= PORTSC_CONN_CHANGE
;
568 EhcWriteOpReg (Ehc
, Offset
, State
);
571 case EfiUsbPortEnableChange
:
573 // Clear enable status change
575 State
|= PORTSC_ENABLE_CHANGE
;
576 EhcWriteOpReg (Ehc
, Offset
, State
);
579 case EfiUsbPortOverCurrentChange
:
581 // Clear PortOverCurrent change
583 State
|= PORTSC_OVERCUR_CHANGE
;
584 EhcWriteOpReg (Ehc
, Offset
, State
);
587 case EfiUsbPortPower
:
588 case EfiUsbPortSuspendChange
:
589 case EfiUsbPortResetChange
:
591 // Not supported or not related operation
596 Status
= EFI_INVALID_PARAMETER
;
601 EHC_DEBUG (("EhcClearRootHubPortFeature: exit status %r\n", Status
));
602 gBS
->RestoreTPL (OldTpl
);
608 Submits control transfer to a target USB device.
610 @param This This EFI_USB2_HC_PROTOCOL instance.
611 @param DeviceAddress The target device address
612 @param DeviceSpeed Target device speed.
613 @param MaximumPacketLength Maximum packet size the default control transfer
614 endpoint is capable of sending or receiving.
615 @param Request USB device request to send
616 @param TransferDirection Specifies the data direction for the data stage
617 @param Data Data buffer to be transmitted or received from USB
619 @param DataLength The size (in bytes) of the data buffer
620 @param TimeOut Indicates the maximum timeout, in millisecond,
621 @param Translator Transaction translator to be used by this device.
622 @param TransferResult Return the result of this control transfer.
624 @return EFI_SUCCESS : Transfer was completed successfully.
625 @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resources.
626 @return EFI_INVALID_PARAMETER : Some parameters are invalid.
627 @return EFI_TIMEOUT : Transfer failed due to timeout.
628 @return EFI_DEVICE_ERROR : Transfer failed due to host controller or device error.
635 IN EFI_USB2_HC_PROTOCOL
*This
,
636 IN UINT8 DeviceAddress
,
637 IN UINT8 DeviceSpeed
,
638 IN UINTN MaximumPacketLength
,
639 IN EFI_USB_DEVICE_REQUEST
*Request
,
640 IN EFI_USB_DATA_DIRECTION TransferDirection
,
642 IN OUT UINTN
*DataLength
,
644 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
645 OUT UINT32
*TransferResult
655 // Validate parameters
657 if ((Request
== NULL
) || (TransferResult
== NULL
)) {
658 return EFI_INVALID_PARAMETER
;
661 if ((TransferDirection
!= EfiUsbDataIn
) &&
662 (TransferDirection
!= EfiUsbDataOut
) &&
663 (TransferDirection
!= EfiUsbNoData
)) {
664 return EFI_INVALID_PARAMETER
;
667 if ((TransferDirection
== EfiUsbNoData
) &&
668 ((Data
!= NULL
) || (*DataLength
!= 0))) {
669 return EFI_INVALID_PARAMETER
;
672 if ((TransferDirection
!= EfiUsbNoData
) &&
673 ((Data
== NULL
) || (*DataLength
== 0))) {
674 return EFI_INVALID_PARAMETER
;
677 if ((MaximumPacketLength
!= 8) && (MaximumPacketLength
!= 16) &&
678 (MaximumPacketLength
!= 32) && (MaximumPacketLength
!= 64)) {
679 return EFI_INVALID_PARAMETER
;
682 if ((DeviceSpeed
== EFI_USB_SPEED_LOW
) && (MaximumPacketLength
!= 8)) {
683 return EFI_INVALID_PARAMETER
;
686 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
687 Ehc
= EHC_FROM_THIS (This
);
689 Status
= EFI_DEVICE_ERROR
;
690 *TransferResult
= EFI_USB_ERR_SYSTEM
;
692 if (EhcIsHalt (Ehc
) || EhcIsSysError (Ehc
)) {
693 EHC_ERROR (("EhcControlTransfer: HC halted at entrance\n"));
695 EhcAckAllInterrupt (Ehc
);
699 EhcAckAllInterrupt (Ehc
);
702 // Create a new URB, insert it into the asynchronous
703 // schedule list, then poll the execution status.
706 // Encode the direction in address, although default control
707 // endpoint is bidirectional. EhcCreateUrb expects this
708 // combination of Ep addr and its direction.
710 Endpoint
= (UINT8
) (0 | ((TransferDirection
== EfiUsbDataIn
) ? 0x80 : 0));
729 EHC_ERROR (("EhcControlTransfer: failed to create URB"));
731 Status
= EFI_OUT_OF_RESOURCES
;
735 EhcLinkQhToAsync (Ehc
, Urb
->Qh
);
736 Status
= EhcExecTransfer (Ehc
, Urb
, TimeOut
);
737 EhcUnlinkQhFromAsync (Ehc
, Urb
->Qh
);
740 // Get the status from URB. The result is updated in EhcCheckUrbResult
741 // which is called by EhcExecTransfer
743 *TransferResult
= Urb
->Result
;
744 *DataLength
= Urb
->Completed
;
746 if (*TransferResult
== EFI_USB_NOERROR
) {
747 Status
= EFI_SUCCESS
;
750 EhcAckAllInterrupt (Ehc
);
751 EhcFreeUrb (Ehc
, Urb
);
754 Ehc
->PciIo
->Flush (Ehc
->PciIo
);
755 gBS
->RestoreTPL (OldTpl
);
757 if (EFI_ERROR (Status
)) {
758 EHC_ERROR (("EhcControlTransfer: error - %r, transfer - %x\n", Status
, *TransferResult
));
766 Submits bulk transfer to a bulk endpoint of a USB device.
768 @param This This EFI_USB2_HC_PROTOCOL instance.
769 @param DeviceAddress Target device address
770 @param EndPointAddress Endpoint number and its direction in bit 7. .
771 @param DeviceSpeed Device speed, Low speed device doesn't support bulk
773 @param MaximumPacketLength Maximum packet size the endpoint is capable of
774 sending or receiving.
775 @param DataBuffersNumber Number of data buffers prepared for the transfer.
776 @param Data Array of pointers to the buffers of data to transmit
777 from or receive into.
778 @param DataLength The lenght of the data buffer
779 @param DataToggle On input, the initial data toggle for the transfer;
780 On output, it is updated to to next data toggle to
781 use of the subsequent bulk
783 @param Translator A pointr to the transaction translator data.
784 @param TimeOut Indicates the maximum time, in millisecond, which
785 the transfer is allowed to complete.
786 @param TransferResult A pointer to the detailed result information of the
789 @return EFI_SUCCESS : The transfer was completed successfully.
790 @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resource.
791 @return EFI_INVALID_PARAMETER : Some parameters are invalid.
792 @return EFI_TIMEOUT : The transfer failed due to timeout.
793 @return EFI_DEVICE_ERROR : The transfer failed due to host controller error.
800 IN EFI_USB2_HC_PROTOCOL
*This
,
801 IN UINT8 DeviceAddress
,
802 IN UINT8 EndPointAddress
,
803 IN UINT8 DeviceSpeed
,
804 IN UINTN MaximumPacketLength
,
805 IN UINT8 DataBuffersNumber
,
806 IN OUT VOID
*Data
[EFI_USB_MAX_BULK_BUFFER_NUM
],
807 IN OUT UINTN
*DataLength
,
808 IN OUT UINT8
*DataToggle
,
810 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
811 OUT UINT32
*TransferResult
820 // Validate the parameters
822 if ((DataLength
== NULL
) || (*DataLength
== 0) ||
823 (Data
== NULL
) || (Data
[0] == NULL
) || (TransferResult
== NULL
)) {
824 return EFI_INVALID_PARAMETER
;
827 if ((*DataToggle
!= 0) && (*DataToggle
!= 1)) {
828 return EFI_INVALID_PARAMETER
;
831 if ((DeviceSpeed
== EFI_USB_SPEED_LOW
) ||
832 ((DeviceSpeed
== EFI_USB_SPEED_FULL
) && (MaximumPacketLength
> 64)) ||
833 ((EFI_USB_SPEED_HIGH
== DeviceSpeed
) && (MaximumPacketLength
> 512))) {
834 return EFI_INVALID_PARAMETER
;
837 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
838 Ehc
= EHC_FROM_THIS (This
);
840 *TransferResult
= EFI_USB_ERR_SYSTEM
;
841 Status
= EFI_DEVICE_ERROR
;
843 if (EhcIsHalt (Ehc
) || EhcIsSysError (Ehc
)) {
844 EHC_ERROR (("EhcBulkTransfer: HC is halted\n"));
846 EhcAckAllInterrupt (Ehc
);
850 EhcAckAllInterrupt (Ehc
);
853 // Create a new URB, insert it into the asynchronous
854 // schedule list, then poll the execution status.
874 EHC_ERROR (("EhcBulkTransfer: failed to create URB\n"));
876 Status
= EFI_OUT_OF_RESOURCES
;
880 EhcLinkQhToAsync (Ehc
, Urb
->Qh
);
881 Status
= EhcExecTransfer (Ehc
, Urb
, TimeOut
);
882 EhcUnlinkQhFromAsync (Ehc
, Urb
->Qh
);
884 *TransferResult
= Urb
->Result
;
885 *DataLength
= Urb
->Completed
;
886 *DataToggle
= Urb
->DataToggle
;
888 if (*TransferResult
== EFI_USB_NOERROR
) {
889 Status
= EFI_SUCCESS
;
892 EhcAckAllInterrupt (Ehc
);
893 EhcFreeUrb (Ehc
, Urb
);
896 Ehc
->PciIo
->Flush (Ehc
->PciIo
);
897 gBS
->RestoreTPL (OldTpl
);
899 if (EFI_ERROR (Status
)) {
900 EHC_ERROR (("EhcBulkTransfer: error - %r, transfer - %x\n", Status
, *TransferResult
));
908 Submits an asynchronous interrupt transfer to an
909 interrupt endpoint of a USB device.
911 @param This This EFI_USB2_HC_PROTOCOL instance.
912 @param DeviceAddress Target device address
913 @param EndPointAddress Endpoint number and its direction encoded in bit 7
914 @param DeviceSpeed Indicates device speed.
915 @param MaximumPacketLength Maximum packet size the target endpoint is capable
916 @param IsNewTransfer If TRUE, to submit an new asynchronous interrupt
917 transfer If FALSE, to remove the specified
918 asynchronous interrupt
919 @param DataToggle On input, the initial data toggle to use; on output,
920 it is updated to indicate the next data toggle
921 @param PollingInterval The he interval, in milliseconds, that the transfer
923 @param DataLength The length of data to receive at the rate specified
925 @param Translator Transaction translator to use.
926 @param CallBackFunction Function to call at the rate specified by
928 @param Context Context to CallBackFunction.
930 @return EFI_SUCCESS : The request has been successfully submitted or canceled.
931 @return EFI_INVALID_PARAMETER : Some parameters are invalid.
932 @return EFI_OUT_OF_RESOURCES : The request failed due to a lack of resources.
933 @return EFI_DEVICE_ERROR : The transfer failed due to host controller error.
939 EhcAsyncInterruptTransfer (
940 IN EFI_USB2_HC_PROTOCOL
* This
,
941 IN UINT8 DeviceAddress
,
942 IN UINT8 EndPointAddress
,
943 IN UINT8 DeviceSpeed
,
944 IN UINTN MaximumPacketLength
,
945 IN BOOLEAN IsNewTransfer
,
946 IN OUT UINT8
*DataToggle
,
947 IN UINTN PollingInterval
,
949 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
* Translator
,
950 IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction
,
951 IN VOID
*Context OPTIONAL
961 // Validate parameters
963 if (!EHCI_IS_DATAIN (EndPointAddress
)) {
964 return EFI_INVALID_PARAMETER
;
968 if (DataLength
== 0) {
969 return EFI_INVALID_PARAMETER
;
972 if ((*DataToggle
!= 1) && (*DataToggle
!= 0)) {
973 return EFI_INVALID_PARAMETER
;
976 if ((PollingInterval
> 255) || (PollingInterval
< 1)) {
977 return EFI_INVALID_PARAMETER
;
981 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
982 Ehc
= EHC_FROM_THIS (This
);
985 // Delete Async interrupt transfer request. DataToggle will return
986 // the next data toggle to use.
988 if (!IsNewTransfer
) {
989 Status
= EhciDelAsyncIntTransfer (Ehc
, DeviceAddress
, EndPointAddress
, DataToggle
);
991 EHC_DEBUG (("EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status
));
995 Status
= EFI_SUCCESS
;
997 if (EhcIsHalt (Ehc
) || EhcIsSysError (Ehc
)) {
998 EHC_ERROR (("EhcAsyncInterruptTransfer: HC is halt\n"));
999 EhcAckAllInterrupt (Ehc
);
1001 Status
= EFI_DEVICE_ERROR
;
1005 EhcAckAllInterrupt (Ehc
);
1007 Data
= AllocatePool (DataLength
);
1010 EHC_ERROR (("EhcAsyncInterruptTransfer: failed to allocate buffer\n"));
1012 Status
= EFI_OUT_OF_RESOURCES
;
1016 Urb
= EhcCreateUrb (
1022 MaximumPacketLength
,
1024 EHC_INT_TRANSFER_ASYNC
,
1034 EHC_ERROR (("EhcAsyncInterruptTransfer: failed to create URB\n"));
1036 gBS
->FreePool (Data
);
1037 Status
= EFI_OUT_OF_RESOURCES
;
1042 // New asynchronous transfer must inserted to the head.
1043 // Check the comments in EhcMoniteAsyncRequests
1045 EhcLinkQhToPeriod (Ehc
, Urb
->Qh
);
1046 InsertHeadList (&Ehc
->AsyncIntTransfers
, &Urb
->UrbList
);
1049 Ehc
->PciIo
->Flush (Ehc
->PciIo
);
1050 gBS
->RestoreTPL (OldTpl
);
1057 Submits synchronous interrupt transfer to an interrupt endpoint
1060 @param This This EFI_USB2_HC_PROTOCOL instance.
1061 @param DeviceAddress Target device address
1062 @param EndPointAddress Endpoint number and its direction encoded in bit 7
1063 @param DeviceSpeed Indicates device speed.
1064 @param MaximumPacketLength Maximum packet size the target endpoint is capable
1065 of sending or receiving.
1066 @param Data Buffer of data that will be transmitted to USB
1067 device or received from USB device.
1068 @param DataLength On input, the size, in bytes, of the data buffer; On
1069 output, the number of bytes transferred.
1070 @param DataToggle On input, the initial data toggle to use; on output,
1071 it is updated to indicate the next data toggle
1072 @param TimeOut Maximum time, in second, to complete
1073 @param Translator Transaction translator to use.
1074 @param TransferResult Variable to receive the transfer result
1076 @return EFI_SUCCESS : The transfer was completed successfully.
1077 @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resource.
1078 @return EFI_INVALID_PARAMETER : Some parameters are invalid.
1079 @return EFI_TIMEOUT : The transfer failed due to timeout.
1080 @return EFI_DEVICE_ERROR : The failed due to host controller or device error
1086 EhcSyncInterruptTransfer (
1087 IN EFI_USB2_HC_PROTOCOL
*This
,
1088 IN UINT8 DeviceAddress
,
1089 IN UINT8 EndPointAddress
,
1090 IN UINT8 DeviceSpeed
,
1091 IN UINTN MaximumPacketLength
,
1093 IN OUT UINTN
*DataLength
,
1094 IN OUT UINT8
*DataToggle
,
1096 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1097 OUT UINT32
*TransferResult
1106 // Validates parameters
1108 if ((DataLength
== NULL
) || (*DataLength
== 0) ||
1109 (Data
== NULL
) || (TransferResult
== NULL
)) {
1110 return EFI_INVALID_PARAMETER
;
1113 if (!EHCI_IS_DATAIN (EndPointAddress
)) {
1114 return EFI_INVALID_PARAMETER
;
1117 if ((*DataToggle
!= 1) && (*DataToggle
!= 0)) {
1118 return EFI_INVALID_PARAMETER
;
1121 if (((DeviceSpeed
== EFI_USB_SPEED_LOW
) && (MaximumPacketLength
!= 8)) ||
1122 ((DeviceSpeed
== EFI_USB_SPEED_FULL
) && (MaximumPacketLength
> 64)) ||
1123 ((DeviceSpeed
== EFI_USB_SPEED_HIGH
) && (MaximumPacketLength
> 3072))) {
1124 return EFI_INVALID_PARAMETER
;
1127 OldTpl
= gBS
->RaiseTPL (EHC_TPL
);
1128 Ehc
= EHC_FROM_THIS (This
);
1130 *TransferResult
= EFI_USB_ERR_SYSTEM
;
1131 Status
= EFI_DEVICE_ERROR
;
1133 if (EhcIsHalt (Ehc
) || EhcIsSysError (Ehc
)) {
1134 EHC_ERROR (("EhcSyncInterruptTransfer: HC is halt\n"));
1136 EhcAckAllInterrupt (Ehc
);
1140 EhcAckAllInterrupt (Ehc
);
1142 Urb
= EhcCreateUrb (
1148 MaximumPacketLength
,
1150 EHC_INT_TRANSFER_SYNC
,
1160 EHC_ERROR (("EhcSyncInterruptTransfer: failed to create URB\n"));
1162 Status
= EFI_OUT_OF_RESOURCES
;
1166 EhcLinkQhToPeriod (Ehc
, Urb
->Qh
);
1167 Status
= EhcExecTransfer (Ehc
, Urb
, TimeOut
);
1168 EhcUnlinkQhFromPeriod (Ehc
, Urb
->Qh
);
1170 *TransferResult
= Urb
->Result
;
1171 *DataLength
= Urb
->Completed
;
1172 *DataToggle
= Urb
->DataToggle
;
1174 if (*TransferResult
== EFI_USB_NOERROR
) {
1175 Status
= EFI_SUCCESS
;
1179 Ehc
->PciIo
->Flush (Ehc
->PciIo
);
1180 gBS
->RestoreTPL (OldTpl
);
1182 if (EFI_ERROR (Status
)) {
1183 EHC_ERROR (("EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status
, *TransferResult
));
1191 Submits isochronous transfer to a target USB device.
1193 @param This This EFI_USB2_HC_PROTOCOL instance.
1194 @param DeviceAddress Target device address
1195 @param EndPointAddress End point address with its direction
1196 @param DeviceSpeed Device speed, Low speed device doesn't support this
1198 @param MaximumPacketLength Maximum packet size that the endpoint is capable of
1199 sending or receiving.
1200 @param DataBuffersNumber Number of data buffers prepared for the transfer.
1201 @param Data Array of pointers to the buffers of data that will
1202 be transmitted to USB device or received from USB
1204 @param DataLength The size, in bytes, of the data buffer
1205 @param Translator Transaction translator to use.
1206 @param TransferResult Variable to receive the transfer result
1208 @return EFI_UNSUPPORTED : Isochronous transfer is unsupported.
1214 EhcIsochronousTransfer (
1215 IN EFI_USB2_HC_PROTOCOL
*This
,
1216 IN UINT8 DeviceAddress
,
1217 IN UINT8 EndPointAddress
,
1218 IN UINT8 DeviceSpeed
,
1219 IN UINTN MaximumPacketLength
,
1220 IN UINT8 DataBuffersNumber
,
1221 IN OUT VOID
*Data
[EFI_USB_MAX_ISO_BUFFER_NUM
],
1222 IN UINTN DataLength
,
1223 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1224 OUT UINT32
*TransferResult
1227 return EFI_UNSUPPORTED
;
1232 Submits Async isochronous transfer to a target USB device.
1234 @param This This EFI_USB2_HC_PROTOCOL instance.
1235 @param DeviceAddress Target device address
1236 @param EndPointAddress End point address with its direction
1237 @param DeviceSpeed Device speed, Low speed device doesn't support this
1239 @param MaximumPacketLength Maximum packet size that the endpoint is capable of
1240 sending or receiving.
1241 @param DataBuffersNumber Number of data buffers prepared for the transfer.
1242 @param Data Array of pointers to the buffers of data that will
1243 be transmitted to USB device or received from USB
1245 @param DataLength The size, in bytes, of the data buffer
1246 @param Translator Transaction translator to use.
1247 @param IsochronousCallBack Function to be called when the transfer complete
1248 @param Context Context passed to the call back function as
1251 @return EFI_UNSUPPORTED : Isochronous transfer isn't supported
1257 EhcAsyncIsochronousTransfer (
1258 IN EFI_USB2_HC_PROTOCOL
*This
,
1259 IN UINT8 DeviceAddress
,
1260 IN UINT8 EndPointAddress
,
1261 IN UINT8 DeviceSpeed
,
1262 IN UINTN MaximumPacketLength
,
1263 IN UINT8 DataBuffersNumber
,
1264 IN OUT VOID
*Data
[EFI_USB_MAX_ISO_BUFFER_NUM
],
1265 IN UINTN DataLength
,
1266 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1267 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack
,
1271 return EFI_UNSUPPORTED
;
1276 EhcDriverEntryPoint (
1277 IN EFI_HANDLE ImageHandle
,
1278 IN EFI_SYSTEM_TABLE
*SystemTable
1282 Routine Description:
1284 Entry point for EFI drivers.
1288 ImageHandle - EFI_HANDLE
1289 SystemTable - EFI_SYSTEM_TABLE
1294 EFI_DEVICE_ERROR Fail
1298 return EfiLibInstallAllDriverProtocols (
1301 &gEhciDriverBinding
,
1303 &gEhciComponentName
,
1311 Test to see if this driver supports ControllerHandle. Any
1312 ControllerHandle that has Usb2HcProtocol installed will
1315 @param This Protocol instance pointer.
1316 @param Controlle Handle of device to test
1317 @param RemainingDevicePath Not used
1319 @return EFI_SUCCESS : This driver supports this device.
1320 @return EFI_UNSUPPORTED : This driver does not support this device.
1325 EhcDriverBindingSupported (
1326 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1327 IN EFI_HANDLE Controller
,
1328 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1332 EFI_PCI_IO_PROTOCOL
*PciIo
;
1333 USB_CLASSC UsbClassCReg
;
1336 // Test whether there is PCI IO Protocol attached on the controller handle.
1338 Status
= gBS
->OpenProtocol (
1340 &gEfiPciIoProtocolGuid
,
1342 This
->DriverBindingHandle
,
1344 EFI_OPEN_PROTOCOL_BY_DRIVER
1347 if (EFI_ERROR (Status
)) {
1348 return EFI_UNSUPPORTED
;
1351 Status
= PciIo
->Pci
.Read (
1355 sizeof (USB_CLASSC
) / sizeof (UINT8
),
1359 if (EFI_ERROR (Status
)) {
1360 Status
= EFI_UNSUPPORTED
;
1365 // Test whether the controller belongs to Ehci type
1367 if ((UsbClassCReg
.BaseCode
!= PCI_CLASS_SERIAL
) ||
1368 (UsbClassCReg
.SubClassCode
!= PCI_CLASS_SERIAL_USB
) ||
1369 (UsbClassCReg
.PI
!= EHC_PCI_CLASSC_PI
)) {
1371 Status
= EFI_UNSUPPORTED
;
1375 gBS
->CloseProtocol (
1377 &gEfiPciIoProtocolGuid
,
1378 This
->DriverBindingHandle
,
1387 Create and initialize a USB2_HC_DEV
1389 @param PciIo The PciIo on this device
1391 @return The allocated and initialized USB2_HC_DEV structure
1392 @return if created, otherwise NULL.
1398 IN EFI_PCI_IO_PROTOCOL
*PciIo
1404 Ehc
= AllocateZeroPool (sizeof (USB2_HC_DEV
));
1411 // Init EFI_USB2_HC_PROTOCOL interface and private data structure
1413 Ehc
->Signature
= USB2_HC_DEV_SIGNATURE
;
1415 Ehc
->Usb2Hc
.GetCapability
= EhcGetCapability
;
1416 Ehc
->Usb2Hc
.Reset
= EhcReset
;
1417 Ehc
->Usb2Hc
.GetState
= EhcGetState
;
1418 Ehc
->Usb2Hc
.SetState
= EhcSetState
;
1419 Ehc
->Usb2Hc
.ControlTransfer
= EhcControlTransfer
;
1420 Ehc
->Usb2Hc
.BulkTransfer
= EhcBulkTransfer
;
1421 Ehc
->Usb2Hc
.AsyncInterruptTransfer
= EhcAsyncInterruptTransfer
;
1422 Ehc
->Usb2Hc
.SyncInterruptTransfer
= EhcSyncInterruptTransfer
;
1423 Ehc
->Usb2Hc
.IsochronousTransfer
= EhcIsochronousTransfer
;
1424 Ehc
->Usb2Hc
.AsyncIsochronousTransfer
= EhcAsyncIsochronousTransfer
;
1425 Ehc
->Usb2Hc
.GetRootHubPortStatus
= EhcGetRootHubPortStatus
;
1426 Ehc
->Usb2Hc
.SetRootHubPortFeature
= EhcSetRootHubPortFeature
;
1427 Ehc
->Usb2Hc
.ClearRootHubPortFeature
= EhcClearRootHubPortFeature
;
1428 Ehc
->Usb2Hc
.MajorRevision
= 0x1;
1429 Ehc
->Usb2Hc
.MinorRevision
= 0x1;
1433 InitializeListHead (&Ehc
->AsyncIntTransfers
);
1435 Ehc
->HcStructParams
= EhcReadCapRegister (Ehc
, EHC_HCSPARAMS_OFFSET
);
1436 Ehc
->HcCapParams
= EhcReadCapRegister (Ehc
, EHC_HCCPARAMS_OFFSET
);
1437 Ehc
->CapLen
= EhcReadCapRegister (Ehc
, EHC_CAPLENGTH_OFFSET
) & 0x0FF;
1439 EHC_DEBUG (("EhcCreateUsb2Hc: capability length %d\n", Ehc
->CapLen
));
1442 // Create AsyncRequest Polling Timer
1444 Status
= gBS
->CreateEvent (
1445 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1447 EhcMoniteAsyncRequests
,
1452 if (EFI_ERROR (Status
)) {
1453 gBS
->FreePool (Ehc
);
1462 Starting the Usb EHCI Driver
1464 @param This Protocol instance pointer.
1465 @param Controller Handle of device to test
1466 @param RemainingDevicePath Not used
1468 @return EFI_SUCCESS : supports this device.
1469 @return EFI_UNSUPPORTED : do not support this device.
1470 @return EFI_DEVICE_ERROR : cannot be started due to device Error
1471 @return EFI_OUT_OF_RESOURCES : cannot allocate resources
1476 EhcDriverBindingStart (
1477 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1478 IN EFI_HANDLE Controller
,
1479 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1484 EFI_PCI_IO_PROTOCOL
*PciIo
;
1487 // Open the PciIo Protocol, then enable the USB host controller
1489 Status
= gBS
->OpenProtocol (
1491 &gEfiPciIoProtocolGuid
,
1493 This
->DriverBindingHandle
,
1495 EFI_OPEN_PROTOCOL_BY_DRIVER
1498 if (EFI_ERROR (Status
)) {
1499 EHC_ERROR (("EhcDriverBindingStart: failed to open PCI_IO\n"));
1500 return EFI_DEVICE_ERROR
;
1503 Status
= PciIo
->Attributes (
1505 EfiPciIoAttributeOperationEnable
,
1506 EFI_PCI_DEVICE_ENABLE
,
1510 if (EFI_ERROR (Status
)) {
1511 EHC_ERROR (("EhcDriverBindingStart: failed to enable controller\n"));
1516 // Create then install USB2_HC_PROTOCOL
1518 Ehc
= EhcCreateUsb2Hc (PciIo
);
1521 EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));
1523 Status
= EFI_OUT_OF_RESOURCES
;
1527 Status
= gBS
->InstallProtocolInterface (
1529 &gEfiUsb2HcProtocolGuid
,
1530 EFI_NATIVE_INTERFACE
,
1534 if (EFI_ERROR (Status
)) {
1535 EHC_ERROR (("EhcDriverBindingStart: failed to install USB2_HC Protocol\n"));
1540 // Robustnesss improvement such as for UoL
1542 EhcClearLegacySupport (Ehc
);
1543 EhcResetHC (Ehc
, EHC_STALL_1_SECOND
);
1545 Status
= EhcInitHC (Ehc
);
1547 if (EFI_ERROR (Status
)) {
1548 EHC_ERROR (("EhcDriverBindingStart: failed to init host controller\n"));
1549 goto UNINSTALL_USBHC
;
1553 // Start the asynchronous interrupt monitor
1555 Status
= gBS
->SetTimer (Ehc
->PollTimer
, TimerPeriodic
, EHC_ASYNC_POLL_TIME
);
1557 if (EFI_ERROR (Status
)) {
1558 EHC_ERROR (("EhcDriverBindingStart: failed to start async interrupt monitor\n"));
1560 EhcHaltHC (Ehc
, EHC_GENERIC_TIME
);
1561 goto UNINSTALL_USBHC
;
1565 // Install the component name protocol, don't fail the start
1566 // because of something for display.
1570 gEhciComponentName
.SupportedLanguages
,
1571 &Ehc
->ControllerNameTable
,
1572 L
"Enhanced Host Controller (USB 2.0)"
1575 EHC_DEBUG (("EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller
));
1579 gBS
->UninstallProtocolInterface (
1581 &gEfiUsb2HcProtocolGuid
,
1587 gBS
->CloseEvent (Ehc
->PollTimer
);
1588 gBS
->FreePool (Ehc
);
1591 gBS
->CloseProtocol (
1593 &gEfiPciIoProtocolGuid
,
1594 This
->DriverBindingHandle
,
1603 Stop this driver on ControllerHandle. Support stoping any child handles
1604 created by this driver.
1606 @param This Protocol instance pointer.
1607 @param Controller Handle of device to stop driver on
1608 @param NumberOfChildren Number of Children in the ChildHandleBuffer
1609 @param ChildHandleBuffer List of handles for the children we need to stop.
1611 @return EFI_SUCCESS Success
1612 @return EFI_DEVICE_ERROR Fail
1617 EhcDriverBindingStop (
1618 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1619 IN EFI_HANDLE Controller
,
1620 IN UINTN NumberOfChildren
,
1621 IN EFI_HANDLE
*ChildHandleBuffer
1625 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
1626 EFI_PCI_IO_PROTOCOL
*PciIo
;
1630 // Test whether the Controller handler passed in is a valid
1631 // Usb controller handle that should be supported, if not,
1632 // return the error status directly
1634 Status
= gBS
->OpenProtocol (
1636 &gEfiUsb2HcProtocolGuid
,
1638 This
->DriverBindingHandle
,
1640 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1643 if (EFI_ERROR (Status
)) {
1647 Ehc
= EHC_FROM_THIS (Usb2Hc
);
1651 // Stop AsyncRequest Polling timer then stop the EHCI driver
1652 // and uninstall the EHCI protocl.
1654 gBS
->SetTimer (Ehc
->PollTimer
, TimerCancel
, EHC_ASYNC_POLL_TIME
);
1655 EhcHaltHC (Ehc
, EHC_GENERIC_TIME
);
1657 Status
= gBS
->UninstallProtocolInterface (
1659 &gEfiUsb2HcProtocolGuid
,
1663 if (EFI_ERROR (Status
)) {
1667 if (Ehc
->PollTimer
!= NULL
) {
1668 gBS
->CloseEvent (Ehc
->PollTimer
);
1673 if (Ehc
->ControllerNameTable
) {
1674 FreeUnicodeStringTable (Ehc
->ControllerNameTable
);
1678 // Disable the USB Host Controller
1682 EfiPciIoAttributeOperationDisable
,
1683 EFI_PCI_DEVICE_ENABLE
,
1687 gBS
->CloseProtocol (
1689 &gEfiPciIoProtocolGuid
,
1690 This
->DriverBindingHandle
,
1694 gBS
->FreePool (Ehc
);
1698 EFI_DRIVER_BINDING_PROTOCOL
1699 gEhciDriverBinding
= {
1700 EhcDriverBindingSupported
,
1701 EhcDriverBindingStart
,
1702 EhcDriverBindingStop
,