]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h
Import EhciDxe and UhciDxe into MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciSched.h
diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.h
new file mode 100644 (file)
index 0000000..cba65c6
--- /dev/null
@@ -0,0 +1,305 @@
+/** @file\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. 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
+\r
+Module Name:\r
+\r
+  UhciSched.h\r
+\r
+Abstract:\r
+\r
+  The definition for EHCI register operation routines.\r
+\r
+Revision History\r
+\r
+\r
+**/\r
+\r
+#ifndef _EFI_UHCI_SCHED_H_\r
+#define _EFI_UHCI_SCHED_H_\r
+\r
+\r
+enum {\r
+  UHCI_ASYNC_INT_SIGNATURE = EFI_SIGNATURE_32 ('u', 'h', 'c', 'a'),\r
+\r
+  //\r
+  // The failure mask for USB transfer return status. If any of\r
+  // these bit is set, the transfer failed. EFI_USB_ERR_NOEXECUTE\r
+  // and EFI_USB_ERR_NAK are not considered as error condition:\r
+  // the transfer is still going on.\r
+  //\r
+  USB_ERR_FAIL_MASK = EFI_USB_ERR_STALL   | EFI_USB_ERR_BUFFER |\r
+                      EFI_USB_ERR_BABBLE  | EFI_USB_ERR_CRC    |\r
+                      EFI_USB_ERR_TIMEOUT | EFI_USB_ERR_BITSTUFF |\r
+                      EFI_USB_ERR_SYSTEM,\r
+\r
+};\r
+\r
+//\r
+// Structure to return the result of UHCI QH execution.\r
+// Result is the final result of the QH's QTD. NextToggle\r
+// is the next data toggle to use. Complete is the actual\r
+// length of data transferred.\r
+//\r
+typedef struct {\r
+  UINT32                  Result;\r
+  UINT8                   NextToggle;\r
+  UINTN                   Complete;\r
+} UHCI_QH_RESULT;\r
+\r
+typedef struct _UHCI_ASYNC_REQUEST  UHCI_ASYNC_REQUEST;\r
+\r
+//\r
+// Structure used to manager the asynchronous interrupt transfers.\r
+//\r
+typedef struct _UHCI_ASYNC_REQUEST{\r
+  UINTN                           Signature;\r
+  LIST_ENTRY                      Link;\r
+  UHCI_ASYNC_REQUEST              *Recycle;\r
+\r
+  //\r
+  // Endpoint attributes\r
+  //\r
+  UINT8                           DevAddr;\r
+  UINT8                           EndPoint;\r
+  BOOLEAN                         IsLow;\r
+  UINTN                           Interval;\r
+\r
+  //\r
+  // Data and UHC structures\r
+  //\r
+  UHCI_QH_SW                      *QhSw;\r
+  UHCI_TD_SW                      *FirstTd;\r
+  UINT8                           *Data;      // Allocated host memory, not mapped memory\r
+  UINTN                           DataLen;\r
+  VOID                            *Mapping;\r
+\r
+  //\r
+  // User callback and its context\r
+  //\r
+  EFI_ASYNC_USB_TRANSFER_CALLBACK Callback;\r
+  VOID                            *Context;\r
+} UHCI_ASYNC_REQUEST;\r
+\r
+#define UHCI_ASYNC_INT_FROM_LINK(a) \\r
+          CR (a, UHCI_ASYNC_REQUEST, Link, UHCI_ASYNC_INT_SIGNATURE)\r
+\r
+EFI_STATUS\r
+UhciInitFrameList (\r
+  IN USB_HC_DEV         *Uhc\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create Frame List Structure\r
+\r
+Arguments:\r
+\r
+  Uhc         - UHCI device\r
+\r
+Returns:\r
+\r
+  EFI_OUT_OF_RESOURCES - Can't allocate memory resources\r
+  EFI_UNSUPPORTED      - Map memory fail\r
+  EFI_SUCCESS          - Success\r
+\r
+--*/\r
+;\r
+\r
+\r
+/**\r
+  Destory FrameList buffer\r
+\r
+  @param  Uhc                    The UHCI device\r
+\r
+  @return VOID\r
+\r
+**/\r
+VOID\r
+UhciDestoryFrameList (\r
+  IN USB_HC_DEV           *Uhc\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Convert the poll rate to the maxium 2^n that is smaller\r
+  than Interval\r
+\r
+  @param  Interval               The poll rate to convert\r
+\r
+  @return The converted poll rate\r
+\r
+**/\r
+UINTN\r
+UhciConvertPollRate (\r
+  IN  UINTN               Interval\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Link a queue head (for asynchronous interrupt transfer) to\r
+  the frame list.\r
+\r
+  @param  FrameBase              The base of the frame list\r
+  @param  Qh                     The queue head to link into\r
+\r
+  @return None\r
+\r
+**/\r
+VOID\r
+UhciLinkQhToFrameList (\r
+  UINT32                  *FrameBase,\r
+  UHCI_QH_SW              *Qh\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Unlink QH from the frame list is easier: find all\r
+  the precedence node, and pointer there next to QhSw's\r
+  next.\r
+\r
+  @param  FrameBase              The base address of the frame list\r
+  @param  Qh                     The queue head to unlink\r
+\r
+  @return None\r
+\r
+**/\r
+VOID\r
+UhciUnlinkQhFromFrameList (\r
+  UINT32                *FrameBase,\r
+  UHCI_QH_SW            *Qh\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Check the result of the transfer\r
+\r
+  @param  Uhc                    The UHCI device\r
+  @param  Td                     The first TDs of the transfer\r
+  @param  TimeOut                TimeOut value in milliseconds\r
+  @param  IsLow                  Is Low Speed Device\r
+  @param  QhResult               The variable to return result\r
+\r
+  @retval EFI_SUCCESS            The transfer finished with success\r
+  @retval EFI_DEVICE_ERROR       Transfer failed\r
+\r
+**/\r
+EFI_STATUS\r
+UhciExecuteTransfer (\r
+  IN  USB_HC_DEV          *Uhc,\r
+  IN  UHCI_QH_SW          *Qh,\r
+  IN  UHCI_TD_SW          *Td,\r
+  IN  UINTN               TimeOut,\r
+  IN  BOOLEAN             IsLow,\r
+  OUT UHCI_QH_RESULT      *QhResult\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Create Async Request node, and Link to List\r
+\r
+  @param  Uhc                    The UHCI device\r
+  @param  Qh                     The queue head of the transfer\r
+  @param  FirstTd                First TD of the transfer\r
+  @param  DevAddr                Device Address\r
+  @param  EndPoint               EndPoint Address\r
+  @param  Toggle                 Data Toggle\r
+  @param  DataLen                Data length\r
+  @param  Interval               Polling Interval when inserted to frame list\r
+  @param  Mapping                Mapping value\r
+  @param  Data                   Data buffer, unmapped\r
+  @param  Callback               Callback after interrupt transfeer\r
+  @param  Context                Callback Context passed as function parameter\r
+  @param  IsLow                  Is Low Speed\r
+\r
+  @retval EFI_SUCCESS            An asynchronous transfer is created\r
+  @retval EFI_INVALID_PARAMETER  Paremeter is error\r
+  @retval EFI_OUT_OF_RESOURCES   Failed because of resource shortage.\r
+\r
+**/\r
+EFI_STATUS\r
+UhciCreateAsyncReq (\r
+  IN USB_HC_DEV                       *Uhc,\r
+  IN UHCI_QH_SW                       *Qh,\r
+  IN UHCI_TD_SW                       *FirstTd,\r
+  IN UINT8                            DevAddr,\r
+  IN UINT8                            EndPoint,\r
+  IN UINTN                            DataLen,\r
+  IN UINTN                            Interval,\r
+  IN VOID                             *Mapping,\r
+  IN UINT8                            *Data,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK  Callback,\r
+  IN VOID                             *Context,\r
+  IN BOOLEAN                          IsLow\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Delete Async Interrupt QH and TDs\r
+\r
+  @param  Uhc                    The UHCI device\r
+  @param  DevAddr                Device Address\r
+  @param  EndPoint               EndPoint Address\r
+  @param  Toggle                 The next data toggle to use\r
+\r
+  @retval EFI_SUCCESS            The request is deleted\r
+  @retval EFI_INVALID_PARAMETER  Paremeter is error\r
+  @retval EFI_NOT_FOUND          The asynchronous isn't found\r
+\r
+**/\r
+EFI_STATUS\r
+UhciRemoveAsyncReq (\r
+  IN  USB_HC_DEV          *Uhc,\r
+  IN  UINT8               DevAddr,\r
+  IN  UINT8               EndPoint,\r
+  OUT UINT8               *Toggle\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Release all the asynchronous transfers on the lsit.\r
+\r
+  @param  Uhc                    The UHCI device\r
+\r
+  @return VOID\r
+\r
+**/\r
+VOID\r
+UhciFreeAllAsyncReq (\r
+  IN USB_HC_DEV           *Uhc\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Interrupt transfer periodic check handler\r
+\r
+  @param  Event                  The event of the time\r
+  @param  Context                Context of the event, pointer to USB_HC_DEV\r
+\r
+  @return VOID\r
+\r
+**/\r
+VOID\r
+UhciMonitorAsyncReqList (\r
+  IN EFI_EVENT            Event,\r
+  IN VOID                 *Context\r
+  )\r
+;\r
+\r
+#endif\r