17#include <IndustryStandard/Pci.h>
19#include <Protocol/PciIo.h>
21#include <Library/BaseMemoryLib.h>
22#include <Library/DebugLib.h>
23#include <Library/IoLib.h>
24#include <Library/UefiBootServicesTableLib.h>
40 IN EFI_PCI_IO_PROTOCOL *PciIo
54 Status = PciIo->Mem.Read (
63 ExtendCap = EFI_ERROR (Status) ? 0 : ((HcCapParams >> 14U) & 0x3FFFCU);
66 Status = PciIo->Mem.Read (
75 if (EFI_ERROR (Status)) {
83 if (!(Value & BIT16)) {
102 Status = PciIo->Mem.Read (
111 if (EFI_ERROR (Status) || !(Value & BIT16)) {
119 Status = PciIo->Mem.Read (
128 if (EFI_ERROR (Status)) {
133 Value |= 0xE0000000U;
147 Status = PciIo->Mem.Read (
156 if (EFI_ERROR (Status)) {
160 Value &= ~(BIT24 | BIT16);
177 ExtendCap += ((Value >> 6U) & 0x3FCU);
194 IN EFI_PCI_IO_PROTOCOL *PciIo
207 BOOLEAN IsOwnershipConflict;
212 Status = EFI_SUCCESS;
236 return EFI_NOT_FOUND;
253 ExtendCap = (HcCapParams >> 8U) & 0xFFU;
266 IsBiosOwned = (UsbLegSup & BIT16) != 0;
271 return EFI_NOT_FOUND;
288 UsbLegCtlSts &= 0xFFFF0000U;
302 UsbCmd = UsbCmd & 0xFFFFFF00U;
327 IsBiosOwned = (UsbLegSup & BIT16) != 0;
328 IsOsOwned = (UsbLegSup & BIT24) != 0;
352 IsOwnershipConflict = IsBiosOwned && IsOsOwned;
354 if (IsOwnershipConflict) {
379 if ((Value & BIT24) == 0x0) {
414 if ((Value & BIT16) == 0x0) {
419 IsOwnershipConflict = (Value & BIT16) != 0x0;
420 if (IsOwnershipConflict) {
445 if ((Value & BIT16) == 0x0) {
461 UsbLegCtlSts &= 0xFFFF0000U;
475 Status = EFI_NOT_FOUND;
492 IN EFI_PCI_IO_PROTOCOL *PciIo
510 PortBase = (Base >> 5) & 0x07ff;
514 Status = PciIo->Pci.Write (
522 if ((PortBase != 0) && ((PortBase & BIT0) == 0)) {
523 IoWrite16 (PortBase, 0x0002);
525 IoWrite16 (PortBase + 4, 0);
527 IoWrite16 (PortBase, 0);
540 EFI_HANDLE *HandleArray;
541 UINTN HandleArrayCount;
543 EFI_PCI_IO_PROTOCOL *PciIo;
546 Status =
gBS->LocateHandleBuffer (
548 &gEfiPciIoProtocolGuid,
554 if (EFI_ERROR (Status)) {
558 Result = EFI_UNSUPPORTED;
560 for (Index = 0; Index < HandleArrayCount; ++Index) {
561 Status =
gBS->HandleProtocol (
563 &gEfiPciIoProtocolGuid,
567 if (EFI_ERROR (Status)) {
571 Status = PciIo->Pci.Read (
575 sizeof (Pci) /
sizeof (UINT32),
579 if ( EFI_ERROR (Status)
580 || (Pci.Hdr.ClassCode[1] != PCI_CLASS_SERIAL_USB)
581 || (Pci.Hdr.ClassCode[2] != PCI_CLASS_SERIAL))
586 if (Pci.Hdr.ClassCode[0] == PCI_IF_XHCI) {
588 }
else if (Pci.Hdr.ClassCode[0] == PCI_IF_EHCI) {
590 }
else if (Pci.Hdr.ClassCode[0] == PCI_IF_UHCI) {
595 gBS->FreePool (HandleArray);
UINT8 Command[7]
Actual command for the Command Page.
#define EHC_USBINT_OFFSET
USB Interrupt Enable Register.
#define XHC_NEXT_CAPABILITY_MASK
#define XHC_CAPABILITY_ID_MASK
#define EHC_HCCPARAMS_OFFSET
#define XHC_USBCMD_OFFSET
USB Command Register Offset.
#define EHC_USBSTS_OFFSET
USB Status Register Offset.
#define XHC_HCCPARAMS_OFFSET
#define EHC_USBCMD_OFFSET
USB Command Register Offset.
STATIC EFI_STATUS XhciReleaseOwnership(IN EFI_PCI_IO_PROTOCOL *PciIo)
STATIC EFI_STATUS UhciReleaseOwnership(IN EFI_PCI_IO_PROTOCOL *PciIo)
STATIC EFI_STATUS EhciReleaseOwnership(IN EFI_PCI_IO_PROTOCOL *PciIo)
EFI_STATUS ReleaseUsbOwnership(VOID)
UINT8 EFIAPI MmioRead8(IN UINTN Address)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)