]> git.proxmox.com Git - mirror_edk2.git/blobdiff - QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciSched.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Usb / Ohci / Dxe / OhciSched.h
diff --git a/QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciSched.h b/QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciSched.h
new file mode 100644 (file)
index 0000000..8a86382
--- /dev/null
@@ -0,0 +1,231 @@
+/** @file\r
+This file contains the definination for host controller schedule routines.\r
+\r
+Copyright (c) 2013-2015 Intel Corporation.\r
+\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
+\r
+**/\r
+\r
+\r
+\r
+#ifndef _OHCI_SCHED_H\r
+#define _OHCI_SCHED_H\r
+\r
+#include "Descriptor.h"\r
+\r
+#define HCCA_MEM_SIZE     256\r
+#define GRID_SIZE         16\r
+#define GRID_SHIFT        4\r
+\r
+typedef struct _INTERRUPT_CONTEXT_ENTRY INTERRUPT_CONTEXT_ENTRY;\r
+\r
+struct _INTERRUPT_CONTEXT_ENTRY{\r
+  UINT8                               DeviceAddress;\r
+  UINT8                               EndPointAddress;\r
+  ED_DESCRIPTOR                       *Ed;\r
+  TD_DESCRIPTOR                       *DataTd;\r
+  BOOLEAN                             IsSlowDevice;\r
+  UINT8                               MaxPacketLength;\r
+  UINTN                               PollingInterval;\r
+  EFI_ASYNC_USB_TRANSFER_CALLBACK     CallBackFunction;\r
+  VOID                                *Context;\r
+  BOOLEAN                             IsPeriodic;\r
+  VOID                                *Buffer;\r
+  UINTN                               DataLength;\r
+  VOID                                *UCBuffer;\r
+  VOID                                *UCBufferMapping;\r
+  UINT8                               *Toggle;\r
+  INTERRUPT_CONTEXT_ENTRY      *NextEntry;\r
+};\r
+\r
+\r
+typedef struct {\r
+  UINT32                  ErrorCode;\r
+  UINT8                   NextToggle;\r
+} OHCI_ED_RESULT;\r
+\r
+/**\r
+\r
+  Add an item of interrupt context\r
+\r
+  @param  Ohc                   UHC private data\r
+  @param  NewEntry              New entry to add\r
+\r
+  @retval EFI_SUCCESS           Item successfully added\r
+\r
+**/\r
+EFI_STATUS\r
+OhciAddInterruptContextEntry (\r
+  IN  USB_OHCI_HC_DEV          *Ohc,\r
+  IN  INTERRUPT_CONTEXT_ENTRY  *NewEntry\r
+  );\r
+\r
+/**\r
+\r
+  Free a interrupt context entry\r
+\r
+  @param  Ohc                   UHC private data\r
+  @param  Entry                 Pointer to an interrupt context entry\r
+\r
+  @retval EFI_SUCCESS           Entry freed\r
+  @retval EFI_INVALID_PARAMETER Entry is NULL\r
+\r
+**/\r
+EFI_STATUS\r
+OhciFreeInterruptContextEntry (\r
+  IN USB_OHCI_HC_DEV          *Ohc,\r
+  IN INTERRUPT_CONTEXT_ENTRY  *Entry\r
+  );\r
+\r
+/**\r
+\r
+  Free entries match the device address and endpoint address\r
+\r
+  @Param  Ohc                   UHC private date\r
+  @Param  DeviceAddress         Item to free must match this device address\r
+  @Param  EndPointAddress       Item to free must match this end point address\r
+  @Param  DataToggle            DataToggle for output\r
+\r
+  @retval  EFI_SUCCESS          Items match the requirement removed\r
+\r
+**/\r
+EFI_STATUS\r
+OhciFreeInterruptContext(\r
+  IN  USB_OHCI_HC_DEV     *Ohc,\r
+  IN  UINT8               DeviceAddress,\r
+  IN  UINT8               EndPointAddress,\r
+  OUT UINT8               *DataToggle\r
+  );\r
+\r
+\r
+/**\r
+\r
+  Convert Error code from OHCI format to EFI format\r
+\r
+  @Param  ErrorCode             ErrorCode in OHCI format\r
+\r
+  @retval                       ErrorCode in EFI format\r
+\r
+**/\r
+UINT32\r
+ConvertErrorCode (\r
+  IN  UINT32              ErrorCode\r
+  );\r
+\r
+\r
+/**\r
+\r
+  Check TDs Results\r
+\r
+  @Param  Ohc                   UHC private data\r
+  @Param  Td                    TD_DESCRIPTOR\r
+  @Param  Result                Result to return\r
+\r
+  @retval TRUE                  means OK\r
+  @retval FLASE                 means Error or Short packet\r
+\r
+**/\r
+BOOLEAN\r
+OhciCheckTDsResults (\r
+  IN  USB_OHCI_HC_DEV     *Ohc,\r
+  IN  TD_DESCRIPTOR       *Td,\r
+  OUT UINT32              *Result\r
+  );\r
+/**\r
+\r
+  Check the task status on an ED\r
+\r
+  @Param  Ed                    Pointer to the ED task that TD hooked on\r
+  @Param  HeadTd                TD header for current transaction\r
+\r
+  @retval                       Task Status Code\r
+\r
+**/\r
+\r
+UINT32\r
+CheckEDStatus (\r
+  IN  ED_DESCRIPTOR       *Ed,\r
+  IN  TD_DESCRIPTOR       *HeadTd,\r
+  OUT OHCI_ED_RESULT      *EdResult\r
+  );\r
+/**\r
+\r
+  Check the task status\r
+\r
+  @Param  Ohc                   UHC private data\r
+  @Param  ListType              Pipe type\r
+  @Param  Ed                    Pointer to the ED task hooked on\r
+  @Param  HeadTd                Head of TD corresponding to the task\r
+  @Param  ErrorCode             return the ErrorCode\r
+\r
+  @retval  EFI_SUCCESS          Task done\r
+  @retval  EFI_NOT_READY        Task on processing\r
+  @retval  EFI_DEVICE_ERROR     Some error occured\r
+\r
+**/\r
+EFI_STATUS\r
+CheckIfDone (\r
+  IN  USB_OHCI_HC_DEV       *Ohc,\r
+  IN  DESCRIPTOR_LIST_TYPE  ListType,\r
+  IN  ED_DESCRIPTOR         *Ed,\r
+  IN  TD_DESCRIPTOR         *HeadTd,\r
+  OUT OHCI_ED_RESULT        *EdResult\r
+  );\r
+\r
+/**\r
+\r
+  Convert TD condition code to Efi Status\r
+\r
+  @Param  ConditionCode         Condition code to convert\r
+\r
+  @retval  EFI_SUCCESS          No error occured\r
+  @retval  EFI_NOT_READY        TD still on processing\r
+  @retval  EFI_DEVICE_ERROR     Error occured in processing TD\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+OhciTDConditionCodeToStatus (\r
+  IN  UINT32              ConditionCode\r
+  );\r
+\r
+/**\r
+\r
+  Invoke callbacks hooked on done TDs\r
+\r
+  @Param  Entry                 Interrupt transfer transaction information data structure\r
+  @Param  Context               Ohc private data\r
+\r
+**/\r
+\r
+VOID\r
+OhciInvokeInterruptCallBack(\r
+  IN  INTERRUPT_CONTEXT_ENTRY  *Entry,\r
+  IN  UINT32                   Result\r
+);\r
+\r
+\r
+/**\r
+\r
+  Timer to submit periodic interrupt transfer, and invoke callbacks hooked on done TDs\r
+\r
+  @param  Event                 Event handle\r
+  @param  Context               Device private data\r
+\r
+**/\r
+\r
+VOID\r
+EFIAPI\r
+OhciHouseKeeper (\r
+  IN  EFI_EVENT           Event,\r
+  IN  VOID                *Context\r
+  );\r
+\r
+#endif\r