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