PEIM to produce gPeiUsbHostControllerPpiGuid based on gPeiUsbControllerPpiGuid\r
which is used to enable recovery function from USB Drivers.\r
\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. <BR>\r
- \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution. The\r
-full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. <BR>\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
/**\r
Submits control transfer to a target USB device.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
@param DeviceAddress The target device address.\r
@param DeviceSpeed Target device speed.\r
- @param MaximumPacketLength Maximum packet size the default control transfer \r
+ @param MaximumPacketLength Maximum packet size the default control transfer\r
endpoint is capable of sending or receiving.\r
@param Request USB device request to send.\r
@param TransferDirection Specifies the data direction for the data stage.\r
\r
/**\r
Submits bulk transfer to a bulk endpoint of a USB device.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
@param DeviceAddress Target device address.\r
@param EndPointAddress Endpoint number and its direction in bit 7.\r
- @param MaximumPacketLength Maximum packet size the endpoint is capable of \r
+ @param MaximumPacketLength Maximum packet size the endpoint is capable of\r
sending or receiving.\r
- @param Data Array of pointers to the buffers of data to transmit \r
+ @param Data Array of pointers to the buffers of data to transmit\r
from or receive into.\r
@param DataLength The lenght of the data buffer.\r
@param DataToggle On input, the initial data toggle for the transfer;\r
- On output, it is updated to to next data toggle to use of \r
+ On output, it is updated to to next data toggle to use of\r
the subsequent bulk transfer.\r
@param TimeOut Indicates the maximum time, in millisecond, which the\r
transfer is allowed to complete.\r
Retrieves the number of root hub ports.\r
\r
@param[in] PeiServices The pointer to the PEI Services Table.\r
- @param[in] This The pointer to this instance of the \r
+ @param[in] This The pointer to this instance of the\r
PEI_USB_HOST_CONTROLLER_PPI.\r
- @param[out] PortNumber The pointer to the number of the root hub ports. \r
- \r
+ @param[out] PortNumber The pointer to the number of the root hub ports.\r
+\r
@retval EFI_SUCCESS The port number was retrieved successfully.\r
@retval EFI_INVALID_PARAMETER PortNumber is NULL.\r
\r
\r
/**\r
Retrieves the current status of a USB root hub port.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
- @param PortNumber The root hub port to retrieve the state from. \r
+ @param PortNumber The root hub port to retrieve the state from.\r
@param PortStatus Variable to receive the port state.\r
\r
@retval EFI_SUCCESS The status of the USB root hub port specified.\r
\r
/**\r
Sets a feature for the specified root hub port.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES\r
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI\r
@param PortNumber Root hub port to set.\r
\r
/**\r
Clears a feature for the specified root hub port.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
@param PortNumber Specifies the root hub port whose feature\r
@param PortFeature Indicates the feature selector associated with the\r
feature clear request.\r
\r
- @retval EFI_SUCCESS The feature specified by PortFeature was cleared \r
+ @retval EFI_SUCCESS The feature specified by PortFeature was cleared\r
for the USB root hub port specified by PortNumber.\r
@retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r
\r
ASSERT (UhcDev->BulkQH != NULL);\r
\r
//\r
- //Set the corresponding QH pointer \r
+ //Set the corresponding QH pointer\r
//\r
SetQHHorizontalLinkPtr(UhcDev->ConfigQH, UhcDev->BulkQH);\r
SetQHHorizontalQHorTDSelect (UhcDev->ConfigQH, TRUE);\r
\r
/**\r
Read a 16bit width data from Uhc HC IO space register.\r
- \r
+\r
@param UhcDev The UHCI device.\r
@param Port The IO space address of the register.\r
\r
\r
/**\r
Write a 16bit width data into Uhc HC IO space register.\r
- \r
+\r
@param UhcDev The UHCI device.\r
@param Port The IO space address of the register.\r
@param Data The data written into the register.\r
\r
/**\r
Write a 32bit width data into Uhc HC IO space register.\r
- \r
+\r
@param UhcDev The UHCI device.\r
@param Port The IO space address of the register.\r
@param Data The data written into the register.\r
\r
/**\r
Clear the content of UHCI's Status Register.\r
- \r
+\r
@param UhcDev The UHCI device.\r
@param StatusAddr The IO space address of the register.\r
\r
}\r
}\r
\r
-/**\r
- Get Current Frame Number.\r
-\r
- @param UhcDev The UHCI device.\r
- @param FrameNumberAddr The address of frame list register.\r
\r
- @retval The content of the frame list register.\r
-\r
-**/\r
-UINT16\r
-GetCurrentFrameNumber (\r
- IN USB_UHC_DEV *UhcDev,\r
- IN UINT32 FrameNumberAddr\r
- )\r
-{\r
- //\r
- // Gets value in the USB frame number register.\r
- //\r
- return (UINT16) (USBReadPortW (UhcDev, FrameNumberAddr) & 0x03FF);\r
-}\r
\r
/**\r
Set Frame List Base Address.\r
PtrQH->QueueHead.QHHorizontalPtr = (UINT32) (UINTN) PtrNext >> 4;\r
}\r
\r
-/**\r
- Get the horizontal link pointer in QH.\r
-\r
- @param PtrQH Place to store QH_STRUCT pointer.\r
\r
- @retval The horizontal link pointer in QH.\r
-\r
-**/\r
-VOID *\r
-GetQHHorizontalLinkPtr (\r
- IN QH_STRUCT *PtrQH\r
- )\r
-{\r
- //\r
- // Restore the 28bit address to 32bit address\r
- // (take 32bit address as an example)\r
- //\r
- return (VOID *) (UINTN) ((PtrQH->QueueHead.QHHorizontalPtr) << 4);\r
-}\r
\r
/**\r
Set a QH or TD horizontally to be connected with a specific QH.\r
PtrQH->QueueHead.QHVerticalTerminate = IsValid ? 0 : 1;\r
}\r
\r
-/**\r
- Get the vertical validor bit in QH.\r
-\r
- @param PtrQH Place to store QH_STRUCT pointer.\r
-\r
- @retval The vertical linker is valid or not.\r
\r
-**/\r
-BOOLEAN\r
-GetQHHorizontalValidorInvalid (\r
- IN QH_STRUCT *PtrQH\r
- )\r
-{\r
- //\r
- // If TRUE, meaning the Horizontal Link Pointer field is valid,\r
- // else, the field is invalid.\r
- //\r
- return (BOOLEAN) (!(PtrQH->QueueHead.QHHorizontalTerminate));\r
-}\r
\r
/**\r
Allocate TD or QH Struct.\r
return (VOID *) (UINTN) ((PtrTDStruct->TDData.TDLinkPtr) << 4);\r
}\r
\r
-/**\r
- Get the information about whether the Link Pointer field pointing to\r
- a QH or a TD.\r
-\r
- @param PtrTDStruct Place to store TD_STRUCT pointer.\r
-\r
- @retval whether the Link Pointer field pointing to a QH or a TD.\r
\r
-**/\r
-BOOLEAN\r
-IsTDLinkPtrQHOrTD (\r
- IN TD_STRUCT *PtrTDStruct\r
- )\r
-{\r
- //\r
- // Get the information about whether the Link Pointer field pointing to\r
- // a QH or a TD.\r
- //\r
- return (BOOLEAN) (PtrTDStruct->TDData.TDLinkPtrQSelect);\r
-}\r
\r
/**\r
Enable/Disable short packet detection mechanism.\r
&MappedAddr,\r
&Mapping\r
);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
+ if (EFI_ERROR (Status) || (TempPtr == NULL)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
\r
Ptr = TempPtr;\r
}\r
}\r
\r
-/**\r
- Judge the memory block in the memory header is empty or not.\r
-\r
- @param MemoryHeaderPtr A pointer to the memory header list.\r
\r
- @retval Whether the memory block in the memory header is empty or not.\r
\r
-**/\r
-BOOLEAN\r
-IsMemoryBlockEmptied (\r
- IN MEMORY_MANAGE_HEADER *MemoryHeaderPtr\r
- )\r
-{\r
- UINTN Index;\r
-\r
- for (Index = 0; Index < MemoryHeaderPtr->BitArraySizeInBytes; Index++) {\r
- if (MemoryHeaderPtr->BitArrayPtr[Index] != 0) {\r
- return FALSE;\r
- }\r
- }\r
\r
- return TRUE;\r
-}\r
-\r
-/**\r
- remove a memory header from list.\r
-\r
- @param FirstMemoryHeader A pointer to the memory header list.\r
- @param FreeMemoryHeader A memory header to be removed into the list.\r
-\r
-**/\r
-VOID\r
-DelinkMemoryBlock (\r
- IN MEMORY_MANAGE_HEADER *FirstMemoryHeader,\r
- IN MEMORY_MANAGE_HEADER *FreeMemoryHeader\r
- )\r
-{\r
- MEMORY_MANAGE_HEADER *TempHeaderPtr;\r
-\r
- if ((FirstMemoryHeader == NULL) || (FreeMemoryHeader == NULL)) {\r
- return ;\r
- }\r
-\r
- for (TempHeaderPtr = FirstMemoryHeader; TempHeaderPtr != NULL; TempHeaderPtr = TempHeaderPtr->Next) {\r
-\r
- if (TempHeaderPtr->Next == FreeMemoryHeader) {\r
- //\r
- // Link the before and after\r
- //\r
- TempHeaderPtr->Next = FreeMemoryHeader->Next;\r
- break;\r
- }\r
- }\r
-}\r
\r
/**\r
Map address of request structure buffer.\r