]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciPei / UhcPeim.c
index b7d60db0c94e090f70a7bd80352b41494257d96c..b897c3f82ce6e61734ddadb39639d86f5871ae96 100644 (file)
@@ -2,16 +2,9 @@
 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
@@ -220,12 +213,12 @@ UhcPeimEntry (
 \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
@@ -458,18 +451,18 @@ UhcControlTransfer (
 \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
@@ -694,10 +687,10 @@ UhcBulkTransfer (
   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
@@ -739,10 +732,10 @@ UhcGetRootHubPortNumber (
 \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
@@ -832,7 +825,7 @@ UhcGetRootHubPortStatus (
 \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
@@ -908,7 +901,7 @@ UhcSetRootHubPortFeature (
 \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
@@ -916,7 +909,7 @@ UhcSetRootHubPortFeature (
   @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
@@ -1131,7 +1124,7 @@ CreateFrameList (
   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
@@ -1154,7 +1147,7 @@ CreateFrameList (
 \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
@@ -1172,7 +1165,7 @@ USBReadPortW (
 \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
@@ -1190,7 +1183,7 @@ USBWritePortW (
 \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
@@ -1208,7 +1201,7 @@ USBWritePortDW (
 \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
@@ -1252,26 +1245,7 @@ IsStatusOK (
   }\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
@@ -1349,25 +1323,7 @@ SetQHHorizontalLinkPtr (
   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
@@ -1470,25 +1426,7 @@ SetQHVerticalValidorInvalid (
   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
@@ -2000,26 +1938,7 @@ GetTDLinkPtr (
   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
@@ -2863,8 +2782,8 @@ CreateMemoryBlock (
              &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
@@ -3239,60 +3158,9 @@ InsertMemoryHeaderToList (
   }\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