]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / XhciDxe / XhciSched.h
index 227b4552305aa0dabff6c198d17966a86b6089fe..2f18995021518f27c05d66202bad3c76a36ad439 100644 (file)
@@ -2,14 +2,8 @@
 \r
   This file contains the definition for XHCI host controller schedule routines.\r
 \r
-Copyright (c) 2011 - 2012, 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
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -80,6 +74,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define TRB_COMPLETION_TRB_ERROR              5\r
 #define TRB_COMPLETION_STALL_ERROR            6\r
 #define TRB_COMPLETION_SHORT_PACKET           13\r
+#define TRB_COMPLETION_STOPPED                26\r
+#define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27\r
 \r
 //\r
 // The topology string used to present usb device location\r
@@ -172,6 +168,8 @@ typedef struct _URB {
   EFI_USB_DEVICE_REQUEST          *Request;\r
   VOID                            *Data;\r
   UINTN                           DataLen;\r
+  VOID                            *DataPhy;\r
+  VOID                            *DataMap;\r
   EFI_ASYNC_USB_TRANSFER_CALLBACK Callback;\r
   VOID                            *Context;\r
   //\r
@@ -222,7 +220,7 @@ typedef struct _TRANSFER_TRB_NORMAL {
 \r
   UINT32                  TRBPtrHi;\r
 \r
-  UINT32                  Lenth:17;\r
+  UINT32                  Length:17;\r
   UINT32                  TDSize:5;\r
   UINT32                  IntTarget:10;\r
 \r
@@ -251,7 +249,7 @@ typedef struct _TRANSFER_TRB_CONTROL_SETUP {
   UINT32                  wIndex:16;\r
   UINT32                  wLength:16;\r
 \r
-  UINT32                  Lenth:17;\r
+  UINT32                  Length:17;\r
   UINT32                  RsvdZ1:5;\r
   UINT32                  IntTarget:10;\r
 \r
@@ -274,7 +272,7 @@ typedef struct _TRANSFER_TRB_CONTROL_DATA {
 \r
   UINT32                  TRBPtrHi;\r
 \r
-  UINT32                  Lenth:17;\r
+  UINT32                  Length:17;\r
   UINT32                  TDSize:5;\r
   UINT32                  IntTarget:10;\r
 \r
@@ -323,7 +321,7 @@ typedef struct _EVT_TRB_TRANSFER {
 \r
   UINT32                  TRBPtrHi;\r
 \r
-  UINT32                  Lenth:24;\r
+  UINT32                  Length:24;\r
   UINT32                  Completecode:8;\r
 \r
   UINT32                  CycleBit:1;\r
@@ -616,7 +614,7 @@ typedef struct _SLOT_CONTEXT_64 {
   UINT32                  RsvdZ9;\r
   UINT32                  RsvdZ10;\r
   UINT32                  RsvdZ11;\r
-  \r
+\r
   UINT32                  RsvdZ12;\r
   UINT32                  RsvdZ13;\r
   UINT32                  RsvdZ14;\r
@@ -684,12 +682,12 @@ typedef struct _ENDPOINT_CONTEXT_64 {
   UINT32                  RsvdZ5;\r
   UINT32                  RsvdZ6;\r
   UINT32                  RsvdZ7;\r
-  \r
+\r
   UINT32                  RsvdZ8;\r
   UINT32                  RsvdZ9;\r
   UINT32                  RsvdZ10;\r
   UINT32                  RsvdZ11;\r
-  \r
+\r
   UINT32                  RsvdZ12;\r
   UINT32                  RsvdZ13;\r
   UINT32                  RsvdZ14;\r
@@ -848,6 +846,34 @@ XhciDelAllAsyncIntTransfers (
   IN USB_XHCI_INSTANCE    *Xhc\r
   );\r
 \r
+/**\r
+  Insert a single asynchronous interrupt transfer for\r
+  the device and endpoint.\r
+\r
+  @param Xhc            The XHCI Instance\r
+  @param BusAddr        The logical device address assigned by UsbBus driver\r
+  @param EpAddr         Endpoint addrress\r
+  @param DevSpeed       The device speed\r
+  @param MaxPacket      The max packet length of the endpoint\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
+\r
+  @return Created URB or NULL\r
+\r
+**/\r
+URB *\r
+XhciInsertAsyncIntTransfer (\r
+  IN USB_XHCI_INSTANCE                  *Xhc,\r
+  IN UINT8                              BusAddr,\r
+  IN UINT8                              EpAddr,\r
+  IN UINT8                              DevSpeed,\r
+  IN UINTN                              MaxPacket,\r
+  IN UINTN                              DataLen,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK    Callback,\r
+  IN VOID                               *Context\r
+  );\r
+\r
 /**\r
   Set Bios Ownership\r
 \r
@@ -1039,6 +1065,49 @@ XhcSetConfigCmd64 (
   IN USB_CONFIG_DESCRIPTOR    *ConfigDesc\r
   );\r
 \r
+/**\r
+  Set interface through XHCI's Configure_Endpoint cmd.\r
+\r
+  @param  Xhc           The XHCI Instance.\r
+  @param  SlotId        The slot id to be configured.\r
+  @param  DeviceSpeed   The device's speed.\r
+  @param  ConfigDesc    The pointer to the usb device configuration descriptor.\r
+  @param  Request       USB device request to send.\r
+\r
+  @retval EFI_SUCCESS   Successfully set interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcSetInterface (\r
+  IN USB_XHCI_INSTANCE        *Xhc,\r
+  IN UINT8                    SlotId,\r
+  IN UINT8                    DeviceSpeed,\r
+  IN USB_CONFIG_DESCRIPTOR    *ConfigDesc,\r
+  IN EFI_USB_DEVICE_REQUEST   *Request\r
+  );\r
+\r
+/**\r
+  Set interface through XHCI's Configure_Endpoint cmd.\r
+\r
+  @param  Xhc           The XHCI Instance.\r
+  @param  SlotId        The slot id to be configured.\r
+  @param  DeviceSpeed   The device's speed.\r
+  @param  ConfigDesc    The pointer to the usb device configuration descriptor.\r
+  @param  Request       USB device request to send.\r
+\r
+  @retval EFI_SUCCESS   Successfully set interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcSetInterface64 (\r
+  IN USB_XHCI_INSTANCE        *Xhc,\r
+  IN UINT8                    SlotId,\r
+  IN UINT8                    DeviceSpeed,\r
+  IN USB_CONFIG_DESCRIPTOR    *ConfigDesc,\r
+  IN EFI_USB_DEVICE_REQUEST   *Request\r
+  );\r
 \r
 /**\r
   Find out the actual device address according to the requested device address from UsbBus.\r
@@ -1272,6 +1341,88 @@ XhcRecoverHaltedEndpoint (
   IN  URB                 *Urb\r
   );\r
 \r
+/**\r
+  System software shall use a Stop Endpoint Command (section 4.6.9) and the Set TR Dequeue Pointer\r
+  Command (section 4.6.10) to remove the timed-out TDs from the xHC transfer ring. The next write to\r
+  the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running\r
+  state.\r
+\r
+  @param  Xhc                   The XHCI Instance.\r
+  @param  Urb                   The urb which doesn't get completed in a specified timeout range.\r
+\r
+  @retval EFI_SUCCESS           The dequeuing of the TDs is successful.\r
+  @retval Others                Failed to stop the endpoint and dequeue the TDs.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcDequeueTrbFromEndpoint (\r
+  IN  USB_XHCI_INSTANCE   *Xhc,\r
+  IN  URB                 *Urb\r
+  );\r
+\r
+/**\r
+  Stop endpoint through XHCI's Stop_Endpoint cmd.\r
+\r
+  @param  Xhc                   The XHCI Instance.\r
+  @param  SlotId                The slot id to be configured.\r
+  @param  Dci                   The device context index of endpoint.\r
+  @param  PendingUrb            The pending URB to check completion status when stopping the end point.\r
+\r
+  @retval EFI_SUCCESS           Stop endpoint successfully.\r
+  @retval Others                Failed to stop endpoint.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcStopEndpoint (\r
+  IN USB_XHCI_INSTANCE      *Xhc,\r
+  IN UINT8                  SlotId,\r
+  IN UINT8                  Dci,\r
+  IN URB                    *PendingUrb  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Reset endpoint through XHCI's Reset_Endpoint cmd.\r
+\r
+  @param  Xhc                   The XHCI Instance.\r
+  @param  SlotId                The slot id to be configured.\r
+  @param  Dci                   The device context index of endpoint.\r
+\r
+  @retval EFI_SUCCESS           Reset endpoint successfully.\r
+  @retval Others                Failed to reset endpoint.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcResetEndpoint (\r
+  IN USB_XHCI_INSTANCE      *Xhc,\r
+  IN UINT8                  SlotId,\r
+  IN UINT8                  Dci\r
+  );\r
+\r
+/**\r
+  Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd.\r
+\r
+  @param  Xhc                   The XHCI Instance.\r
+  @param  SlotId                The slot id to be configured.\r
+  @param  Dci                   The device context index of endpoint.\r
+  @param  Urb                   The dequeue pointer of the transfer ring specified\r
+                                by the urb to be updated.\r
+\r
+  @retval EFI_SUCCESS           Set transfer ring dequeue pointer succeeds.\r
+  @retval Others                Failed to set transfer ring dequeue pointer.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+XhcSetTrDequeuePointer (\r
+  IN USB_XHCI_INSTANCE      *Xhc,\r
+  IN UINT8                  SlotId,\r
+  IN UINT8                  Dci,\r
+  IN URB                    *Urb\r
+  );\r
+\r
 /**\r
   Create a new URB for a new transaction.\r
 \r
@@ -1305,6 +1456,19 @@ XhcCreateUrb (
   IN VOID                               *Context\r
   );\r
 \r
+/**\r
+  Free an allocated URB.\r
+\r
+  @param  Xhc                   The XHCI device.\r
+  @param  Urb                   The URB to free.\r
+\r
+**/\r
+VOID\r
+XhcFreeUrb (\r
+  IN USB_XHCI_INSTANCE    *Xhc,\r
+  IN URB                  *Urb\r
+  );\r
+\r
 /**\r
   Create a transfer TRB.\r
 \r