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