]>
Commit | Line | Data |
---|---|---|
913cb9dc | 1 | /** @file\r |
2 | \r | |
78c2ffb5 | 3 | Provides some data struct used by EHCI controller driver.\r |
4 | \r | |
913cb9dc | 5 | Copyright (c) 2006 - 2007, 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 | |
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 |
913cb9dc | 25 | #include <Library/DebugLib.h>\r |
26 | #include <Library/BaseMemoryLib.h>\r | |
27 | #include <Library/UefiDriverEntryPoint.h>\r | |
28 | #include <Library/UefiBootServicesTableLib.h>\r | |
29 | #include <Library/UefiLib.h>\r | |
30 | #include <Library/BaseLib.h>\r | |
31 | #include <Library/MemoryAllocationLib.h>\r | |
dd4047a5 | 32 | #include <Library/PcdLib.h>\r |
913cb9dc | 33 | \r |
34 | #include <IndustryStandard/Pci22.h>\r | |
35 | \r | |
36 | typedef struct _USB2_HC_DEV USB2_HC_DEV;\r | |
37 | \r | |
38 | #include "UsbHcMem.h"\r | |
39 | #include "EhciReg.h"\r | |
40 | #include "EhciUrb.h"\r | |
41 | #include "EhciSched.h"\r | |
42 | #include "EhciDebug.h"\r | |
aa79b0b3 | 43 | #include "ComponentName.h"\r |
913cb9dc | 44 | \r |
78c2ffb5 | 45 | typedef enum {\r |
41e8ff27 | 46 | EHC_1_MICROSECOND = 1,\r |
47 | EHC_1_MILLISECOND = 1000 * EHC_1_MICROSECOND,\r | |
48 | EHC_1_SECOND = 1000 * EHC_1_MILLISECOND,\r | |
49 | \r | |
50 | //\r | |
51 | // EHCI register operation timeout, set by experience\r | |
52 | //\r | |
53 | EHC_RESET_TIMEOUT = 1 * EHC_1_SECOND,\r | |
54 | EHC_GENERIC_TIMEOUT = 10 * EHC_1_MILLISECOND,\r | |
55 | \r | |
56 | //\r | |
57 | // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r | |
58 | //\r | |
59 | EHC_ROOT_PORT_RECOVERY_STALL = 20 * EHC_1_MILLISECOND,\r | |
60 | \r | |
61 | //\r | |
68246fa8 | 62 | // Sync and Async transfer polling interval, set by experience,\r |
41e8ff27 | 63 | // and the unit of Async is 100us, means 50ms as interval.\r |
64 | //\r | |
65 | EHC_SYNC_POLL_INTERVAL = 20 * EHC_1_MICROSECOND,\r | |
78c2ffb5 | 66 | EHC_ASYNC_POLL_INTERVAL = 50 * 10000U\r |
67 | } EHC_TIMEOUT_EXPERIENCE_VALUE;\r | |
68 | \r | |
41e8ff27 | 69 | \r |
70 | //\r | |
71 | // EHC raises TPL to TPL_NOTIFY to serialize all its operations\r | |
72 | // to protect shared data structures.\r | |
73 | //\r | |
78c2ffb5 | 74 | #define EHC_TPL TPL_NOTIFY\r |
41e8ff27 | 75 | \r |
78c2ffb5 | 76 | #define USB2_HC_DEV_SIGNATURE EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')\r |
913cb9dc | 77 | \r |
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 | |
102 | #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r | |
103 | \r | |
c52fa98c | 104 | struct _USB2_HC_DEV {\r |
913cb9dc | 105 | UINTN Signature;\r |
106 | EFI_USB2_HC_PROTOCOL Usb2Hc;\r | |
107 | \r | |
108 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
68246fa8 | 109 | UINT64 OriginalPciAttributes;\r |
913cb9dc | 110 | USBHC_MEM_POOL *MemPool;\r |
111 | \r | |
112 | //\r | |
113 | // Schedule data shared between asynchronous and periodic\r | |
114 | // transfers:\r | |
115 | // ShortReadStop, as its name indicates, is used to terminate\r | |
116 | // the short read except the control transfer. EHCI follows\r | |
117 | // the alternative next QTD point when a short read happens.\r | |
118 | // For control transfer, even the short read happens, try the\r | |
119 | // status stage.\r | |
120 | //\r | |
121 | EHC_QTD *ShortReadStop;\r | |
122 | EFI_EVENT PollTimer;\r | |
123 | \r | |
124 | //\r | |
125 | // Asynchronous(bulk and control) transfer schedule data:\r | |
126 | // ReclaimHead is used as the head of the asynchronous transfer\r | |
127 | // list. It acts as the reclamation header.\r | |
128 | //\r | |
129 | EHC_QH *ReclaimHead;\r | |
130 | \r | |
131 | //\r | |
132 | // Peroidic (interrupt) transfer schedule data:\r | |
133 | //\r | |
134 | VOID *PeriodFrame; // Mapped as common buffer\r | |
135 | VOID *PeriodFrameHost;\r | |
136 | VOID *PeriodFrameMap;\r | |
137 | \r | |
138 | EHC_QH *PeriodOne;\r | |
139 | LIST_ENTRY AsyncIntTransfers;\r | |
140 | \r | |
141 | //\r | |
142 | // EHCI configuration data\r | |
143 | //\r | |
144 | UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r | |
145 | UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r | |
146 | UINT32 CapLen; // Capability length\r | |
147 | UINT32 High32bitAddr;\r | |
148 | \r | |
149 | //\r | |
150 | // Misc\r | |
151 | //\r | |
152 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r | |
c52fa98c | 153 | };\r |
913cb9dc | 154 | \r |
155 | \r | |
f527bce3 | 156 | extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r |
157 | extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r | |
158 | extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r | |
913cb9dc | 159 | \r |
aa79b0b3 | 160 | /**\r |
161 | Test to see if this driver supports ControllerHandle. Any\r | |
162 | ControllerHandle that has Usb2HcProtocol installed will\r | |
163 | be supported.\r | |
164 | \r | |
165 | @param This Protocol instance pointer.\r | |
166 | @param Controller Handle of device to test.\r | |
167 | @param RemainingDevicePath Not used.\r | |
168 | \r | |
169 | @return EFI_SUCCESS This driver supports this device.\r | |
170 | @return EFI_UNSUPPORTED This driver does not support this device.\r | |
171 | \r | |
172 | **/\r | |
173 | EFI_STATUS\r | |
174 | EFIAPI\r | |
175 | EhcDriverBindingSupported (\r | |
176 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
177 | IN EFI_HANDLE Controller,\r | |
178 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Starting the Usb EHCI Driver.\r | |
183 | \r | |
184 | @param This Protocol instance pointer.\r | |
185 | @param Controller Handle of device to test.\r | |
186 | @param RemainingDevicePath Not used.\r | |
187 | \r | |
188 | @return EFI_SUCCESS supports this device.\r | |
189 | @return EFI_UNSUPPORTED do not support this device.\r | |
190 | @return EFI_DEVICE_ERROR cannot be started due to device Error.\r | |
191 | @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r | |
192 | \r | |
193 | **/\r | |
194 | EFI_STATUS\r | |
195 | EFIAPI\r | |
196 | EhcDriverBindingStart (\r | |
197 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
198 | IN EFI_HANDLE Controller,\r | |
199 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
200 | );\r | |
201 | \r | |
202 | /**\r | |
203 | Stop this driver on ControllerHandle. Support stoping any child handles\r | |
204 | created by this driver.\r | |
205 | \r | |
206 | @param This Protocol instance pointer.\r | |
207 | @param Controller Handle of device to stop driver on.\r | |
208 | @param NumberOfChildren Number of Children in the ChildHandleBuffer.\r | |
209 | @param ChildHandleBuffer List of handles for the children we need to stop.\r | |
210 | \r | |
211 | @return EFI_SUCCESS Success.\r | |
212 | @return EFI_DEVICE_ERROR Fail.\r | |
213 | \r | |
214 | **/\r | |
215 | EFI_STATUS\r | |
216 | EFIAPI\r | |
217 | EhcDriverBindingStop (\r | |
218 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
219 | IN EFI_HANDLE Controller,\r | |
220 | IN UINTN NumberOfChildren,\r | |
221 | IN EFI_HANDLE *ChildHandleBuffer\r | |
222 | );\r | |
223 | \r | |
913cb9dc | 224 | #endif\r |
aa79b0b3 | 225 | \r |