]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg EhciDxe: Extract new EhciInsertAsyncIntTransfer function
authorStar Zeng <star.zeng@intel.com>
Wed, 24 Oct 2018 11:27:22 +0000 (19:27 +0800)
committerStar Zeng <star.zeng@intel.com>
Sun, 28 Oct 2018 13:20:07 +0000 (21:20 +0800)
V3:
Match function parameter name and description between
EhciSched.c and EhciSched.h.

V2:
Add the missing "gBS->FreePool (Data);".

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1274

Extract new EhciInsertAsyncIntTransfer function from
EhcAsyncInterruptTransfer.

It is code preparation for following patch,
no essential functional change.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.h

index 50b5598df4fb9c6fb3252cd1330dc040897cfa2a..5569f4f9618b9f2b4997398e959c83f7c5e50258 100644 (file)
@@ -997,7 +997,6 @@ EhcAsyncInterruptTransfer (
   URB                     *Urb;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
-  UINT8                   *Data;\r
 \r
   //\r
   // Validate parameters\r
@@ -1046,16 +1045,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
@@ -1063,9 +1053,6 @@ EhcAsyncInterruptTransfer (
           *DataToggle,\r
           MaximumPacketLength,\r
           Translator,\r
-          EHC_INT_TRANSFER_ASYNC,\r
-          NULL,\r
-          Data,\r
           DataLength,\r
           CallBackFunction,\r
           Context,\r
@@ -1073,20 +1060,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
index 168280be81d7d7a4ce02dfc33d933db35a14b3cf..ec8d796fab110995d086ce722d7c7922d7bd40c7 100644 (file)
@@ -814,6 +814,82 @@ EhciDelAllAsyncIntTransfers (
   }\r
 }\r
 \r
+/**\r
+  Insert a single asynchronous interrupt transfer for\r
+  the device and endpoint.\r
+\r
+  @param  Ehc               The EHCI device.\r
+  @param  DevAddr           The device address.\r
+  @param  EpAddr            Endpoint addrress & its direction.\r
+  @param  DevSpeed          The device speed.\r
+  @param  Toggle            Initial data toggle to use.\r
+  @param  MaxPacket         The max packet length of the endpoint.\r
+  @param  Hub               The transaction translator to use.\r
+  @param  DataLen           The length of data buffer.\r
+  @param  Callback          The function to call when data is transferred.\r
+  @param  Context           The context to the callback.\r
+  @param  Interval          The interval for interrupt transfer.\r
+\r
+  @return Created URB or NULL.\r
+\r
+**/\r
+URB *\r
+EhciInsertAsyncIntTransfer (\r
+  IN USB2_HC_DEV                        *Ehc,\r
+  IN UINT8                              DevAddr,\r
+  IN UINT8                              EpAddr,\r
+  IN UINT8                              DevSpeed,\r
+  IN UINT8                              Toggle,\r
+  IN UINTN                              MaxPacket,\r
+  IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,\r
+  IN UINTN                              DataLen,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK    Callback,\r
+  IN VOID                               *Context,\r
+  IN UINTN                              Interval\r
+  )\r
+{\r
+  VOID      *Data;\r
+  URB       *Urb;\r
+\r
+  Data = AllocatePool (DataLen);\r
+\r
+  if (Data == NULL) {\r
+    DEBUG ((DEBUG_ERROR, "%a: failed to allocate buffer\n", __FUNCTION__));\r
+    return NULL;\r
+  }\r
+\r
+  Urb = EhcCreateUrb (\r
+          Ehc,\r
+          DevAddr,\r
+          EpAddr,\r
+          DevSpeed,\r
+          Toggle,\r
+          MaxPacket,\r
+          Hub,\r
+          EHC_INT_TRANSFER_ASYNC,\r
+          NULL,\r
+          Data,\r
+          DataLen,\r
+          Callback,\r
+          Context,\r
+          Interval\r
+          );\r
+\r
+  if (Urb == NULL) {\r
+    DEBUG ((DEBUG_ERROR, "%a: failed to create URB\n", __FUNCTION__));\r
+    gBS->FreePool (Data);\r
+    return NULL;\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
+  return Urb;\r
+}\r
 \r
 /**\r
   Flush data from PCI controller specific address to mapped system\r
index c03bd619d7e8129f36b56daf8d1a0957285bcc2c..e0c430531fafdd8237bfc4c12346ba03b1c7e641 100644 (file)
@@ -2,7 +2,7 @@
 \r
   This file contains the definination for host controller schedule routines.\r
 \r
-Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 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
@@ -162,6 +162,39 @@ EhciDelAllAsyncIntTransfers (
   IN USB2_HC_DEV          *Ehc\r
   );\r
 \r
+/**\r
+  Insert a single asynchronous interrupt transfer for\r
+  the device and endpoint.\r
+\r
+  @param  Ehc               The EHCI device.\r
+  @param  DevAddr           The device address.\r
+  @param  EpAddr            Endpoint addrress & its direction.\r
+  @param  DevSpeed          The device speed.\r
+  @param  Toggle            Initial data toggle to use.\r
+  @param  MaxPacket         The max packet length of the endpoint.\r
+  @param  Hub               The transaction translator to use.\r
+  @param  DataLen           The length of data buffer.\r
+  @param  Callback          The function to call when data is transferred.\r
+  @param  Context           The context to the callback.\r
+  @param  Interval          The interval for interrupt transfer.\r
+\r
+  @return Created URB or NULL.\r
+\r
+**/\r
+URB *\r
+EhciInsertAsyncIntTransfer (\r
+  IN USB2_HC_DEV                        *Ehc,\r
+  IN UINT8                              DevAddr,\r
+  IN UINT8                              EpAddr,\r
+  IN UINT8                              DevSpeed,\r
+  IN UINT8                              Toggle,\r
+  IN UINTN                              MaxPacket,\r
+  IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,\r
+  IN UINTN                              DataLen,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK    Callback,\r
+  IN VOID                               *Context,\r
+  IN UINTN                              Interval\r
+  );\r
 \r
 /**\r
   Interrupt transfer periodic check handler.\r