summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Bus/Pci/Uhci
diff options
context:
space:
mode:
authorljin6 <ljin6@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-18 04:13:40 +0000
committerljin6 <ljin6@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-18 04:13:40 +0000
commit562d28495df348923812281161e64bc9514e15e6 (patch)
tree121f4f3c37c23b23a4dabe21cf4fc46c78a0c5b3 /EdkModulePkg/Bus/Pci/Uhci
parent4b9fc76f7bba0d847d36cb2070a2d3305ae87acc (diff)
downloadedk2-562d28495df348923812281161e64bc9514e15e6.zip
edk2-562d28495df348923812281161e64bc9514e15e6.tar.gz
edk2-562d28495df348923812281161e64bc9514e15e6.tar.bz2
Add DevicePathUtilities DevicePathToText DevciePathFromText USB2HostController protocols
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1037 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Bus/Pci/Uhci')
-rw-r--r--EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.msa3
-rw-r--r--EdkModulePkg/Bus/Pci/Uhci/Dxe/uhchlp.c148
-rw-r--r--EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c1577
-rw-r--r--EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.h1733
4 files changed, 2986 insertions, 475 deletions
diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.msa b/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.msa
index 66a41d9..3d24744 100644
--- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.msa
+++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.msa
@@ -71,6 +71,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
<Protocol Usage="BY_START">
<ProtocolCName>gEfiUsbHcProtocolGuid</ProtocolCName>
</Protocol>
+ <Protocol Usage="BY_START">
+ <ProtocolCName>gEfiUsb2HcProtocolGuid</ProtocolCName>
+ </Protocol>
</Protocols>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhchlp.c b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhchlp.c
index 62d58ee..74ddc6b 100644
--- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhchlp.c
+++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhchlp.c
@@ -49,13 +49,13 @@ Returns:
// Perform 16bit Read in PCI IO Space
//
return PciIo->Io.Read (
- PciIo,
- EfiPciIoWidthUint16,
- USB_BAR_INDEX,
- (UINT64) PortOffset,
- 1,
- Data
- );
+ PciIo,
+ EfiPciIoWidthUint16,
+ USB_BAR_INDEX,
+ (UINT64) PortOffset,
+ 1,
+ Data
+ );
}
EFI_STATUS
@@ -86,13 +86,13 @@ Returns:
// Perform 32bit Read in PCI IO Space
//
return PciIo->Io.Read (
- PciIo,
- EfiPciIoWidthUint32,
- USB_BAR_INDEX,
- (UINT64) PortOffset,
- 1,
- Data
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ USB_BAR_INDEX,
+ (UINT64) PortOffset,
+ 1,
+ Data
+ );
}
EFI_STATUS
@@ -123,13 +123,13 @@ Returns:
// Perform 16bit Write in PCI IO Space
//
return PciIo->Io.Write (
- PciIo,
- EfiPciIoWidthUint16,
- USB_BAR_INDEX,
- (UINT64) PortOffset,
- 1,
- &Data
- );
+ PciIo,
+ EfiPciIoWidthUint16,
+ USB_BAR_INDEX,
+ (UINT64) PortOffset,
+ 1,
+ &Data
+ );
}
EFI_STATUS
@@ -160,13 +160,13 @@ Returns:
// Perform 32bit Write in PCI IO Space
//
return PciIo->Io.Write (
- PciIo,
- EfiPciIoWidthUint32,
- USB_BAR_INDEX,
- (UINT64) PortOffset,
- 1,
- &Data
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ USB_BAR_INDEX,
+ (UINT64) PortOffset,
+ 1,
+ &Data
+ );
}
//
// USB register-base helper functions
@@ -657,10 +657,10 @@ Returns:
EFI_STATUS Status;
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- (UINT32) (USBCMD),
- &CommandContent
- );
+ HcDev->PciIo,
+ (UINT32) (USBCMD),
+ &CommandContent
+ );
if ((CommandContent & USBCMD_MAXP) != USBCMD_MAXP) {
CommandContent |= USBCMD_MAXP;
@@ -715,25 +715,25 @@ Returns:
BufferSizeInBytes = 4096;
BufferSizeInPages = EFI_SIZE_TO_PAGES (BufferSizeInBytes);
Status = HcDev->PciIo->AllocateBuffer (
- HcDev->PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- BufferSizeInPages,
- &CommonBuffer,
- 0
- );
+ HcDev->PciIo,
+ AllocateAnyPages,
+ EfiBootServicesData,
+ BufferSizeInPages,
+ &CommonBuffer,
+ 0
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterCommonBuffer,
- CommonBuffer,
- &BufferSizeInBytes,
- &MappedAddress,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterCommonBuffer,
+ CommonBuffer,
+ &BufferSizeInBytes,
+ &MappedAddress,
+ &Mapping
+ );
if (EFI_ERROR (Status) || (BufferSizeInBytes != 4096)) {
HcDev->PciIo->FreeBuffer (HcDev->PciIo, BufferSizeInPages, CommonBuffer);
return EFI_UNSUPPORTED;
@@ -3589,13 +3589,13 @@ Returns:
// and it is allocated as common buffer use.
//
Status = HcDev->PciIo->AllocateBuffer (
- HcDev->PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- MemoryBlockSizeInPages,
- &CommonBuffer,
- 0
- );
+ HcDev->PciIo,
+ AllocateAnyPages,
+ EfiBootServicesData,
+ MemoryBlockSizeInPages,
+ &CommonBuffer,
+ 0
+ );
if (EFI_ERROR (Status)) {
gBS->FreePool ((*MemoryHeader)->BitArrayPtr);
gBS->FreePool (*MemoryHeader);
@@ -3604,13 +3604,13 @@ Returns:
MemoryBlockSizeInBytes = EFI_PAGES_TO_SIZE (MemoryBlockSizeInPages);
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterCommonBuffer,
- CommonBuffer,
- &MemoryBlockSizeInBytes,
- &MappedAddress,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterCommonBuffer,
+ CommonBuffer,
+ &MemoryBlockSizeInBytes,
+ &MappedAddress,
+ &Mapping
+ );
//
// if returned Mapped size is less than the size we request,do not support.
//
@@ -3741,10 +3741,10 @@ Returns:
TempHeaderPtr = TempHeaderPtr->Next) {
Status = AllocMemInMemoryBlock (
- TempHeaderPtr,
- (VOID **) Pool,
- RealAllocSize / 32
- );
+ TempHeaderPtr,
+ (VOID **) Pool,
+ RealAllocSize / 32
+ );
if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize);
return EFI_SUCCESS;
@@ -3777,10 +3777,10 @@ Returns:
InsertMemoryHeaderToList (MemoryHeader, NewMemoryHeader);
Status = AllocMemInMemoryBlock (
- NewMemoryHeader,
- (VOID **) Pool,
- RealAllocSize / 32
- );
+ NewMemoryHeader,
+ (VOID **) Pool,
+ RealAllocSize / 32
+ );
if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize);
@@ -4226,12 +4226,12 @@ TurnOffUSBEmulation (
//
Command = 0;
PciIo->Pci.Write (
- PciIo,
- EfiPciIoWidthUint16,
- USB_EMULATION,
- 1,
- &Command
- );
+ PciIo,
+ EfiPciIoWidthUint16,
+ USB_EMULATION,
+ 1,
+ &Command
+ );
return ;
}
diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c
index 1eba8be..14f8bf2 100644
--- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c
+++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c
@@ -28,13 +28,6 @@ Revision History
EFI_STATUS
EFIAPI
-UHCIDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-EFI_STATUS
-EFIAPI
UHCIDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
@@ -119,7 +112,7 @@ UHCIAsyncInterruptTransfer (
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN BOOLEAN IsSlowDevice,
- IN UINT8 MaxiumPacketLength,
+ IN UINT8 MaximumPacketLength,
IN BOOLEAN IsNewTransfer,
IN OUT UINT8 *DataToggle,
IN UINTN PollingInterval, OPTIONAL
@@ -200,6 +193,161 @@ UHCIClearRootHubPortFeature (
);
//
+// UEFI 2.0 Protocol
+//
+
+EFI_STATUS
+EFIAPI
+UHCI2GetCapability(
+ IN EFI_USB2_HC_PROTOCOL * This,
+ OUT UINT8 *MaxSpeed,
+ OUT UINT8 *PortNumber,
+ OUT UINT8 *Is64BitCapable
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2Reset (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT16 Attributes
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2GetState (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ OUT EFI_USB_HC_STATE * State
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2SetState (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN EFI_USB_HC_STATE State
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2ControlTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN EFI_USB_DEVICE_REQUEST * Request,
+ IN EFI_USB_DATA_DIRECTION TransferDirection,
+ IN OUT VOID *Data, OPTIONAL
+ IN OUT UINTN *DataLength, OPTIONAL
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2BulkTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2AsyncInterruptTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN BOOLEAN IsNewTransfer,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN PollingInterval, OPTIONAL
+ IN UINTN DataLength, OPTIONAL
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction, OPTIONAL
+ IN VOID *Context OPTIONAL
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2SyncInterruptTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2IsochronousTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2AsyncIsochronousTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
+ IN VOID *Context OPTIONAL
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2GetRootHubPortStatus (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ OUT EFI_USB_PORT_STATUS * PortStatus
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2SetRootHubPortFeature (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+EFI_STATUS
+EFIAPI
+UHCI2ClearRootHubPortFeature (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+//
// Asynchronous interrupt transfer monitor function
//
VOID
@@ -236,7 +384,7 @@ UHCIDriverBindingSupported (
Arguments:
This - Protocol instance pointer.
- Controller, - Handle of device to test
+ Controller - Handle of device to test
RemainingDevicePath - Not used
Returns:
@@ -289,20 +437,20 @@ UHCIDriverBindingSupported (
(UsbClassCReg.PI != PCI_CLASSC_PI_UHCI)) {
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_UNSUPPORTED;
}
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -351,6 +499,7 @@ UHCIDriverBindingStart (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Turn off USB emulation
//
@@ -367,11 +516,11 @@ UHCIDriverBindingStart (
);
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_UNSUPPORTED;
}
@@ -381,14 +530,14 @@ UHCIDriverBindingStart (
HcDev = AllocateZeroPool (sizeof (USB_HC_DEV));
if (HcDev == NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_OUT_OF_RESOURCES;
}
-
+
//
// init EFI_USB_HC_PROTOCOL protocol interface and install the protocol
//
@@ -410,6 +559,27 @@ UHCIDriverBindingStart (
HcDev->UsbHc.MinorRevision = 0x1;
//
+ //
+ // init EFI_USB2_HC_PROTOCOL protocol interface and install the protocol
+ //
+ HcDev->Usb2Hc.GetCapability = UHCI2GetCapability;
+ HcDev->Usb2Hc.Reset = UHCI2Reset;
+ HcDev->Usb2Hc.GetState = UHCI2GetState;
+ HcDev->Usb2Hc.SetState = UHCI2SetState;
+ HcDev->Usb2Hc.ControlTransfer = UHCI2ControlTransfer;
+ HcDev->Usb2Hc.BulkTransfer = UHCI2BulkTransfer;
+ HcDev->Usb2Hc.AsyncInterruptTransfer = UHCI2AsyncInterruptTransfer;
+ HcDev->Usb2Hc.SyncInterruptTransfer = UHCI2SyncInterruptTransfer;
+ HcDev->Usb2Hc.IsochronousTransfer = UHCI2IsochronousTransfer;
+ HcDev->Usb2Hc.AsyncIsochronousTransfer = UHCI2AsyncIsochronousTransfer;
+ HcDev->Usb2Hc.GetRootHubPortStatus = UHCI2GetRootHubPortStatus;
+ HcDev->Usb2Hc.SetRootHubPortFeature = UHCI2SetRootHubPortFeature;
+ HcDev->Usb2Hc.ClearRootHubPortFeature = UHCI2ClearRootHubPortFeature;
+
+ HcDev->Usb2Hc.MajorRevision = 0x1;
+ HcDev->Usb2Hc.MinorRevision = 0x1;
+
+ //
// Init UHCI private data structures
//
HcDev->Signature = USB_HC_DEV_SIGNATURE;
@@ -428,14 +598,14 @@ UHCIDriverBindingStart (
}
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_OUT_OF_RESOURCES;
}
-
+
//
// Init interrupt list head in the HcDev structure.
//
@@ -460,11 +630,11 @@ UHCIDriverBindingStart (
}
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_UNSUPPORTED;
}
@@ -486,11 +656,11 @@ UHCIDriverBindingStart (
}
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_UNSUPPORTED;
}
@@ -518,7 +688,7 @@ UHCIDriverBindingStart (
);
return Status;
}
-
+
//
// Install Host Controller Protocol
//
@@ -538,17 +708,46 @@ UHCIDriverBindingStart (
}
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return Status;
+ }
+
+ //
+ // Install USB2.0 Host Controller Protocol
+ //
+ Status = gBS->InstallProtocolInterface (
+ &Controller,
+ &gEfiUsb2HcProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &HcDev->Usb2Hc
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->CloseEvent (HcDev->InterruptTransTimer);
+ FreeFrameListEntry (HcDev);
+ DelMemoryManagement (HcDev);
+
+ if (HcDev != NULL) {
+ gBS->FreePool (HcDev);
+ }
+
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
return Status;
}
//
// component name protocol.
//
+
HcDev->ControllerNameTable = NULL;
AddUnicodeString (
"eng",
@@ -582,12 +781,17 @@ UnInstallUHCInterface (
HcDev = USB_HC_DEV_FROM_THIS (This);
gBS->UninstallProtocolInterface (
- Controller,
- &gEfiUsbHcProtocolGuid,
- &HcDev->UsbHc
- );
-
- //
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ &HcDev->UsbHc
+ );
+
+ gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ &HcDev->Usb2Hc
+ );
+ //
// first stop USB Host Controller
//
This->SetState (This, EfiUsbHcStateHalt);
@@ -659,12 +863,31 @@ UHCIDriverBindingStop (
--*/
{
EFI_USB_HC_PROTOCOL *UsbHc;
+ EFI_USB2_HC_PROTOCOL *Usb2Hc;
EFI_STATUS OpenStatus;
OpenStatus = gBS->OpenProtocol (
Controller,
&gEfiUsbHcProtocolGuid,
- (VOID **) &UsbHc,
+ (VOID **)&UsbHc,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+
+ //
+ // Test whether the Controller handler passed in is a valid
+ // Usb controller handle that should be supported, if not,
+ // return the error status directly
+ //
+ if (EFI_ERROR (OpenStatus)) {
+ return OpenStatus;
+ }
+
+ OpenStatus = gBS->OpenProtocol (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ (VOID **) &Usb2Hc,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -684,11 +907,11 @@ UHCIDriverBindingStop (
UnInstallUHCInterface (Controller, UsbHc);
gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
@@ -753,20 +976,20 @@ UHCIReset (
// set the Global Reset bit in the command register
//
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Command |= USBCMD_GRESET;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -782,10 +1005,10 @@ UHCIReset (
//
Command &= ~USBCMD_GRESET;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -801,20 +1024,20 @@ UHCIReset (
// set Host Controller Reset bit to 1
//
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Command |= USBCMD_HCRESET;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -905,20 +1128,20 @@ UHCIGetState (
StatusRegAddr = (UINT32) (USBSTS);
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &UhcCommand
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &UhcCommand
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- StatusRegAddr,
- &UhcStatus
- );
+ HcDev->PciIo,
+ StatusRegAddr,
+ &UhcStatus
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -990,10 +1213,10 @@ UHCISetState (
}
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1001,10 +1224,10 @@ UHCISetState (
Command &= ~USBCMD_RS;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1033,20 +1256,20 @@ UHCISetState (
// Set Run/Stop bit to 1.
//
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Command |= USBCMD_RS | USBCMD_MAXP;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1055,10 +1278,10 @@ UHCISetState (
case EfiUsbHcStateSuspend:
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1115,20 +1338,20 @@ UHCISetState (
// Set Enter Global Suspend Mode bit to 1.
//
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Command |= USBCMD_EGSM;
Status = WriteUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1185,10 +1408,10 @@ UHCIGetRootHubPortNumber (
for (Index = 0; Index < 2; Index++) {
PSAddr = (UINT32) (USBPORTSC1 + Index * 2);
Status = ReadRootPortReg (
- HcDev->PciIo,
- PSAddr,
- &RHPortControl
- );
+ HcDev->PciIo,
+ PSAddr,
+ &RHPortControl
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1261,10 +1484,10 @@ UHCIGetRootHubPortStatus (
PortStatus->PortChangeStatus = 0;
Status = ReadRootPortReg (
- HcDev->PciIo,
- PSAddr,
- &RHPortStatus
- );
+ HcDev->PciIo,
+ PSAddr,
+ &RHPortStatus
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
@@ -1307,6 +1530,10 @@ UHCIGetRootHubPortStatus (
PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
}
//
+ // CHC will always return one in this bit
+ //
+ PortStatus->PortStatus |= USB_PORT_STAT_OWNER;
+ //
// Fill Port Status Change bits
//
@@ -1393,10 +1620,10 @@ UHCISetRootHubPortFeature (
case EfiUsbPortSuspend:
Status = ReadUHCCommandReg (
- HcDev->PciIo,
- CommandRegAddr,
- &Command
- );
+ HcDev->PciIo,
+ CommandRegAddr,
+ &Command
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1487,10 +1714,10 @@ UHCIClearRootHubPortFeature (
PSAddr = (UINT32) (USBPORTSC1 + PortNumber * 2);
Status = ReadRootPortReg (
- HcDev->PciIo,
- PSAddr,
- &RHPortControl
- );
+ HcDev->PciIo,
+ PSAddr,
+ &RHPortControl
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -1733,13 +1960,13 @@ UHCIControlTransfer (
// BusMasterWrite means cpu read
//
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterWrite,
- PtrDataSource,
- &DataLen,
- &TempPtr,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterWrite,
+ PtrDataSource,
+ &DataLen,
+ &TempPtr,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1757,13 +1984,13 @@ UHCIControlTransfer (
// BusMasterRead means cpu write
//
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterRead,
- PtrDataSource,
- &DataLen,
- &TempPtr,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterRead,
+ PtrDataSource,
+ &DataLen,
+ &TempPtr,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1809,13 +2036,13 @@ UHCIControlTransfer (
//
RequestLen = sizeof (EFI_USB_DEVICE_REQUEST);
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterRead,
- (UINT8 *) Request,
- &RequestLen,
- &TempPtr,
- &RequestMapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterRead,
+ (UINT8 *) Request,
+ &RequestLen,
+ &TempPtr,
+ &RequestMapping
+ );
if (EFI_ERROR (Status)) {
HcDev->PciIo->Unmap (HcDev->PciIo, Mapping);
@@ -1829,14 +2056,14 @@ UHCIControlTransfer (
// generate Setup Stage TD
//
Status = GenSetupStageTD (
- HcDev,
- DeviceAddress,
- 0,
- IsSlowDevice,
- (UINT8 *) RequestMappedAddress,
- sizeof (EFI_USB_DEVICE_REQUEST),
- &PtrSetupTD
- );
+ HcDev,
+ DeviceAddress,
+ 0,
+ IsSlowDevice,
+ (UINT8 *) RequestMappedAddress,
+ sizeof (EFI_USB_DEVICE_REQUEST),
+ &PtrSetupTD
+ );
if (EFI_ERROR (Status)) {
HcDev->PciIo->Unmap (HcDev->PciIo, Mapping);
@@ -1864,16 +2091,16 @@ UHCIControlTransfer (
}
Status = GenDataTD (
- HcDev,
- DeviceAddress,
- 0,
- Ptr,
- PktSize,
- PktID,
- DataToggle,
- IsSlowDevice,
- &PtrTD
- );
+ HcDev,
+ DeviceAddress,
+ 0,
+ Ptr,
+ PktSize,
+ PktID,
+ DataToggle,
+ IsSlowDevice,
+ &PtrTD
+ );
if (EFI_ERROR (Status)) {
//
@@ -1920,13 +2147,13 @@ UHCIControlTransfer (
// create Status Stage TD structure
//
Status = CreateStatusTD (
- HcDev,
- DeviceAddress,
- 0,
- PktID,
- IsSlowDevice,
- &PtrStatusTD
- );
+ HcDev,
+ DeviceAddress,
+ 0,
+ PktID,
+ IsSlowDevice,
+ &PtrStatusTD
+ );
if (EFI_ERROR (Status)) {
HcDev->PciIo->Unmap (HcDev->PciIo, Mapping);
@@ -2009,13 +2236,13 @@ UHCIControlTransfer (
}
Status = ExecuteControlTransfer (
- HcDev,
- PtrFirstDataTD,
- LoadFrameListIndex,
- DataLength,
- TimeOut,
- TransferResult
- );
+ HcDev,
+ PtrFirstDataTD,
+ LoadFrameListIndex,
+ DataLength,
+ TimeOut,
+ TransferResult
+ );
for (Index = 0; Index < 500; Index++) {
DelLinkSingleQH (
@@ -2060,13 +2287,13 @@ UHCIControlTransfer (
// detail status is returned
//
Status = ExecuteControlTransfer (
- HcDev,
- PtrStatusTD,
- LoadFrameListIndex,
- DataLength,
- TimeOut,
- TransferResult
- );
+ HcDev,
+ PtrStatusTD,
+ LoadFrameListIndex,
+ DataLength,
+ TimeOut,
+ TransferResult
+ );
//
// Delete Control Transfer QH-TDs structure
@@ -2123,13 +2350,13 @@ UHCIControlTransfer (
// detail status is returned
//
Status = ExecuteControlTransfer (
- HcDev,
- PtrSetupTD,
- LoadFrameListIndex,
- DataLength,
- TimeOut,
- TransferResult
- );
+ HcDev,
+ PtrSetupTD,
+ LoadFrameListIndex,
+ DataLength,
+ TimeOut,
+ TransferResult
+ );
//
// Remove Control Transfer QH-TDs structure from the frame list
// and update the pointers in the Frame List
@@ -2354,13 +2581,13 @@ UHCIBulkTransfer (
// BusMasterWrite means cpu read
//
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterWrite,
- PtrDataSource,
- &DataLen,
- &TempPtr,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterWrite,
+ PtrDataSource,
+ &DataLen,
+ &TempPtr,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2377,13 +2604,13 @@ UHCIBulkTransfer (
// BusMasterRead means cpu write
//
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterRead,
- PtrDataSource,
- &DataLen,
- &TempPtr,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterRead,
+ PtrDataSource,
+ &DataLen,
+ &TempPtr,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2422,16 +2649,16 @@ UHCIBulkTransfer (
}
Status = GenDataTD (
- HcDev,
- DeviceAddress,
- EndPointAddress,
- Ptr,
- PktSize,
- PktID,
- *DataToggle,
- FALSE,
- &PtrTD
- );
+ HcDev,
+ DeviceAddress,
+ EndPointAddress,
+ Ptr,
+ PktSize,
+ PktID,
+ *DataToggle,
+ FALSE,
+ &PtrTD
+ );
if (EFI_ERROR (Status)) {
HcDev->PciIo->Unmap (HcDev->PciIo, Mapping);
@@ -2526,14 +2753,14 @@ UHCIBulkTransfer (
// of the last successful TD
//
Status = ExecBulkorSyncInterruptTransfer (
- HcDev,
- PtrFirstTD,
- LoadFrameListIndex,
- DataLength,
- DataToggle,
- TimeOut,
- TransferResult
- );
+ HcDev,
+ PtrFirstTD,
+ LoadFrameListIndex,
+ DataLength,
+ DataToggle,
+ TimeOut,
+ TransferResult
+ );
//
// Delete Bulk transfer QH-TD structure
@@ -2587,7 +2814,7 @@ UHCIAsyncInterruptTransfer (
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
IN BOOLEAN IsSlowDevice,
- IN UINT8 MaxiumPacketLength,
+ IN UINT8 MaximumPacketLength,
IN BOOLEAN IsNewTransfer,
IN OUT UINT8 *DataToggle,
IN UINTN PollingInterval, OPTIONAL
@@ -2618,7 +2845,7 @@ UHCIAsyncInterruptTransfer (
IsSlowDevice Indicates whether the target device is slow device
or full-speed device.
- MaxiumPacketLength Indicates the maximum packet size the target endpoint
+ MaximumPacketLength Indicates the maximum packet size the target endpoint
is capable of sending or receiving.
IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between
@@ -2715,11 +2942,11 @@ UHCIAsyncInterruptTransfer (
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = DeleteAsyncINTQHTDs (
- HcDev,
- DeviceAddress,
- EndPointAddress,
- DataToggle
- );
+ HcDev,
+ DeviceAddress,
+ EndPointAddress,
+ DataToggle
+ );
gBS->RestoreTPL (OldTpl);
@@ -2764,13 +2991,13 @@ UHCIAsyncInterruptTransfer (
// BusMasterWrite means cpu read
//
Status = HcDev->PciIo->Map (
- HcDev->PciIo,
- EfiPciIoOperationBusMasterWrite,
- Ptr,
- &DataLen,
- &TempPtr,
- &Mapping
- );
+ HcDev->PciIo,
+ EfiPciIoOperationBusMasterWrite,
+ Ptr,
+ &DataLen,
+ &TempPtr,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
gBS->FreePool (Ptr);
return Status;
@@ -2788,21 +3015,21 @@ UHCIAsyncInterruptTransfer (
//
PktSize = (UINT8) DataLen;
- if (DataLen > MaxiumPacketLength) {
- PktSize = MaxiumPacketLength;
+ if (DataLen > MaximumPacketLength) {
+ PktSize = MaximumPacketLength;
}
Status = GenDataTD (
- HcDev,
- DeviceAddress,
- EndPointAddress,
- MappedPtr,
- PktSize,
- PktID,
- CurrentDataToggle,
- IsSlowDevice,
- &PtrTD
- );
+ HcDev,
+ DeviceAddress,
+ EndPointAddress,
+ MappedPtr,
+ PktSize,
+ PktID,
+ CurrentDataToggle,
+ IsSlowDevice,
+ &PtrTD
+ );
if (EFI_ERROR (Status)) {
gBS->FreePool (Ptr);
HcDev->PciIo->Unmap (HcDev->PciIo, Mapping);
@@ -3084,6 +3311,10 @@ UHCISyncInterruptTransfer (
return EFI_INVALID_PARAMETER;
}
+ if (TransferResult == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
ClearStatusReg (HcDev->PciIo, StatusReg);
//
@@ -3357,6 +3588,830 @@ UHCIAsyncIsochronousTransfer (
return EFI_UNSUPPORTED;
}
+//
+// UEFI 2.0 Protocol
+//
+EFI_STATUS
+EFIAPI
+UHCI2GetCapability(
+ IN EFI_USB2_HC_PROTOCOL * This,
+ OUT UINT8 *MaxSpeed,
+ OUT UINT8 *PortNumber,
+ OUT UINT8 *Is64BitCapable
+ )
+/*++
+
+ Routine Description:
+ Retrieves capabilities of USB host controller according to UEFI 2.0 spec.
+
+ Arguments:
+ This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ MaxSpeed - A pointer to the max speed USB host controller supports.
+
+ PortNumber - A pointer to the number of root hub ports.
+
+ Is64BitCapable - A pointer to an integer to show whether USB host controller
+ supports 64-bit memory addressing.
+ Returns:
+ EFI_SUCCESS
+ The host controller capabilities were retrieved successfully.
+ EFI_INVALID_PARAMETER
+ MaxSpeed or PortNumber or Is64BitCapable is NULL.
+ EFI_DEVICE_ERROR
+ An error was encountered while attempting to retrieve the capabilities.
+
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ if ((NULL == MaxSpeed)
+ ||(NULL == PortNumber)
+ || (NULL == Is64BitCapable))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *MaxSpeed = EFI_USB_SPEED_FULL;
+ *Is64BitCapable = (UINT8)FALSE;
+ return UHCIGetRootHubPortNumber(&HcDev->UsbHc, PortNumber);
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2Reset (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT16 Attributes
+ )
+/*++
+
+ Routine Description:
+ Provides software reset for the USB host controller according to UEFI 2.0 spec.
+
+ Arguments:
+ This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ Attributes - A bit mask of the reset operation to perform.
+ See below for a list of the supported bit mask values.
+
+ #define EFI_USB_HC_RESET_GLOBAL 0x0001
+ #define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002
+ #define EFI_USB_HC_RESET_GLOBAL _WITH_DEBUG 0x0004
+ #define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008
+
+ EFI_USB_HC_RESET_GLOBAL
+ If this bit is set, a global reset signal will be sent to the USB bus.
+ This resets all of the USB bus logic, including the USB host
+ controller hardware and all the devices attached on the USB bus.
+ EFI_USB_HC_RESET_HOST_CONTROLLER
+ If this bit is set, the USB host controller hardware will be reset.
+ No reset signal will be sent to the USB bus.
+
+ Returns:
+ EFI_SUCCESS
+ The reset operation succeeded.
+ EFI_INVALID_PARAMETER
+ Attributes is not valid.
+ EFI_UNSUPPORTED
+ The type of reset specified by Attributes is not currently supported by the host controller hardware.
+ EFI_ACCESS_DENIED
+ Reset operation is rejected due to the debug port being configured and active.
+ EFI_DEVICE_ERROR
+ An error was encountered while attempting to perform
+ the reset operation.
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ if (Attributes==EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG || Attributes==EFI_USB_HC_RESET_HOST_WITH_DEBUG)
+ return EFI_UNSUPPORTED;
+
+ return UHCIReset(
+ &HcDev->UsbHc,
+ Attributes
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2GetState (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ OUT EFI_USB_HC_STATE * State
+ )
+/*++
+
+ Routine Description:
+ Retrieves current state of the USB host controller according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This - A pointer to the EFI_USB_HC_PROTOCOL instance.
+
+ State - A pointer to the EFI_USB_HC_STATE data structure that
+ indicates current state of the USB host controller.
+ Type EFI_USB_HC_STATE is defined below.
+
+ typedef enum {
+ EfiUsbHcStateHalt,
+ EfiUsbHcStateOperational,
+ EfiUsbHcStateSuspend,
+ EfiUsbHcStateMaximum
+ } EFI_USB_HC_STATE;
+
+ Returns:
+ EFI_SUCCESS
+ The state information of the host controller was returned in State.
+ EFI_INVALID_PARAMETER
+ State is NULL.
+ EFI_DEVICE_ERROR
+ An error was encountered while attempting to retrieve the
+ host controller's current state.
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+ return UHCIGetState(
+ &HcDev->UsbHc,
+ State
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2SetState (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN EFI_USB_HC_STATE State
+ )
+/*++
+
+ Routine Description:
+ Sets the USB host controller to a specific state according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This - A pointer to the EFI_USB_HC_PROTOCOL instance.
+
+ State - Indicates the state of the host controller that will be set.
+
+ Returns:
+ EFI_SUCCESS
+ The USB host controller was successfully placed in the state
+ specified by State.
+ EFI_INVALID_PARAMETER
+ State is invalid.
+ EFI_DEVICE_ERROR
+ Failed to set the state specified by State due to device error.
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+ return UHCISetState(
+ &HcDev->UsbHc,
+ State
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2ControlTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN EFI_USB_DEVICE_REQUEST * Request,
+ IN EFI_USB_DATA_DIRECTION TransferDirection,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ )
+/*++
+
+ Routine Description:
+ Submits control transfer to a target USB device accroding to UEFI 2.0 spec..
+
+ Arguments:
+
+ This - A pointer to the EFI_USB_HC_PROTOCOL instance.
+
+ DeviceAddress -Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ DeviceSpeed - Indicates transfer speed of device.
+
+ MaximumPacketLength - Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
+ sending or receiving.
+
+ Request - A pointer to the USB device request that will be sent
+ to the USB device.
+
+ TransferDirection - Specifies the data direction for the transfer.
+ There are three values available, DataIn, DataOut
+ and NoData.
+
+ Data -A pointer to the buffer of data that will be transmitted
+ to USB device or received from USB device.
+
+ DataLength - Indicates the size, in bytes, of the data buffer
+ specified by Data.
+
+ TimeOut - Indicates the maximum time, in microseconds,
+ which the transfer is allowed to complete.
+
+ TransferResult - A pointer to the detailed result information generated
+ by this control transfer.
+
+ Returns:
+ EFI_SUCCESS
+ The control transfer was completed successfully.
+ EFI_OUT_OF_RESOURCES
+ The control transfer could not be completed due to a lack of resources.
+ EFI_INVALID_PARAMETER
+ Some parameters are invalid.
+ EFI_TIMEOUT
+ The control transfer failed due to timeout.
+ EFI_DEVICE_ERROR
+ The control transfer failed due to host controller or device error.
+ Caller should check TranferResult for detailed error information.
+
+--*/
+{
+ USB_HC_DEV *HcDev;
+ BOOLEAN IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ return UHCIControlTransfer(
+ &HcDev->UsbHc,
+ DeviceAddress,
+ IsSlowDevice,
+ (UINT8) MaximumPacketLength,
+ Request,
+ TransferDirection,
+ Data,
+ DataLength,
+ TimeOut,
+ TransferResult
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2BulkTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ )
+/*++
+
+ Routine Description:
+ Submits bulk transfer to a bulk endpoint of a USB device according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ DeviceAddress Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ EndPointAddress The combination of an endpoint number and an
+ endpoint direction of the target USB device.
+ Each endpoint address supports data transfer in
+ one direction except the control endpoint
+ (whose default endpoint address is 0).
+ It is the caller's responsibility to make sure that
+ the EndPointAddress represents a bulk endpoint.
+
+ DeviceSpeed Indicates device speed. The supported values are EFI_USB_SPEED_FULL
+ and EFI_USB_SPEED_HIGH.
+
+ MaximumPacketLength Indicates the maximum packet size the target endpoint
+ is capable of sending or receiving.
+
+ DataBuffersNumber Number of data buffers prepared for the transfer.
+
+ Data Array of pointers to the buffers of data that will be transmitted
+ to USB device or received from USB device.
+
+ DataLength When input, indicates the size, in bytes, of the data buffer
+ specified by Data. When output, indicates the actually
+ transferred data size.
+
+ DataToggle A pointer to the data toggle value. On input, it indicates
+ the initial data toggle value the bulk transfer should adopt;
+ on output, it is updated to indicate the data toggle value
+ of the subsequent bulk transfer.
+
+ Translator A pointr to the transaction translator data.
+
+ TimeOut Indicates the maximum time, in microseconds, which the
+ transfer is allowed to complete.
+
+ TransferResult A pointer to the detailed result information of the
+ bulk transfer.
+
+ Returns:
+ EFI_SUCCESS
+ The bulk transfer was completed successfully.
+
+ EFI_OUT_OF_RESOURCES
+ The bulk transfer could not be submitted due to lack of resource.
+
+ EFI_INVALID_PARAMETER
+ Some parameters are invalid.
+
+ EFI_TIMEOUT
+ The bulk transfer failed due to timeout.
+
+ EFI_DEVICE_ERROR
+ The bulk transfer failed due to host controller or device error.
+ Caller should check TranferResult for detailed error information.
+
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ if( Data == NULL || DeviceSpeed==EFI_USB_SPEED_LOW)
+ return EFI_INVALID_PARAMETER;
+ /* For full-speed bulk transfers only the data pointed by Data[0] shall be used */
+
+ return UHCIBulkTransfer (
+ &HcDev->UsbHc,
+ DeviceAddress,
+ EndPointAddress,
+ (UINT8) MaximumPacketLength,
+ *Data,
+ DataLength,
+ DataToggle,
+ TimeOut,
+ TransferResult
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2AsyncInterruptTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN BOOLEAN IsNewTransfer,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN PollingInterval,
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
+ IN VOID *Context
+ )
+/*++
+
+ Routine Description:
+ Submits an asynchronous interrupt transfer to an
+ interrupt endpoint of a USB device according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ DeviceAddress Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ EndPointAddress The combination of an endpoint number and an endpoint
+ direction of the target USB device. Each endpoint address
+ supports data transfer in one direction except the
+ control endpoint (whose default endpoint address is 0).
+ It is the caller's responsibility to make sure that
+ the EndPointAddress represents an interrupt endpoint.
+
+ DeviceSpeed Indicates device speed.
+
+ MaximumPacketLength Indicates the maximum packet size the target endpoint
+ is capable of sending or receiving.
+
+ IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between
+ the host and the target interrupt endpoint.
+ If FALSE, the specified asynchronous interrupt pipe
+ is canceled.
+
+ DataToggle A pointer to the data toggle value. On input, it is valid
+ when IsNewTransfer is TRUE, and it indicates the initial
+ data toggle value the asynchronous interrupt transfer
+ should adopt.
+ On output, it is valid when IsNewTransfer is FALSE,
+ and it is updated to indicate the data toggle value of
+ the subsequent asynchronous interrupt transfer.
+
+ PollingInterval Indicates the interval, in milliseconds, that the
+ asynchronous interrupt transfer is polled.
+ This parameter is required when IsNewTransfer is TRUE.
+
+ DataLength Indicates the length of data to be received at the
+ rate specified by PollingInterval from the target
+ asynchronous interrupt endpoint. This parameter
+ is only required when IsNewTransfer is TRUE.
+
+ Translator A pointr to the transaction translator data.
+
+ CallBackFunction The Callback function.This function is called at the
+ rate specified by PollingInterval.This parameter is
+ only required when IsNewTransfer is TRUE.
+
+ Context The context that is passed to the CallBackFunction.
+ This is an optional parameter and may be NULL.
+
+ Returns:
+
+ EFI_SUCCESS
+ The asynchronous interrupt transfer request has been successfully
+ submitted or canceled.
+
+ EFI_INVALID_PARAMETER
+ Some parameters are invalid.
+
+ EFI_OUT_OF_RESOURCES
+ The request could not be completed due to a lack of resources.
+
+ EFI_DEVICE_ERROR
+ Can't read register
+--*/
+{
+ USB_HC_DEV *HcDev;
+ BOOLEAN IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+ return UHCIAsyncInterruptTransfer(
+ &HcDev->UsbHc,
+ DeviceAddress,
+ EndPointAddress,
+ IsSlowDevice,
+ (UINT8) MaximumPacketLength,
+ IsNewTransfer,
+ DataToggle,
+ PollingInterval,
+ DataLength,
+ CallBackFunction,
+ Context
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2SyncInterruptTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ )
+/*++
+
+ Routine Description:
+ Submits synchronous interrupt transfer to an interrupt endpoint
+ of a USB device according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ DeviceAddress Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ EndPointAddress The combination of an endpoint number and an endpoint
+ direction of the target USB device. Each endpoint
+ address supports data transfer in one direction
+ except the control endpoint (whose default
+ endpoint address is 0). It is the caller's responsibility
+ to make sure that the EndPointAddress represents
+ an interrupt endpoint.
+
+ DeviceSpeed Indicates device speed.
+
+ MaximumPacketLength Indicates the maximum packet size the target endpoint
+ is capable of sending or receiving.
+
+ Data A pointer to the buffer of data that will be transmitted
+ to USB device or received from USB device.
+
+ DataLength On input, the size, in bytes, of the data buffer specified
+ by Data. On output, the number of bytes transferred.
+
+ DataToggle A pointer to the data toggle value. On input, it indicates
+ the initial data toggle value the synchronous interrupt
+ transfer should adopt;
+ on output, it is updated to indicate the data toggle value
+ of the subsequent synchronous interrupt transfer.
+
+ TimeOut Indicates the maximum time, in microseconds, which the
+ transfer is allowed to complete.
+ Translator A pointr to the transaction translator data.
+ TransferResult A pointer to the detailed result information from
+ the synchronous interrupt transfer.
+
+ Returns:
+ EFI_SUCCESS
+ The synchronous interrupt transfer was completed successfully.
+ EFI_OUT_OF_RESOURCES
+ The synchronous interrupt transfer could not be submitted due
+ to lack of resource.
+ EFI_INVALID_PARAMETER
+ Some parameters are invalid.
+ EFI_TIMEOUT
+ The synchronous interrupt transfer failed due to timeout.
+ EFI_DEVICE_ERROR
+ The synchronous interrupt transfer failed due to host controller
+ or device error. Caller should check TranferResult for detailed
+ error information.
+--*/
+{
+ USB_HC_DEV *HcDev;
+ BOOLEAN IsSlowDevice;
+
+ if(DeviceSpeed==EFI_USB_SPEED_HIGH)
+ return EFI_INVALID_PARAMETER;
+
+ IsSlowDevice = (EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE;
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ return UHCISyncInterruptTransfer(
+ &HcDev->UsbHc,
+ DeviceAddress,
+ EndPointAddress,
+ IsSlowDevice,
+ (UINT8) MaximumPacketLength,
+ Data,
+ DataLength,
+ DataToggle,
+ TimeOut,
+ TransferResult
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2IsochronousTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ )
+/*++
+
+ Routine Description:
+
+ Submits isochronous transfer to a target USB device according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ DeviceAddress Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ EndPointAddress End point address
+
+ DeviceSpeed Indicates device speed.
+
+ MaximumPacketLength Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
+ sending or receiving.
+
+ DataBuffersNumber Number of data buffers prepared for the transfer.
+
+ Data Array of pointers to the buffers of data that will be
+ transmitted to USB device or received from USB device.
+
+ DataLength Indicates the size, in bytes, of the data buffer
+ specified by Data.
+
+ Translator A pointr to the transaction translator data.
+
+ TransferResult A pointer to the detailed result information generated
+ by this control transfer.
+ Returns:
+
+ EFI_UNSUPPORTED
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2AsyncIsochronousTransfer (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
+ IN VOID *Context
+ )
+/*++
+
+ Routine Description:
+
+ Submits Async isochronous transfer to a target USB device according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ DeviceAddress Represents the address of the target device on the USB,
+ which is assigned during USB enumeration.
+
+ EndPointAddress End point address
+
+ DeviceSpeed Indicates device speed.
+
+ MaximumPacketLength Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
+ sending or receiving.
+
+ DataBuffersNumber Number of data buffers prepared for the transfer.
+
+ Data Array of pointers to the buffers of data that will be transmitted
+ to USB device or received from USB device.
+
+ Translator A pointr to the transaction translator data.
+
+ IsochronousCallBack When the transfer complete, the call back function will be called
+
+ Context Pass to the call back function as parameter
+
+ Returns:
+
+ EFI_UNSUPPORTED
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2GetRootHubPortStatus (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ OUT EFI_USB_PORT_STATUS * PortStatus
+ )
+/*++
+
+ Routine Description:
+ Retrieves the current status of a USB root hub port according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL.
+
+ PortNumber Specifies the root hub port from which the status
+ is to be retrieved. This value is zero-based. For example,
+ if a root hub has two ports, then the first port is numbered 0,
+ and the second port is numbered 1.
+
+ PortStatus A pointer to the current port status bits and
+ port status change bits.
+
+ Returns:
+ EFI_SUCCESS
+ The status of the USB root hub port specified by PortNumber
+ was returned in PortStatus.
+ EFI_INVALID_PARAMETER
+ PortNumber is invalid.
+ EFI_DEVICE_ERROR - Can't read register
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+
+ return UHCIGetRootHubPortStatus(
+ &HcDev->UsbHc,
+ PortNumber,
+ PortStatus
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2SetRootHubPortFeature (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ )
+/*++
+
+ Routine Description:
+ Sets a feature for the specified root hub port according to UEFI 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL.
+
+ PortNumber Specifies the root hub port whose feature
+ is requested to be set.
+
+ PortFeature Indicates the feature selector associated
+ with the feature set request.
+
+ Returns:
+ EFI_SUCCESS
+ The feature specified by PortFeature was set for the
+ USB root hub port specified by PortNumber.
+ EFI_INVALID_PARAMETER
+ PortNumber is invalid or PortFeature is invalid.
+ EFI_DEVICE_ERROR
+ Can't read register
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+ return UHCISetRootHubPortFeature(
+ &HcDev->UsbHc,
+ PortNumber,
+ PortFeature
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UHCI2ClearRootHubPortFeature (
+ IN EFI_USB2_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ )
+/*++
+
+ Routine Description:
+ Clears a feature for the specified root hub port according to Uefi 2.0 spec.
+
+ Arguments:
+
+ This A pointer to the EFI_USB2_HC_PROTOCOL instance.
+
+ PortNumber Specifies the root hub port whose feature
+ is requested to be cleared.
+
+ PortFeature Indicates the feature selector associated with the
+ feature clear request.
+
+ Returns:
+ EFI_SUCCESS
+ The feature specified by PortFeature was cleared for the
+ USB root hub port specified by PortNumber.
+ EFI_INVALID_PARAMETER
+ PortNumber is invalid or PortFeature is invalid.
+ EFI_DEVICE_ERROR
+ Can't read register
+--*/
+{
+ USB_HC_DEV *HcDev;
+
+ HcDev = USB2_HC_DEV_FROM_THIS (This);
+ return UHCIClearRootHubPortFeature(
+ &HcDev->UsbHc,
+ PortNumber,
+ PortFeature
+ );
+}
+
VOID
EFIAPI
MonitorInterruptTrans (
diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.h b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.h
index d6f841b..c5ae155 100644
--- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.h
+++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.h
@@ -28,7 +28,7 @@ Revision History
#include <IndustryStandard/pci22.h>
-#define EFI_D_UHCI EFI_D_INFO
+#define EFI_D_UHCI EFI_D_INFO
//
// stall time
@@ -45,21 +45,20 @@ Revision History
//
// 50 ms
//
-#define INTERRUPT_POLLING_TIME 50 * 1000 * 10
+#define INTERRUPT_POLLING_TIME 50 * 1000 * 10
//
// UHCI IO Space Address Register Register locates at
// offset 20 ~ 23h of PCI Configuration Space (UHCI spec, Revision 1.1),
// so, its BAR Index is 4.
//
-#define USB_BAR_INDEX 4
+#define USB_BAR_INDEX 4
//
// One memory block uses 1 page (common buffer for QH,TD use.)
//
#define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 1
-
#define bit(a) 1 << (a)
//
@@ -82,13 +81,13 @@ extern UINT16 USBBaseAddr;
#define USBCMD_MAXP bit (7) /* Max Packet (0 = 32, 1 = 64) */
/* Status register */
-#define USBSTS 2 /* Status Register Offset 02-03h */
-#define USBSTS_USBINT bit (0) /* Interrupt due to IOC */
-#define USBSTS_ERROR bit (1) /* Interrupt due to error */
-#define USBSTS_RD bit (2) /* Resume Detect */
-#define USBSTS_HSE bit (3) /* Host System Error*/
-#define USBSTS_HCPE bit (4) /* Host Controller Process Error*/
-#define USBSTS_HCH bit (5) /* HC Halted */
+#define USBSTS 2 /* Status Register Offset 02-03h */
+#define USBSTS_USBINT bit (0) /* Interrupt due to IOC */
+#define USBSTS_ERROR bit (1) /* Interrupt due to error */
+#define USBSTS_RD bit (2) /* Resume Detect */
+#define USBSTS_HSE bit (3) /* Host System Error*/
+#define USBSTS_HCPE bit (4) /* Host Controller Process Error*/
+#define USBSTS_HCH bit (5) /* HC Halted */
/* Interrupt enable register */
#define USBINTR 4 /* Interrupt Enable Register 04-05h */
@@ -98,13 +97,13 @@ extern UINT16 USBBaseAddr;
#define USBINTR_SP bit (3) /* Short packet interrupt enable */
/* Frame Number Register Offset 06-08h */
-#define USBFRNUM 6
+#define USBFRNUM 6
/* Frame List Base Address Register Offset 08-0Bh */
-#define USBFLBASEADD 8
+#define USBFLBASEADD 8
/* Start of Frame Modify Register Offset 0Ch */
-#define USBSOF 0x0c
+#define USBSOF 0x0c
/* USB port status and control registers */
#define USBPORTSC1 0x10 /*Port 1 offset 10-11h */
@@ -126,16 +125,16 @@ extern UINT16 USBBaseAddr;
//
// Class Code Register offset
//
-#define CLASSC 0x09
+#define CLASSC 0x09
//
// USB IO Space Base Address Register offset
//
-#define USBBASE 0x20
+#define USBBASE 0x20
//
// USB legacy Support
//
-#define USB_EMULATION 0xc0
+#define USB_EMULATION 0xc0
//
// USB Base Class Code,Sub-Class Code and Programming Interface.
@@ -224,6 +223,7 @@ typedef struct {
//
//////////////////////////////////////////////////////////////////////////
#define USB_HC_DEV_FROM_THIS(a) CR (a, USB_HC_DEV, UsbHc, USB_HC_DEV_SIGNATURE)
+#define USB2_HC_DEV_FROM_THIS(a) CR (a, USB_HC_DEV, Usb2Hc, USB_HC_DEV_SIGNATURE)
#define USB_HC_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'h', 'c', 'i')
#define INTERRUPT_LIST_SIGNATURE EFI_SIGNATURE_32 ('i', 'n', 't', 's')
@@ -267,6 +267,7 @@ typedef struct _MEMORY_MANAGE_HEADER {
typedef struct {
UINTN Signature;
EFI_USB_HC_PROTOCOL UsbHc;
+ EFI_USB2_HC_PROTOCOL Usb2Hc;
EFI_PCI_IO_PROTOCOL *PciIo;
//
@@ -289,196 +290,683 @@ WriteUHCCommandReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 CmdAddrOffset,
IN UINT16 UsbCmd
- );
+ )
+/*++
+
+Routine Description:
+
+ Write UHCI Command Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ CmdAddrOffset - Command address offset
+ UsbCmd - Data to write
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
ReadUHCCommandReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 CmdAddrOffset,
IN OUT UINT16 *Data
- );
+ )
+/*++
+
+Routine Description:
+
+ Read UHCI Command Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ CmdAddrOffset - Command address offset
+ Data - Data to return
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
WriteUHCStatusReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusAddrOffset,
IN UINT16 UsbSts
- );
+ )
+/*++
+
+Routine Description:
+
+ Write UHCI Staus Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusAddrOffset - Status address offset
+ UsbSts - Data to write
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
ReadUHCStatusReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusAddrOffset,
IN OUT UINT16 *Data
- );
+ )
+/*++
+
+Routine Description:
+
+ Read UHCI Staus Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusAddrOffset - Status address offset
+ UsbSts - Data to return
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
ClearStatusReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusAddrOffset
- );
+ )
+/*++
+
+Routine Description:
+
+ Clear the content of UHC's Status Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusAddrOffset - Status address offset
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
ReadUHCFrameNumberReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 FrameNumAddrOffset,
IN OUT UINT16 *Data
- );
+ )
+/*++
+
+Routine Description:
+
+ Read from UHC's Frame Number Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ FrameNumAddrOffset - Frame number register offset
+ Data - Data to return
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
WriteUHCFrameListBaseReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 FlBaseAddrOffset,
IN UINT32 UsbFrameListBaseAddr
- );
+ )
+/*++
+
+Routine Description:
+
+ Write to UHC's Frame List Base Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ FlBaseAddrOffset - Frame Base address register
+ UsbFrameListBaseAddr - Address to write
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
ReadRootPortReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 PortAddrOffset,
IN OUT UINT16 *Data
- );
+ )
+/*++
+
+Routine Description:
+
+ Read from UHC's Root Port Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ PortAddrOffset - Port Addrress Offset,
+ Data - Data to return
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
WriteRootPortReg (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 PortAddrOffset,
IN UINT16 ControlBits
- );
+ )
+/*++
+
+Routine Description:
+
+ Write to UHC's Root Port Register
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ PortAddrOffset - Port Addrress Offset,
+ ControlBits - Data to write
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
EFI_STATUS
WaitForUHCHalt (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusRegAddr,
IN UINTN Timeout
- );
+ )
+/*++
+
+Routine Description:
+
+ Wait until UHCI halt or timeout
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusRegAddr - Status Register Address
+ Timeout - Time out value in us
+
+Returns:
+
+ EFI_DEVICE_ERROR - Unable to read the status register
+ EFI_TIMEOUT - Time out
+ EFI_SUCCESS - Success
+
+--*/
+;
BOOLEAN
IsStatusOK (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusRegAddr
- );
+ )
+/*++
+
+Routine Description:
+
+ Judge whether the host controller operates well
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusRegAddr - Status register address
+
+Returns:
+
+ TRUE - Status is good
+ FALSE - Status is bad
+
+--*/
+;
BOOLEAN
IsHostSysOrProcessErr (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 StatusRegAddr
- );
+ )
+/*++
-//
-// This routine programs the USB frame number register. We assume that the
-// HC schedule execution is stopped.
-//
-EFI_STATUS
-SetFrameNumberReg (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT32 FRNUMAddr,
- IN UINT16 Index
- );
+Routine Description:
+
+ Judge the status is HostSys,ProcessErr error or good
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ StatusRegAddr - Status register address
+
+Returns:
+
+ TRUE - Status is good
+ FALSE - Status is bad
+
+--*/
+;
UINT16
GetCurrentFrameNumber (
IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT32 FRNUMAddr
- );
+ IN UINT32 FrameNumAddrOffset
+ )
+/*++
+
+Routine Description:
+
+ Get Current Frame Number
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ FrameNumAddrOffset - FrameNum register AddrOffset
+
+Returns:
+
+ Frame number
+
+--*/
+;
EFI_STATUS
SetFrameListBaseAddress (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 FLBASEADDRReg,
IN UINT32 Addr
- );
+ )
+/*++
+
+Routine Description:
+
+ Set FrameListBase Address
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ FlBaseAddrReg - FrameListBase register
+ Addr - Address to set
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
UINT32
GetFrameListBaseAddress (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT32 FLBAddr
- );
+ )
+/*++
+
+Routine Description:
+
+ Get Current Frame Number
+
+Arguments:
+
+ PciIo - EFI_PCI_IO_PROTOCOL
+ FrameNumAddrOffset - FrameNum register AddrOffset
+
+Returns:
+
+ Frame number
+
+--*/
+;
EFI_STATUS
CreateFrameList (
IN USB_HC_DEV *HcDev,
IN UINT32 FLBASEADDRReg
- );
+ )
+/*++
+
+Routine Description:
+
+ CreateFrameList
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ FlBaseAddrReg - Frame List register
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - Can't allocate memory resources
+ EFI_UNSUPPORTED - Map memory fail
+ EFI_SUCCESS - Success
+
+--*/
+;
EFI_STATUS
FreeFrameListEntry (
IN USB_HC_DEV *UhcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Free FrameList buffer
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS - success
+
+--*/
+;
VOID
InitFrameList (
IN USB_HC_DEV *HcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Initialize FrameList
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+Returns:
+ VOID
+
+--*/
+;
EFI_STATUS
CreateQH (
IN USB_HC_DEV *HcDev,
OUT QH_STRUCT **pptrQH
- );
+ )
+/*++
+
+Routine Description:
+
+ CreateQH
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ pptrQH - QH_STRUCT content to return
+Returns:
+
+ EFI_SUCCESS - Success
+ EFI_OUT_OF_RESOURCES - Can't allocate memory
+
+--*/
+;
VOID
SetQHHorizontalLinkPtr (
IN QH_STRUCT *ptrQH,
IN VOID *ptrNext
- );
+ )
+/*++
+
+Routine Description:
+
+ Set QH Horizontal Link Pointer
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ ptrNext - Data to write
-VOID *
+Returns:
+
+ VOID
+
+--*/
+;
+
+VOID *
GetQHHorizontalLinkPtr (
IN QH_STRUCT *ptrQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Get QH Horizontal Link Pointer
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+
+
+Returns:
+
+ Data to return
+
+--*/
+;
VOID
SetQHHorizontalQHorTDSelect (
IN QH_STRUCT *ptrQH,
IN BOOLEAN bQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Set QH Horizontal QH or TD
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ bQH - TRUE is QH FALSE is TD
+
+Returns:
+ VOID
+
+--*/
+;
VOID
SetQHHorizontalValidorInvalid (
IN QH_STRUCT *ptrQH,
IN BOOLEAN bValid
- );
+ )
+/*++
+
+Routine Description:
+
+ Set QH Horizontal Valid or Invalid
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ bValid - TRUE is Valid FALSE is Invalid
+
+Returns:
+ VOID
+
+--*/
+;
VOID
SetQHVerticalLinkPtr (
IN QH_STRUCT *ptrQH,
IN VOID *ptrNext
- );
+ )
+/*++
+
+Routine Description:
-VOID *
+ Set QH Vertical Link Pointer
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ ptrNext - Data to write
+Returns:
+
+ VOID
+
+--*/
+;
+
+VOID *
GetQHVerticalLinkPtr (
IN QH_STRUCT *ptrQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Get QH Vertical Link Pointer
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+
+Returns:
+
+ Data to return
+
+--*/
+;
VOID
SetQHVerticalQHorTDSelect (
IN QH_STRUCT *ptrQH,
IN BOOLEAN bQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Set QH Vertical QH or TD
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ bQH - TRUE is QH FALSE is TD
+
+Returns:
+
+ VOID
+
+--*/
+;
BOOLEAN
IsQHHorizontalQHSelect (
IN QH_STRUCT *ptrQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Is QH Horizontal QH Select
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+
+Returns:
+
+ TRUE - QH
+ FALSE - TD
+
+--*/
+;
VOID
SetQHVerticalValidorInvalid (
IN QH_STRUCT *ptrQH,
IN BOOLEAN bValid
- );
+ )
+/*++
+
+Routine Description:
+
+ Set QH Vertical Valid or Invalid
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ IsValid - TRUE is valid FALSE is invalid
+
+Returns:
+
+ VOID
+
+--*/
+;
BOOLEAN
GetQHVerticalValidorInvalid (
IN QH_STRUCT *ptrQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Get QH Vertical Valid or Invalid
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+
+Returns:
+
+ TRUE - Valid
+ FALSE - Invalid
+
+--*/
+;
EFI_STATUS
AllocateTDStruct (
IN USB_HC_DEV *HcDev,
OUT TD_STRUCT **ppTDStruct
- );
+ )
/*++
Routine Description:
@@ -494,12 +982,13 @@ Returns:
EFI_SUCCESS
--*/
+;
EFI_STATUS
CreateTD (
IN USB_HC_DEV *HcDev,
OUT TD_STRUCT **pptrTD
- );
+ )
/*++
Routine Description:
@@ -517,6 +1006,7 @@ Returns:
EFI_SUCCESS - Success
--*/
+;
EFI_STATUS
@@ -528,7 +1018,7 @@ GenSetupStageTD (
IN UINT8 *pDevReq,
IN UINT8 RequestLen,
OUT TD_STRUCT **ppTD
- );
+ )
/*++
Routine Description:
@@ -550,6 +1040,7 @@ Returns:
EFI_SUCCESS - Success
--*/
+;
EFI_STATUS
GenDataTD (
@@ -562,7 +1053,7 @@ GenDataTD (
IN UINT8 Toggle,
IN BOOLEAN bSlow,
OUT TD_STRUCT **ppTD
- );
+ )
/*++
Routine Description:
@@ -586,6 +1077,7 @@ Returns:
EFI_SUCCESS - Success
--*/
+;
EFI_STATUS
CreateStatusTD (
@@ -595,7 +1087,7 @@ CreateStatusTD (
IN UINT8 PktID,
IN BOOLEAN bSlow,
OUT TD_STRUCT **ppTD
- );
+ )
/*++
Routine Description:
@@ -617,237 +1109,918 @@ Returns:
EFI_SUCCESS - Success
--*/
+;
VOID
SetTDLinkPtrValidorInvalid (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bValid
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Link Pointer Valid or Invalid
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+ bValid - TRUE is valid FALSE is invalid
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDLinkPtrQHorTDSelect (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Link Pointer QH or TD Select
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+ bQH - TRUE is QH FALSE is TD
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDLinkPtrDepthorBreadth (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bDepth
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Link Pointer depth or bread priority
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+ bDepth - TRUE is Depth FALSE is Breadth
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDLinkPtr (
IN TD_STRUCT *ptrTDStruct,
IN VOID *ptrNext
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Link Pointer
+
+Arguments:
-VOID *
+ ptrTDStruct - TD_STRUCT
+ ptrNext - Pointer to set
+
+Returns:
+
+ VOID
+
+--*/
+;
+
+VOID *
GetTDLinkPtr (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Link Pointer
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+
+Returns:
+
+ Pointer to get
+
+--*/
+;
VOID
EnableorDisableTDShortPacket (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bEnable
- );
+ )
+/*++
+
+Routine Description:
+
+ Enable or Disable TD ShortPacket
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+ bEnable - TRUE is Enanble FALSE is Disable
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDControlErrorCounter (
IN TD_STRUCT *ptrTDStruct,
IN UINT8 nMaxErrors
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Control ErrorCounter
+
+Arguments:
+
+ ptrTDStruct - TD_STRUCT
+ nMaxErrors - Error counter number
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDLoworFullSpeedDevice (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bLowSpeedDevice
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD status low speed or full speed
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ bLowSpeedDevice - Show low speed or full speed
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDControlIsochronousorNot (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bIsochronous
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD status Isochronous or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ IsIsochronous - Show Isochronous or not
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetorClearTDControlIOC (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bSet
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD status IOC IsSet
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ IsSet - Show IOC set or not
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDStatusActiveorInactive (
IN TD_STRUCT *ptrTDStruct,
IN BOOLEAN bActive
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD status active or not
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ IsActive - Active or not
+
+Returns:
+
+ VOID
+
+--*/
+;
UINT16
SetTDTokenMaxLength (
IN TD_STRUCT *ptrTDStruct,
IN UINT16 nMaxLen
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Token maxlength
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ MaximumLength - Maximum length of TD Token
+
+Returns:
+
+ Real maximum length set to TD Token
+
+--*/
+;
VOID
SetTDTokenDataToggle1 (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Token data toggle1
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDTokenDataToggle0 (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Token data toggle0
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ VOID
+
+--*/
+;
UINT8
GetTDTokenDataToggle (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Token data toggle
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ data toggle value
+
+--*/
+;
VOID
SetTDTokenEndPoint (
IN TD_STRUCT *ptrTDStruct,
IN UINTN nEndPoint
- );
+ )
+/*++
+
+Routine Description:
+
+ Set Data Token endpoint number
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ EndPoint - End point number
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDTokenDeviceAddress (
IN TD_STRUCT *ptrTDStruct,
IN UINTN nDevAddr
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Token device address
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ DeviceAddress - Device address
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDTokenPacketID (
IN TD_STRUCT *ptrTDStruct,
IN UINT8 nPID
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD Token packet ID
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+ PID - Packet ID
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetTDDataBuffer (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Set TD data buffer
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ VOID
+
+--*/
+;
BOOLEAN
IsTDStatusActive (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status active or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Active
+ FALSE - Inactive
+
+--*/
+;
BOOLEAN
IsTDStatusStalled (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status stalled or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Stalled
+ FALSE - not stalled
+
+--*/
+;
BOOLEAN
IsTDStatusBufferError (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status buffer error or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Buffer error
+ FALSE - No error
+
+--*/
+;
BOOLEAN
IsTDStatusBabbleError (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status babble error or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Babble error
+ FALSE - No error
+
+--*/
+;
BOOLEAN
IsTDStatusNAKReceived (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status NAK received
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - NAK received
+ FALSE - NAK not received
+
+--*/
+;
BOOLEAN
IsTDStatusCRCTimeOutError (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status CRC timeout error or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - CRC timeout error
+ FALSE - CRC timeout no error
+
+--*/
+;
BOOLEAN
IsTDStatusBitStuffError (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether TD status bit stuff error or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Bit stuff error
+ FALSE - Bit stuff no error
+
+--*/
+;
UINT16
GetTDStatusActualLength (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD status length
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return Td status length
+
+--*/
+;
UINT16
GetTDTokenMaxLength (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Token maximum length
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return TD token maximum length
+
+--*/
+;
UINT8
GetTDTokenEndPoint (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Token endpoint number
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return TD Token endpoint number
+
+--*/
+;
UINT8
GetTDTokenDeviceAddress (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Token device address
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return TD Token device address
+
+--*/
+;
UINT8
GetTDTokenPacketID (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD Token packet ID
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return TD Token packet ID
-UINT8 *
+--*/
+;
+
+UINT8 *
GetTDDataBuffer (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get the point to TD data buffer
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ Return a point to TD data buffer
+
+--*/
+;
BOOLEAN
GetTDLinkPtrValidorInvalid (
IN TD_STRUCT *ptrTDStruct
- );
+ )
+/*++
+
+Routine Description:
+
+ Get TD LinkPtr valid or not
+
+Arguments:
+
+ ptrTDStruct - A point to TD_STRUCT
+
+Returns:
+
+ TRUE - Invalid
+ FALSE - Valid
+
+--*/
+;
UINTN
CountTDsNumber (
IN TD_STRUCT *ptrFirstTD
- );
+ )
+/*++
+
+Routine Description:
+
+ Get the number of TDs
+
+Arguments:
+
+ PtrFirstTD - A point to the first TD_STRUCT
+
+Returns:
+
+ Return the number of TDs
+
+--*/
+;
VOID
LinkTDToQH (
IN QH_STRUCT *ptrQH,
IN TD_STRUCT *ptrTD
- );
+ )
+/*++
+
+Routine Description:
+
+ Link TD To QH
+
+Arguments:
+
+ PtrQH - QH_STRUCT
+ PtrTD - TD_STRUCT
+Returns:
+
+ VOID
+
+--*/
+;
VOID
LinkTDToTD (
IN TD_STRUCT *ptrPreTD,
IN TD_STRUCT *ptrTD
- );
+ )
+/*++
+
+Routine Description:
+
+ Link TD To TD
+
+Arguments:
+
+ ptrPreTD - Previous TD_STRUCT to be linked
+ PtrTD - TD_STRUCT to link
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetorClearCurFrameListTerminate (
IN FRAMELIST_ENTRY *pCurEntry,
IN BOOLEAN bSet
- );
+ )
+/*++
+
+Routine Description:
+
+ Set or clear current framelist terminate
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+ IsSet - TRUE to empty the frame and indicate the Pointer field is valid
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
SetCurFrameListQHorTD (
IN FRAMELIST_ENTRY *pCurEntry,
IN BOOLEAN bQH
- );
+ )
+/*++
+
+Routine Description:
+
+ Set current framelist QH or TD
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+ IsQH - TRUE to set QH and FALSE to set TD
+
+Returns:
+
+ VOID
+
+--*/
+;
BOOLEAN
GetCurFrameListTerminate (
IN FRAMELIST_ENTRY *pCurEntry
- );
+ )
+/*++
+
+Routine Description:
+
+ Get current framelist terminate
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+
+Returns:
+
+ TRUE - Terminate
+ FALSE - Not terminate
+
+--*/
+;
VOID
SetCurFrameListPointer (
IN FRAMELIST_ENTRY *pCurEntry,
IN UINT8 *ptr
- );
+ )
+/*++
-VOID *
+Routine Description:
+
+ Set current framelist pointer
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+ ptr - A point to FrameListPtr point to
+
+Returns:
+
+ VOID
+
+--*/
+;
+
+VOID *
GetCurFrameListPointer (
IN FRAMELIST_ENTRY *pCurEntry
- );
+ )
+/*++
+
+Routine Description:
+
+ Get current framelist pointer
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+
+Returns:
+
+ A point FrameListPtr point to
+
+--*/
+;
VOID
LinkQHToFrameList (
IN FRAMELIST_ENTRY *pEntry,
IN UINT16 FrameListIndex,
IN QH_STRUCT *ptrQH
- );
+ )
/*++
Routine Description:
@@ -864,14 +2037,7 @@ Returns:
VOID
--*/
-VOID
-DeleteQHTDs (
- IN FRAMELIST_ENTRY *pEntry,
- IN QH_STRUCT *ptrQH,
- IN TD_STRUCT *ptrFirstTD,
- IN UINT16 FrameListIndex,
- IN BOOLEAN SearchOther
- );
+;
VOID
DelLinkSingleQH (
@@ -880,13 +2046,50 @@ DelLinkSingleQH (
IN UINT16 FrameListIndex,
IN BOOLEAN SearchOther,
IN BOOLEAN Delete
- );
+ )
+/*++
+
+Routine Description:
+
+ Unlink from frame list and delete single QH
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ PtrQH - QH_STRUCT
+ FrameListIndex - Frame List Index
+ SearchOther - Search Other QH
+ Delete - TRUE is to delete the QH
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
DeleteQueuedTDs (
IN USB_HC_DEV *HcDev,
IN TD_STRUCT *ptrFirstTD
- );
+ )
+/*++
+
+Routine Description:
+
+ Delete Queued TDs
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ PtrFirstTD - TD link list head
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
InsertQHTDToINTList (
@@ -902,10 +2105,12 @@ InsertQHTDToINTList (
IN UINT8 *DataBuffer,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
IN VOID *Context
- );
+ )
/*++
Routine Description:
+
Insert QH and TD To Interrupt List
+
Arguments:
HcDev - USB_HC_DEV
@@ -920,11 +2125,14 @@ Arguments:
DataBuffer - Data buffer
CallBackFunction- CallBackFunction after interrupt transfeer
Context - CallBackFunction Context passed as function parameter
+
Returns:
+
EFI_SUCCESS - Sucess
EFI_INVALID_PARAMETER - Paremeter is error
--*/
+;
EFI_STATUS
DeleteAsyncINTQHTDs (
@@ -932,11 +2140,12 @@ DeleteAsyncINTQHTDs (
IN UINT8 DeviceAddress,
IN UINT8 EndPointAddress,
OUT UINT8 *DataToggle
- );
+ )
/*++
Routine Description:
Delete Async INT QH and TDs
+
Arguments:
HcDev - USB_HC_DEV
@@ -945,10 +2154,13 @@ Arguments:
DataToggle - Data Toggle
Returns:
+
EFI_SUCCESS - Sucess
EFI_INVALID_PARAMETER - Paremeter is error
--*/
+;
+
BOOLEAN
CheckTDsResults (
IN TD_STRUCT *ptrTD,
@@ -956,7 +2168,7 @@ CheckTDsResults (
OUT UINT32 *Result,
OUT UINTN *ErrTDPos,
OUT UINTN *ActualTransferSize
- );
+ )
/*++
Routine Description:
@@ -977,6 +2189,8 @@ Returns:
FALSE - Fail
--*/
+;
+
VOID
ExecuteAsyncINTTDs (
IN USB_HC_DEV *HcDev,
@@ -984,7 +2198,7 @@ ExecuteAsyncINTTDs (
OUT UINT32 *Result,
OUT UINTN *ErrTDPos,
OUT UINTN *ActualLen
- ) ;
+ )
/*++
Routine Description:
@@ -1004,12 +2218,14 @@ Returns:
VOID
--*/
+;
+
VOID
UpdateAsyncINTQHTDs (
IN INTERRUPT_LIST *ptrList,
IN UINT32 Result,
IN UINT32 ErrTDPos
- );
+ )
/*++
Routine Description:
@@ -1027,16 +2243,19 @@ Returns:
VOID
--*/
+;
+
VOID
ReleaseInterruptList (
IN USB_HC_DEV *HcDev,
IN LIST_ENTRY *ListHead
- );
+ )
/*++
Routine Description:
Release Interrupt List
+
Arguments:
HcDev - USB_HC_DEV
@@ -1047,6 +2266,8 @@ Returns:
VOID
--*/
+;
+
EFI_STATUS
ExecuteControlTransfer (
IN USB_HC_DEV *HcDev,
@@ -1055,7 +2276,7 @@ ExecuteControlTransfer (
OUT UINTN *ActualLen,
IN UINTN TimeOut,
OUT UINT32 *TransferResult
- );
+ )
/*++
Routine Description:
@@ -1077,6 +2298,8 @@ Returns:
--*/
+;
+
EFI_STATUS
ExecBulkorSyncInterruptTransfer (
IN USB_HC_DEV *HcDev,
@@ -1086,7 +2309,7 @@ ExecBulkorSyncInterruptTransfer (
OUT UINT8 *DataToggle,
IN UINTN TimeOut,
OUT UINT32 *TransferResult
- );
+ )
/*++
Routine Description:
@@ -1107,81 +2330,311 @@ Returns:
EFI_SUCCESS - Sucess
EFI_DEVICE_ERROR - Error
--*/
+;
EFI_STATUS
InitializeMemoryManagement (
IN USB_HC_DEV *HcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Initialize Memory Management
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS - Success
+
+--*/
+;
EFI_STATUS
CreateMemoryBlock (
IN USB_HC_DEV *HcDev,
IN MEMORY_MANAGE_HEADER **MemoryHeader,
IN UINTN MemoryBlockSizeInPages
- );
+ )
+/*++
+
+Routine Description:
+
+ Use PciIo->AllocateBuffer to allocate common buffer for the memory block,
+ and use PciIo->Map to map the common buffer for Bus Master Read/Write.
+
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ MemoryHeader - MEMORY_MANAGE_HEADER to output
+ MemoryBlockSizeInPages - MemoryBlockSizeInPages
+
+Returns:
+
+ EFI_SUCCESS - Success
+ EFI_OUT_OF_RESOURCES - Out of resources
+ EFI_UNSUPPORTED - Unsupported
+
+--*/
+;
EFI_STATUS
FreeMemoryHeader (
IN USB_HC_DEV *HcDev,
IN MEMORY_MANAGE_HEADER *MemoryHeader
- );
+ )
+/*++
+
+Routine Description:
+
+ Free Memory Header
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ MemoryHeader - MemoryHeader to be freed
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+
+--*/
+;
EFI_STATUS
UhciAllocatePool (
IN USB_HC_DEV *UhcDev,
IN UINT8 **Pool,
IN UINTN AllocSize
- );
+ )
+/*++
+
+Routine Description:
+
+ Uhci Allocate Pool
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ Pool - Place to store pointer to the memory buffer
+ AllocSize - Alloc Size
+
+Returns:
+
+ EFI_SUCCESS - Success
+
+--*/
+;
VOID
UhciFreePool (
IN USB_HC_DEV *HcDev,
IN UINT8 *Pool,
IN UINTN AllocSize
- );
+ )
+/*++
+
+Routine Description:
+
+ Uhci Free Pool
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+ Pool - Pool to free
+ AllocSize - Pool size
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
InsertMemoryHeaderToList (
IN MEMORY_MANAGE_HEADER *MemoryHeader,
IN MEMORY_MANAGE_HEADER *NewMemoryHeader
- );
+ )
+/*++
+
+Routine Description:
+
+ Insert Memory Header To List
+
+Arguments:
+
+ MemoryHeader - MEMORY_MANAGE_HEADER
+ NewMemoryHeader - MEMORY_MANAGE_HEADER
+
+Returns:
+
+ VOID
+
+--*/
+;
EFI_STATUS
AllocMemInMemoryBlock (
IN MEMORY_MANAGE_HEADER *MemoryHeader,
IN VOID **Pool,
IN UINTN NumberOfMemoryUnit
- );
+ )
+/*++
+
+Routine Description:
+
+ Alloc Memory In MemoryBlock
+
+Arguments:
+
+ MemoryHeader - MEMORY_MANAGE_HEADER
+ Pool - Place to store pointer to memory
+ NumberOfMemoryUnit - Number Of Memory Unit
+
+Returns:
+
+ EFI_NOT_FOUND - Can't find the free memory
+ EFI_SUCCESS - Success
+
+--*/
+;
BOOLEAN
IsMemoryBlockEmptied (
IN MEMORY_MANAGE_HEADER *MemoryHeaderPtr
- );
+ )
+/*++
+
+/*++
+
+Routine Description:
+
+ Is Memory Block Emptied
+
+Arguments:
+
+ MemoryHeaderPtr - MEMORY_MANAGE_HEADER
+
+Returns:
+
+ TRUE - Empty
+ FALSE - Not Empty
+
+--*/
+;
VOID
DelinkMemoryBlock (
IN MEMORY_MANAGE_HEADER *FirstMemoryHeader,
IN MEMORY_MANAGE_HEADER *FreeMemoryHeader
- );
+ )
+/*++
+
+Routine Description:
+
+ Delink Memory Block
+
+Arguments:
+
+ FirstMemoryHeader - MEMORY_MANAGE_HEADER
+ NeedFreeMemoryHeader - MEMORY_MANAGE_HEADER
+
+Returns:
+
+ VOID
+
+--*/
+;
EFI_STATUS
DelMemoryManagement (
IN USB_HC_DEV *HcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Delete Memory Management
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS - Success
+
+--*/
+;
VOID
EnableMaxPacketSize (
IN USB_HC_DEV *HcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Enable Max Packet Size
+
+Arguments:
+
+ HcDev - USB_HC_DEV
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
CleanUsbTransactions (
IN USB_HC_DEV *HcDev
- );
+ )
+/*++
+
+Routine Description:
+
+ Clean USB Transactions
+
+Arguments:
+
+ HcDev - A point to USB_HC_DEV
+
+Returns:
+
+ VOID
+
+--*/
+;
VOID
TurnOffUSBEmulation (
IN EFI_PCI_IO_PROTOCOL *PciIo
- );
+ )
+/*++
+
+Routine Description:
+
+ Set current framelist QH or TD
+
+Arguments:
+
+ pCurEntry - A point to FRAMELIST_ENTITY
+ IsQH - TRUE to set QH and FALSE to set TD
+
+Returns:
+
+ VOID
+
+--*/
+;
#endif