]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
MdeModulePkg EhciDxe: Use common buffer for AsyncInterruptTransfer
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
... / ...
CommitLineData
1/** @file\r
2\r
3 Provides some data struct used by EHCI controller driver.\r
4\r
5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _EFI_EHCI_H_\r
17#define _EFI_EHCI_H_\r
18\r
19\r
20#include <Uefi.h>\r
21\r
22#include <Protocol/Usb2HostController.h>\r
23#include <Protocol/PciIo.h>\r
24\r
25#include <Guid/EventGroup.h>\r
26\r
27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
34#include <Library/PcdLib.h>\r
35#include <Library/ReportStatusCodeLib.h>\r
36\r
37#include <IndustryStandard/Pci.h>\r
38\r
39typedef struct _USB2_HC_DEV USB2_HC_DEV;\r
40\r
41#include "UsbHcMem.h"\r
42#include "EhciReg.h"\r
43#include "EhciUrb.h"\r
44#include "EhciSched.h"\r
45#include "EhciDebug.h"\r
46#include "ComponentName.h"\r
47\r
48//\r
49// EHC timeout experience values\r
50//\r
51\r
52#define EHC_1_MICROSECOND 1\r
53#define EHC_1_MILLISECOND (1000 * EHC_1_MICROSECOND)\r
54#define EHC_1_SECOND (1000 * EHC_1_MILLISECOND)\r
55\r
56//\r
57// EHCI register operation timeout, set by experience\r
58//\r
59#define EHC_RESET_TIMEOUT (1 * EHC_1_SECOND)\r
60#define EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND)\r
61\r
62//\r
63// Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r
64//\r
65#define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND)\r
66\r
67//\r
68// Sync and Async transfer polling interval, set by experience,\r
69// and the unit of Async is 100us, means 1ms as interval.\r
70//\r
71#define EHC_SYNC_POLL_INTERVAL (1 * EHC_1_MILLISECOND)\r
72#define EHC_ASYNC_POLL_INTERVAL EFI_TIMER_PERIOD_MILLISECONDS(1)\r
73\r
74//\r
75// EHCI debug port control status register bit definition\r
76//\r
77#define USB_DEBUG_PORT_IN_USE BIT10\r
78#define USB_DEBUG_PORT_ENABLE BIT28\r
79#define USB_DEBUG_PORT_OWNER BIT30\r
80#define USB_DEBUG_PORT_IN_USE_MASK (USB_DEBUG_PORT_IN_USE | \\r
81 USB_DEBUG_PORT_OWNER)\r
82\r
83//\r
84// EHC raises TPL to TPL_NOTIFY to serialize all its operations\r
85// to protect shared data structures.\r
86//\r
87#define EHC_TPL TPL_NOTIFY\r
88\r
89//\r
90//Iterate through the double linked list. NOT delete safe\r
91//\r
92#define EFI_LIST_FOR_EACH(Entry, ListHead) \\r
93 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
94\r
95//\r
96//Iterate through the double linked list. This is delete-safe.\r
97//Don't touch NextEntry\r
98//\r
99#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r
100 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
101 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
102\r
103#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)\r
104\r
105\r
106#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r
107#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
108#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
109\r
110#define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r
111 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r
112\r
113#define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')\r
114#define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
115\r
116struct _USB2_HC_DEV {\r
117 UINTN Signature;\r
118 EFI_USB2_HC_PROTOCOL Usb2Hc;\r
119\r
120 EFI_PCI_IO_PROTOCOL *PciIo;\r
121 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
122 UINT64 OriginalPciAttributes;\r
123 USBHC_MEM_POOL *MemPool;\r
124\r
125 //\r
126 // Schedule data shared between asynchronous and periodic\r
127 // transfers:\r
128 // ShortReadStop, as its name indicates, is used to terminate\r
129 // the short read except the control transfer. EHCI follows\r
130 // the alternative next QTD point when a short read happens.\r
131 // For control transfer, even the short read happens, try the\r
132 // status stage.\r
133 //\r
134 EHC_QTD *ShortReadStop;\r
135 EFI_EVENT PollTimer;\r
136\r
137 //\r
138 // ExitBootServicesEvent is used to stop the EHC DMA operation\r
139 // after exit boot service.\r
140 //\r
141 EFI_EVENT ExitBootServiceEvent;\r
142\r
143 //\r
144 // Asynchronous(bulk and control) transfer schedule data:\r
145 // ReclaimHead is used as the head of the asynchronous transfer\r
146 // list. It acts as the reclamation header.\r
147 //\r
148 EHC_QH *ReclaimHead;\r
149\r
150 //\r
151 // Periodic (interrupt) transfer schedule data:\r
152 //\r
153 VOID *PeriodFrame; // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.\r
154 VOID *PeriodFrameHost; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.\r
155 VOID *PeriodFrameMap;\r
156\r
157 EHC_QH *PeriodOne;\r
158 LIST_ENTRY AsyncIntTransfers;\r
159\r
160 //\r
161 // EHCI configuration data\r
162 //\r
163 UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r
164 UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r
165 UINT32 CapLen; // Capability length\r
166\r
167 //\r
168 // Misc\r
169 //\r
170 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
171\r
172 //\r
173 // EHCI debug port info\r
174 //\r
175 UINT16 DebugPortOffset; // The offset of debug port mmio register\r
176 UINT8 DebugPortBarNum; // The bar number of debug port mmio register\r
177 UINT8 DebugPortNum; // The port number of usb debug port\r
178\r
179 BOOLEAN Support64BitDma; // Whether 64 bit DMA may be used with this device\r
180};\r
181\r
182\r
183extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r
184extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r
185extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r
186\r
187/**\r
188 Test to see if this driver supports ControllerHandle. Any\r
189 ControllerHandle that has Usb2HcProtocol installed will\r
190 be supported.\r
191\r
192 @param This Protocol instance pointer.\r
193 @param Controller Handle of device to test.\r
194 @param RemainingDevicePath Not used.\r
195\r
196 @return EFI_SUCCESS This driver supports this device.\r
197 @return EFI_UNSUPPORTED This driver does not support this device.\r
198\r
199**/\r
200EFI_STATUS\r
201EFIAPI\r
202EhcDriverBindingSupported (\r
203 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
204 IN EFI_HANDLE Controller,\r
205 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
206 );\r
207\r
208/**\r
209 Starting the Usb EHCI Driver.\r
210\r
211 @param This Protocol instance pointer.\r
212 @param Controller Handle of device to test.\r
213 @param RemainingDevicePath Not used.\r
214\r
215 @return EFI_SUCCESS supports this device.\r
216 @return EFI_UNSUPPORTED do not support this device.\r
217 @return EFI_DEVICE_ERROR cannot be started due to device Error.\r
218 @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r
219\r
220**/\r
221EFI_STATUS\r
222EFIAPI\r
223EhcDriverBindingStart (\r
224 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
225 IN EFI_HANDLE Controller,\r
226 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
227 );\r
228\r
229/**\r
230 Stop this driver on ControllerHandle. Support stopping any child handles\r
231 created by this driver.\r
232\r
233 @param This Protocol instance pointer.\r
234 @param Controller Handle of device to stop driver on.\r
235 @param NumberOfChildren Number of Children in the ChildHandleBuffer.\r
236 @param ChildHandleBuffer List of handles for the children we need to stop.\r
237\r
238 @return EFI_SUCCESS Success.\r
239 @return EFI_DEVICE_ERROR Fail.\r
240\r
241**/\r
242EFI_STATUS\r
243EFIAPI\r
244EhcDriverBindingStop (\r
245 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
246 IN EFI_HANDLE Controller,\r
247 IN UINTN NumberOfChildren,\r
248 IN EFI_HANDLE *ChildHandleBuffer\r
249 );\r
250\r
251#endif\r
252\r