]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.c
index 89ed034b9093151e839b06e323f5a7121c3be9d6..bdd9c27db562aa204b120247be751269e27d2bec 100644 (file)
   USB 2.0 device inserts.\r
 \r
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\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
@@ -121,7 +115,6 @@ EhcReset (
   USB2_HC_DEV             *Ehc;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
-  UINT32                  DbgCtrlStatus;\r
 \r
   Ehc = EHC_FROM_THIS (This);\r
 \r
@@ -147,12 +140,9 @@ EhcReset (
     //\r
     // Host Controller must be Halt when Reset it\r
     //\r
-    if (Ehc->DebugPortNum != 0) {\r
-      DbgCtrlStatus = EhcReadDbgRegister(Ehc, 0);\r
-      if ((DbgCtrlStatus & (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) == (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) {\r
-        Status = EFI_SUCCESS;\r
-        goto ON_EXIT;\r
-      }\r
+    if (EhcIsDebugPortInUse (Ehc, NULL)) {\r
+      Status = EFI_SUCCESS;\r
+      goto ON_EXIT;\r
     }\r
 \r
     if (!EhcIsHalt (Ehc)) {\r
@@ -345,7 +335,6 @@ EhcGetRootHubPortStatus (
   UINTN                   Index;\r
   UINTN                   MapSize;\r
   EFI_STATUS              Status;\r
-  UINT32                  DbgCtrlStatus;\r
 \r
   if (PortStatus == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -367,11 +356,8 @@ EhcGetRootHubPortStatus (
   PortStatus->PortStatus        = 0;\r
   PortStatus->PortChangeStatus  = 0;\r
 \r
-  if ((Ehc->DebugPortNum != 0) && (PortNumber == (Ehc->DebugPortNum - 1))) {\r
-    DbgCtrlStatus = EhcReadDbgRegister(Ehc, 0);\r
-    if ((DbgCtrlStatus & (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) == (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) {\r
-      goto ON_EXIT;\r
-    }\r
+  if (EhcIsDebugPortInUse (Ehc, &PortNumber)) {\r
+    goto ON_EXIT;\r
   }\r
 \r
   State                         = EhcReadOpReg (Ehc, Offset);\r
@@ -1005,7 +991,6 @@ EhcAsyncInterruptTransfer (
   URB                     *Urb;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
-  UINT8                   *Data;\r
 \r
   //\r
   // Validate parameters\r
@@ -1054,16 +1039,7 @@ EhcAsyncInterruptTransfer (
 \r
   EhcAckAllInterrupt (Ehc);\r
 \r
-  Data = AllocatePool (DataLength);\r
-\r
-  if (Data == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to allocate buffer\n"));\r
-\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  Urb = EhcCreateUrb (\r
+  Urb = EhciInsertAsyncIntTransfer (\r
           Ehc,\r
           DeviceAddress,\r
           EndPointAddress,\r
@@ -1071,9 +1047,6 @@ EhcAsyncInterruptTransfer (
           *DataToggle,\r
           MaximumPacketLength,\r
           Translator,\r
-          EHC_INT_TRANSFER_ASYNC,\r
-          NULL,\r
-          Data,\r
           DataLength,\r
           CallBackFunction,\r
           Context,\r
@@ -1081,20 +1054,10 @@ EhcAsyncInterruptTransfer (
           );\r
 \r
   if (Urb == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to create URB\n"));\r
-\r
-    gBS->FreePool (Data);\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_EXIT;\r
   }\r
 \r
-  //\r
-  // New asynchronous transfer must inserted to the head.\r
-  // Check the comments in EhcMoniteAsyncRequests\r
-  //\r
-  EhcLinkQhToPeriod (Ehc, Urb->Qh);\r
-  InsertHeadList (&Ehc->AsyncIntTransfers, &Urb->UrbList);\r
-\r
 ON_EXIT:\r
   Ehc->PciIo->Flush (Ehc->PciIo);\r
   gBS->RestoreTPL (OldTpl);\r
@@ -1696,7 +1659,6 @@ EhcDriverBindingStart (
   UINTN                   EhciBusNumber;\r
   UINTN                   EhciDeviceNumber;\r
   UINTN                   EhciFunctionNumber;\r
-  UINT32                  State;\r
   EFI_DEVICE_PATH_PROTOCOL  *HcDevicePath;\r
 \r
   //\r
@@ -1918,13 +1880,8 @@ EhcDriverBindingStart (
     EhcClearLegacySupport (Ehc);\r
   }\r
 \r
-  if (Ehc->DebugPortNum == 0) {\r
+  if (!EhcIsDebugPortInUse (Ehc, NULL)) {\r
     EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
-  } else {\r
-    State = EhcReadDbgRegister(Ehc, 0);\r
-    if ((State & (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) != (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) {\r
-      EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
-    }\r
   }\r
 \r
   Status = EhcInitHC (Ehc);\r