]>
Commit | Line | Data |
---|---|---|
913cb9dc | 1 | /** @file\r |
78c2ffb5 | 2 | UEFI Component Name(2) protocol implementation for EHCI driver.\r |
913cb9dc | 3 | \r |
824b03ce | 4 | Copyright (c) 2006 - 2007, Intel Corporation \r |
5 | \r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
913cb9dc | 10 | http://opensource.org/licenses/bsd-license.php\r |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
913cb9dc | 15 | **/\r |
16 | \r | |
17 | #include "Ehci.h"\r | |
18 | \r | |
19 | //\r | |
20 | // EFI Component Name Functions\r | |
21 | //\r | |
f527bce3 | 22 | /**\r |
23 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
24 | \r | |
25 | This function retrieves the user readable name of a driver in the form of a\r | |
26 | Unicode string. If the driver specified by This has a user readable name in\r | |
27 | the language specified by Language, then a pointer to the driver name is\r | |
28 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
29 | by This does not support the language specified by Language,\r | |
30 | then EFI_UNSUPPORTED is returned.\r | |
31 | \r | |
32 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
33 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
34 | \r | |
35 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
36 | array indicating the language. This is the\r | |
37 | language of the driver name that the caller is\r | |
38 | requesting, and it must match one of the\r | |
39 | languages specified in SupportedLanguages. The\r | |
40 | number of languages supported by a driver is up\r | |
41 | to the driver writer. Language is specified\r | |
42 | in RFC 3066 or ISO 639-2 language code format.\r | |
43 | \r | |
44 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
45 | This Unicode string is the name of the\r | |
46 | driver specified by This in the language\r | |
47 | specified by Language.\r | |
48 | \r | |
49 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
50 | This and the language specified by Language was\r | |
51 | returned in DriverName.\r | |
52 | \r | |
53 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
54 | \r | |
55 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
56 | \r | |
57 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
58 | the language specified by Language.\r | |
59 | \r | |
60 | **/\r | |
913cb9dc | 61 | EFI_STATUS\r |
62 | EFIAPI\r | |
63 | EhciComponentNameGetDriverName (\r | |
f527bce3 | 64 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
65 | IN CHAR8 *Language,\r | |
66 | OUT CHAR16 **DriverName\r | |
913cb9dc | 67 | );\r |
68 | \r | |
f527bce3 | 69 | \r |
70 | /**\r | |
71 | Retrieves a Unicode string that is the user readable name of the controller\r | |
72 | that is being managed by a driver.\r | |
73 | \r | |
74 | This function retrieves the user readable name of the controller specified by\r | |
75 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
76 | driver specified by This has a user readable name in the language specified by\r | |
77 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
78 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
79 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
80 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
81 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
82 | \r | |
83 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
84 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
85 | \r | |
86 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
87 | specified by This is managing. This handle\r | |
88 | specifies the controller whose name is to be\r | |
89 | returned.\r | |
90 | \r | |
91 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
92 | the name of. This is an optional parameter that\r | |
93 | may be NULL. It will be NULL for device\r | |
94 | drivers. It will also be NULL for a bus drivers\r | |
95 | that wish to retrieve the name of the bus\r | |
96 | controller. It will not be NULL for a bus\r | |
97 | driver that wishes to retrieve the name of a\r | |
98 | child controller.\r | |
99 | \r | |
100 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
101 | array indicating the language. This is the\r | |
102 | language of the driver name that the caller is\r | |
103 | requesting, and it must match one of the\r | |
104 | languages specified in SupportedLanguages. The\r | |
105 | number of languages supported by a driver is up\r | |
106 | to the driver writer. Language is specified in\r | |
107 | RFC 3066 or ISO 639-2 language code format.\r | |
108 | \r | |
109 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
110 | This Unicode string is the name of the\r | |
111 | controller specified by ControllerHandle and\r | |
112 | ChildHandle in the language specified by\r | |
113 | Language from the point of view of the driver\r | |
114 | specified by This.\r | |
115 | \r | |
116 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
117 | the language specified by Language for the\r | |
118 | driver specified by This was returned in\r | |
119 | DriverName.\r | |
120 | \r | |
121 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
122 | \r | |
123 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
124 | EFI_HANDLE.\r | |
125 | \r | |
126 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
127 | \r | |
128 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
129 | \r | |
130 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
131 | managing the controller specified by\r | |
132 | ControllerHandle and ChildHandle.\r | |
133 | \r | |
134 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
135 | the language specified by Language.\r | |
136 | \r | |
137 | **/\r | |
913cb9dc | 138 | EFI_STATUS\r |
139 | EFIAPI\r | |
140 | EhciComponentNameGetControllerName (\r | |
f527bce3 | 141 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
142 | IN EFI_HANDLE ControllerHandle,\r | |
143 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
144 | IN CHAR8 *Language,\r | |
145 | OUT CHAR16 **ControllerName\r | |
913cb9dc | 146 | );\r |
147 | \r | |
f527bce3 | 148 | \r |
913cb9dc | 149 | //\r |
150 | // EFI Component Name Protocol\r | |
151 | //\r | |
1307dcd7 | 152 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {\r |
913cb9dc | 153 | EhciComponentNameGetDriverName,\r |
154 | EhciComponentNameGetControllerName,\r | |
155 | "eng"\r | |
1307dcd7 | 156 | };\r |
f527bce3 | 157 | \r |
158 | //\r | |
159 | // EFI Component Name 2 Protocol\r | |
160 | //\r | |
1307dcd7 | 161 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {\r |
f527bce3 | 162 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,\r |
163 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,\r | |
164 | "en"\r | |
1307dcd7 | 165 | };\r |
f527bce3 | 166 | \r |
913cb9dc | 167 | \r |
d1aeb0bd | 168 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {\r |
f527bce3 | 169 | { "eng;en", L"Usb Ehci Driver" },\r |
913cb9dc | 170 | { NULL , NULL }\r |
171 | };\r | |
172 | \r | |
f527bce3 | 173 | /**\r |
174 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
175 | \r | |
176 | This function retrieves the user readable name of a driver in the form of a\r | |
177 | Unicode string. If the driver specified by This has a user readable name in\r | |
178 | the language specified by Language, then a pointer to the driver name is\r | |
179 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
180 | by This does not support the language specified by Language,\r | |
181 | then EFI_UNSUPPORTED is returned.\r | |
182 | \r | |
183 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
184 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
185 | \r | |
186 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
187 | array indicating the language. This is the\r | |
188 | language of the driver name that the caller is\r | |
189 | requesting, and it must match one of the\r | |
190 | languages specified in SupportedLanguages. The\r | |
191 | number of languages supported by a driver is up\r | |
192 | to the driver writer. Language is specified\r | |
193 | in RFC 3066 or ISO 639-2 language code format.\r | |
194 | \r | |
195 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
196 | This Unicode string is the name of the\r | |
197 | driver specified by This in the language\r | |
198 | specified by Language.\r | |
199 | \r | |
200 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
201 | This and the language specified by Language was\r | |
202 | returned in DriverName.\r | |
203 | \r | |
204 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
205 | \r | |
206 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
207 | \r | |
208 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
209 | the language specified by Language.\r | |
210 | \r | |
211 | **/\r | |
913cb9dc | 212 | EFI_STATUS\r |
213 | EFIAPI\r | |
214 | EhciComponentNameGetDriverName (\r | |
f527bce3 | 215 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
216 | IN CHAR8 *Language,\r | |
217 | OUT CHAR16 **DriverName\r | |
913cb9dc | 218 | )\r |
913cb9dc | 219 | {\r |
f527bce3 | 220 | return LookupUnicodeString2 (\r |
221 | Language,\r | |
222 | This->SupportedLanguages,\r | |
223 | mEhciDriverNameTable,\r | |
224 | DriverName,\r | |
225 | (BOOLEAN)(This == &gEhciComponentName)\r | |
226 | );\r | |
913cb9dc | 227 | }\r |
228 | \r | |
f527bce3 | 229 | /**\r |
230 | Retrieves a Unicode string that is the user readable name of the controller\r | |
231 | that is being managed by a driver.\r | |
232 | \r | |
233 | This function retrieves the user readable name of the controller specified by\r | |
234 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
235 | driver specified by This has a user readable name in the language specified by\r | |
236 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
237 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
238 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
239 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
240 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
241 | \r | |
242 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
243 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
244 | \r | |
245 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
246 | specified by This is managing. This handle\r | |
247 | specifies the controller whose name is to be\r | |
248 | returned.\r | |
249 | \r | |
250 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
251 | the name of. This is an optional parameter that\r | |
252 | may be NULL. It will be NULL for device\r | |
253 | drivers. It will also be NULL for a bus drivers\r | |
254 | that wish to retrieve the name of the bus\r | |
255 | controller. It will not be NULL for a bus\r | |
256 | driver that wishes to retrieve the name of a\r | |
257 | child controller.\r | |
258 | \r | |
259 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
260 | array indicating the language. This is the\r | |
261 | language of the driver name that the caller is\r | |
262 | requesting, and it must match one of the\r | |
263 | languages specified in SupportedLanguages. The\r | |
264 | number of languages supported by a driver is up\r | |
265 | to the driver writer. Language is specified in\r | |
266 | RFC 3066 or ISO 639-2 language code format.\r | |
267 | \r | |
268 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
269 | This Unicode string is the name of the\r | |
270 | controller specified by ControllerHandle and\r | |
271 | ChildHandle in the language specified by\r | |
272 | Language from the point of view of the driver\r | |
273 | specified by This.\r | |
274 | \r | |
275 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
276 | the language specified by Language for the\r | |
277 | driver specified by This was returned in\r | |
278 | DriverName.\r | |
279 | \r | |
280 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
281 | \r | |
282 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
283 | EFI_HANDLE.\r | |
284 | \r | |
285 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
286 | \r | |
287 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
288 | \r | |
289 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
290 | managing the controller specified by\r | |
291 | ControllerHandle and ChildHandle.\r | |
292 | \r | |
293 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
294 | the language specified by Language.\r | |
295 | \r | |
296 | **/\r | |
913cb9dc | 297 | EFI_STATUS\r |
298 | EFIAPI\r | |
299 | EhciComponentNameGetControllerName (\r | |
f527bce3 | 300 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
301 | IN EFI_HANDLE ControllerHandle,\r | |
302 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
303 | IN CHAR8 *Language,\r | |
304 | OUT CHAR16 **ControllerName\r | |
913cb9dc | 305 | )\r |
913cb9dc | 306 | {\r |
307 | EFI_STATUS Status;\r | |
308 | USB2_HC_DEV *EhciDev;\r | |
309 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r | |
310 | \r | |
311 | //\r | |
312 | // This is a device driver, so ChildHandle must be NULL.\r | |
313 | //\r | |
314 | if (ChildHandle != NULL) {\r | |
315 | return EFI_UNSUPPORTED;\r | |
316 | }\r | |
317 | //\r | |
318 | // Make sure this driver is currently managing ControllerHandle\r | |
319 | //\r | |
320 | Status = EfiTestManagedDevice (\r | |
321 | ControllerHandle,\r | |
322 | gEhciDriverBinding.DriverBindingHandle,\r | |
323 | &gEfiPciIoProtocolGuid\r | |
324 | );\r | |
325 | if (EFI_ERROR (Status)) {\r | |
326 | return Status;\r | |
327 | }\r | |
328 | //\r | |
329 | // Get the device context\r | |
330 | //\r | |
331 | Status = gBS->OpenProtocol (\r | |
332 | ControllerHandle,\r | |
333 | &gEfiUsb2HcProtocolGuid,\r | |
334 | (VOID **) &Usb2Hc,\r | |
335 | gEhciDriverBinding.DriverBindingHandle,\r | |
336 | ControllerHandle,\r | |
337 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
338 | );\r | |
339 | if (EFI_ERROR (Status)) {\r | |
340 | return Status;\r | |
341 | }\r | |
342 | \r | |
343 | EhciDev = EHC_FROM_THIS (Usb2Hc);\r | |
344 | \r | |
f527bce3 | 345 | return LookupUnicodeString2 (\r |
346 | Language,\r | |
347 | This->SupportedLanguages,\r | |
348 | EhciDev->ControllerNameTable,\r | |
349 | ControllerName,\r | |
350 | (BOOLEAN)(This == &gEhciComponentName)\r | |
351 | );\r | |
913cb9dc | 352 | \r |
353 | }\r |