]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
fixed DMA not be stopped issue when gBS->ExitBootServices called.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
CommitLineData
913cb9dc 1/** @file\r
2\r
78c2ffb5 3 Provides some data struct used by EHCI controller driver.\r
4\r
597f4ee2 5Copyright (c) 2006 - 2009, Intel Corporation\r
913cb9dc 6All rights reserved. This 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
913cb9dc 14**/\r
15\r
16#ifndef _EFI_EHCI_H_\r
17#define _EFI_EHCI_H_\r
18\r
ed7748fe 19\r
60c93673 20#include <Uefi.h>\r
ed7748fe 21\r
913cb9dc 22#include <Protocol/Usb2HostController.h>\r
23#include <Protocol/PciIo.h>\r
ed7748fe 24\r
0428a6cb 25#include <Guid/EventGroup.h>\r
26\r
913cb9dc 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
dd4047a5 34#include <Library/PcdLib.h>\r
913cb9dc 35\r
36#include <IndustryStandard/Pci22.h>\r
37\r
38typedef struct _USB2_HC_DEV USB2_HC_DEV;\r
39\r
40#include "UsbHcMem.h"\r
41#include "EhciReg.h"\r
42#include "EhciUrb.h"\r
43#include "EhciSched.h"\r
44#include "EhciDebug.h"\r
aa79b0b3 45#include "ComponentName.h"\r
913cb9dc 46\r
78c2ffb5 47typedef enum {\r
41e8ff27 48 EHC_1_MICROSECOND = 1,\r
49 EHC_1_MILLISECOND = 1000 * EHC_1_MICROSECOND,\r
50 EHC_1_SECOND = 1000 * EHC_1_MILLISECOND,\r
51\r
52 //\r
53 // EHCI register operation timeout, set by experience\r
54 //\r
55 EHC_RESET_TIMEOUT = 1 * EHC_1_SECOND,\r
56 EHC_GENERIC_TIMEOUT = 10 * EHC_1_MILLISECOND,\r
57\r
58 //\r
59 // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r
60 //\r
61 EHC_ROOT_PORT_RECOVERY_STALL = 20 * EHC_1_MILLISECOND,\r
62\r
63 //\r
68246fa8 64 // Sync and Async transfer polling interval, set by experience,\r
41e8ff27 65 // and the unit of Async is 100us, means 50ms as interval.\r
66 //\r
67 EHC_SYNC_POLL_INTERVAL = 20 * EHC_1_MICROSECOND,\r
78c2ffb5 68 EHC_ASYNC_POLL_INTERVAL = 50 * 10000U\r
69} EHC_TIMEOUT_EXPERIENCE_VALUE;\r
70\r
41e8ff27 71\r
597f4ee2 72//\r
73// EHC raises TPL to TPL_NOTIFY to serialize all its operations\r
74// to protect shared data structures.\r
75//\r
78c2ffb5 76#define EHC_TPL TPL_NOTIFY\r
41e8ff27 77\r
913cb9dc 78//\r
79//Iterate through the doule linked list. NOT delete safe\r
80//\r
81#define EFI_LIST_FOR_EACH(Entry, ListHead) \\r
82 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
83\r
84//\r
85//Iterate through the doule linked list. This is delete-safe.\r
86//Don't touch NextEntry\r
87//\r
88#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r
89 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
90 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
91\r
50d7ebad 92#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)\r
913cb9dc 93\r
94\r
95#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r
96#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
97#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
98\r
99#define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r
100 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r
101\r
597f4ee2 102#define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')\r
103#define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
913cb9dc 104\r
c52fa98c 105struct _USB2_HC_DEV {\r
913cb9dc 106 UINTN Signature;\r
107 EFI_USB2_HC_PROTOCOL Usb2Hc;\r
108\r
109 EFI_PCI_IO_PROTOCOL *PciIo;\r
68246fa8 110 UINT64 OriginalPciAttributes;\r
913cb9dc 111 USBHC_MEM_POOL *MemPool;\r
112\r
113 //\r
114 // Schedule data shared between asynchronous and periodic\r
115 // transfers:\r
116 // ShortReadStop, as its name indicates, is used to terminate\r
117 // the short read except the control transfer. EHCI follows\r
118 // the alternative next QTD point when a short read happens.\r
119 // For control transfer, even the short read happens, try the\r
120 // status stage.\r
121 //\r
122 EHC_QTD *ShortReadStop;\r
123 EFI_EVENT PollTimer;\r
124\r
0428a6cb 125 //\r
126 // ExitBootServicesEvent is used to stop the EHC DMA operation \r
127 // after exit boot service.\r
128 //\r
129 EFI_EVENT ExitBootServiceEvent;\r
130\r
913cb9dc 131 //\r
132 // Asynchronous(bulk and control) transfer schedule data:\r
133 // ReclaimHead is used as the head of the asynchronous transfer\r
134 // list. It acts as the reclamation header.\r
135 //\r
136 EHC_QH *ReclaimHead;\r
137\r
138 //\r
139 // Peroidic (interrupt) transfer schedule data:\r
140 //\r
141 VOID *PeriodFrame; // Mapped as common buffer\r
142 VOID *PeriodFrameHost;\r
143 VOID *PeriodFrameMap;\r
144\r
145 EHC_QH *PeriodOne;\r
146 LIST_ENTRY AsyncIntTransfers;\r
147\r
148 //\r
149 // EHCI configuration data\r
150 //\r
151 UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r
152 UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r
153 UINT32 CapLen; // Capability length\r
154 UINT32 High32bitAddr;\r
155\r
156 //\r
157 // Misc\r
158 //\r
159 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
c52fa98c 160};\r
913cb9dc 161\r
162\r
f527bce3 163extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r
164extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r
165extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r
913cb9dc 166\r
aa79b0b3 167/**\r
168 Test to see if this driver supports ControllerHandle. Any\r
169 ControllerHandle that has Usb2HcProtocol installed will\r
170 be supported.\r
171\r
172 @param This Protocol instance pointer.\r
173 @param Controller Handle of device to test.\r
174 @param RemainingDevicePath Not used.\r
175\r
176 @return EFI_SUCCESS This driver supports this device.\r
177 @return EFI_UNSUPPORTED This driver does not support this device.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182EhcDriverBindingSupported (\r
183 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
184 IN EFI_HANDLE Controller,\r
185 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
186 );\r
187\r
188/**\r
189 Starting the Usb EHCI Driver.\r
190\r
191 @param This Protocol instance pointer.\r
192 @param Controller Handle of device to test.\r
193 @param RemainingDevicePath Not used.\r
194\r
195 @return EFI_SUCCESS supports this device.\r
196 @return EFI_UNSUPPORTED do not support this device.\r
197 @return EFI_DEVICE_ERROR cannot be started due to device Error.\r
198 @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r
199\r
200**/\r
201EFI_STATUS\r
202EFIAPI\r
203EhcDriverBindingStart (\r
204 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
205 IN EFI_HANDLE Controller,\r
206 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
207 );\r
208\r
209/**\r
210 Stop this driver on ControllerHandle. Support stoping any child handles\r
211 created by this driver.\r
212\r
213 @param This Protocol instance pointer.\r
214 @param Controller Handle of device to stop driver on.\r
215 @param NumberOfChildren Number of Children in the ChildHandleBuffer.\r
216 @param ChildHandleBuffer List of handles for the children we need to stop.\r
217\r
218 @return EFI_SUCCESS Success.\r
219 @return EFI_DEVICE_ERROR Fail.\r
220\r
221**/\r
222EFI_STATUS\r
223EFIAPI\r
224EhcDriverBindingStop (\r
225 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
226 IN EFI_HANDLE Controller,\r
227 IN UINTN NumberOfChildren,\r
228 IN EFI_HANDLE *ChildHandleBuffer\r
229 );\r
230\r
913cb9dc 231#endif\r
aa79b0b3 232\r