]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Provides some data struct used by EHCI controller driver.\r | |
4 | \r | |
5 | Copyright (c) 2006 - 2010, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT 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 | \r | |
36 | #include <IndustryStandard/Pci.h>\r | |
37 | \r | |
38 | typedef 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 | |
45 | #include "ComponentName.h"\r | |
46 | \r | |
47 | //\r | |
48 | // EHC timeout experience values\r | |
49 | //\r | |
50 | \r | |
51 | #define EHC_1_MICROSECOND 1\r | |
52 | #define EHC_1_MILLISECOND (1000 * EHC_1_MICROSECOND)\r | |
53 | #define EHC_1_SECOND (1000 * EHC_1_MILLISECOND)\r | |
54 | \r | |
55 | //\r | |
56 | // EHCI register operation timeout, set by experience\r | |
57 | //\r | |
58 | #define EHC_RESET_TIMEOUT (1 * EHC_1_SECOND)\r | |
59 | #define EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND)\r | |
60 | \r | |
61 | //\r | |
62 | // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r | |
63 | //\r | |
64 | #define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND)\r | |
65 | \r | |
66 | //\r | |
67 | // Sync and Async transfer polling interval, set by experience,\r | |
68 | // and the unit of Async is 100us, means 50ms as interval.\r | |
69 | //\r | |
70 | #define EHC_SYNC_POLL_INTERVAL (1 * EHC_1_MILLISECOND)\r | |
71 | #define EHC_ASYNC_POLL_INTERVAL (50 * 10000U)\r | |
72 | \r | |
73 | //\r | |
74 | // EHC raises TPL to TPL_NOTIFY to serialize all its operations\r | |
75 | // to protect shared data structures.\r | |
76 | //\r | |
77 | #define EHC_TPL TPL_NOTIFY\r | |
78 | \r | |
79 | //\r | |
80 | //Iterate through the doule linked list. NOT delete safe\r | |
81 | //\r | |
82 | #define EFI_LIST_FOR_EACH(Entry, ListHead) \\r | |
83 | for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r | |
84 | \r | |
85 | //\r | |
86 | //Iterate through the doule linked list. This is delete-safe.\r | |
87 | //Don't touch NextEntry\r | |
88 | //\r | |
89 | #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r | |
90 | for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r | |
91 | Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r | |
92 | \r | |
93 | #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)\r | |
94 | \r | |
95 | \r | |
96 | #define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r | |
97 | #define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r | |
98 | #define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r | |
99 | \r | |
100 | #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r | |
101 | (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r | |
102 | \r | |
103 | #define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')\r | |
104 | #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r | |
105 | \r | |
106 | struct _USB2_HC_DEV {\r | |
107 | UINTN Signature;\r | |
108 | EFI_USB2_HC_PROTOCOL Usb2Hc;\r | |
109 | \r | |
110 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
111 | UINT64 OriginalPciAttributes;\r | |
112 | USBHC_MEM_POOL *MemPool;\r | |
113 | \r | |
114 | //\r | |
115 | // Schedule data shared between asynchronous and periodic\r | |
116 | // transfers:\r | |
117 | // ShortReadStop, as its name indicates, is used to terminate\r | |
118 | // the short read except the control transfer. EHCI follows\r | |
119 | // the alternative next QTD point when a short read happens.\r | |
120 | // For control transfer, even the short read happens, try the\r | |
121 | // status stage.\r | |
122 | //\r | |
123 | EHC_QTD *ShortReadStop;\r | |
124 | EFI_EVENT PollTimer;\r | |
125 | \r | |
126 | //\r | |
127 | // ExitBootServicesEvent is used to stop the EHC DMA operation \r | |
128 | // after exit boot service.\r | |
129 | //\r | |
130 | EFI_EVENT ExitBootServiceEvent;\r | |
131 | \r | |
132 | //\r | |
133 | // Asynchronous(bulk and control) transfer schedule data:\r | |
134 | // ReclaimHead is used as the head of the asynchronous transfer\r | |
135 | // list. It acts as the reclamation header.\r | |
136 | //\r | |
137 | EHC_QH *ReclaimHead;\r | |
138 | \r | |
139 | //\r | |
140 | // Peroidic (interrupt) transfer schedule data:\r | |
141 | //\r | |
142 | VOID *PeriodFrame; // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.\r | |
143 | VOID *PeriodFrameHost; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.\r | |
144 | VOID *PeriodFrameMap;\r | |
145 | \r | |
146 | EHC_QH *PeriodOne;\r | |
147 | LIST_ENTRY AsyncIntTransfers;\r | |
148 | \r | |
149 | //\r | |
150 | // EHCI configuration data\r | |
151 | //\r | |
152 | UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r | |
153 | UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r | |
154 | UINT32 CapLen; // Capability length\r | |
155 | \r | |
156 | //\r | |
157 | // Misc\r | |
158 | //\r | |
159 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r | |
160 | };\r | |
161 | \r | |
162 | \r | |
163 | extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r | |
164 | extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r | |
165 | extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r | |
166 | \r | |
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 | |
180 | EFI_STATUS\r | |
181 | EFIAPI\r | |
182 | EhcDriverBindingSupported (\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 | |
201 | EFI_STATUS\r | |
202 | EFIAPI\r | |
203 | EhcDriverBindingStart (\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 | |
222 | EFI_STATUS\r | |
223 | EFIAPI\r | |
224 | EhcDriverBindingStop (\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 | |
231 | #endif\r | |
232 | \r |