]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c
GenFds will try to deduce 'Target_Toolchain_Arch' KeyStringList for GUIDed section.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / ComponentName.c
CommitLineData
ed838d0c 1/** @file\r
2\r
a7022cec 3 UEFI Component Name(2) protocol implementation for Usb Keyboard driver.\r
4\r
5Copyright (c) 2004 - 2008, Intel Corporation\r
ed838d0c 6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
ed838d0c 14**/\r
15\r
16\r
a7022cec 17#include "KeyBoard.h"\r
ed838d0c 18\r
19//\r
20// EFI Component Name Functions\r
21//\r
62b9bb55 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
ed838d0c 61EFI_STATUS\r
62EFIAPI\r
63UsbKeyboardComponentNameGetDriverName (\r
64 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
65 IN CHAR8 *Language,\r
66 OUT CHAR16 **DriverName\r
67 );\r
68\r
62b9bb55 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
ed838d0c 138EFI_STATUS\r
139EFIAPI\r
140UsbKeyboardComponentNameGetControllerName (\r
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
146 );\r
147\r
62b9bb55 148\r
ed838d0c 149//\r
150// EFI Component Name Protocol\r
151//\r
1307dcd7 152GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName = {\r
ed838d0c 153 UsbKeyboardComponentNameGetDriverName,\r
154 UsbKeyboardComponentNameGetControllerName,\r
155 "eng"\r
1307dcd7 156};\r
62b9bb55 157\r
158//\r
159// EFI Component Name 2 Protocol\r
160//\r
1307dcd7 161GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2 = {\r
62b9bb55 162 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbKeyboardComponentNameGetDriverName,\r
163 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbKeyboardComponentNameGetControllerName,\r
164 "en"\r
1307dcd7 165};\r
62b9bb55 166\r
ed838d0c 167\r
d1aeb0bd 168GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {\r
62b9bb55 169 { "eng;en", L"Usb Keyboard Driver" },\r
ed838d0c 170 { NULL , NULL }\r
171};\r
172\r
173\r
62b9bb55 174/**\r
175 Retrieves a Unicode string that is the user readable name of the driver.\r
176\r
177 This function retrieves the user readable name of a driver in the form of a\r
178 Unicode string. If the driver specified by This has a user readable name in\r
179 the language specified by Language, then a pointer to the driver name is\r
180 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
181 by This does not support the language specified by Language,\r
182 then EFI_UNSUPPORTED is returned.\r
183\r
184 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
185 EFI_COMPONENT_NAME_PROTOCOL instance.\r
186\r
187 @param Language[in] A pointer to a Null-terminated ASCII string\r
188 array indicating the language. This is the\r
189 language of the driver name that the caller is\r
190 requesting, and it must match one of the\r
191 languages specified in SupportedLanguages. The\r
192 number of languages supported by a driver is up\r
193 to the driver writer. Language is specified\r
194 in RFC 3066 or ISO 639-2 language code format.\r
195\r
196 @param DriverName[out] A pointer to the Unicode string to return.\r
197 This Unicode string is the name of the\r
198 driver specified by This in the language\r
199 specified by Language.\r
200\r
201 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
202 This and the language specified by Language was\r
203 returned in DriverName.\r
204\r
205 @retval EFI_INVALID_PARAMETER Language is NULL.\r
206\r
207 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
208\r
209 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
210 the language specified by Language.\r
211\r
212**/\r
ed838d0c 213EFI_STATUS\r
214EFIAPI\r
215UsbKeyboardComponentNameGetDriverName (\r
216 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
217 IN CHAR8 *Language,\r
218 OUT CHAR16 **DriverName\r
219 )\r
ed838d0c 220{\r
62b9bb55 221 return LookupUnicodeString2 (\r
222 Language,\r
223 This->SupportedLanguages,\r
224 mUsbKeyboardDriverNameTable,\r
225 DriverName,\r
226 (BOOLEAN)(This == &gUsbKeyboardComponentName)\r
227 );\r
ed838d0c 228}\r
229\r
62b9bb55 230/**\r
231 Retrieves a Unicode string that is the user readable name of the controller\r
232 that is being managed by a driver.\r
233\r
234 This function retrieves the user readable name of the controller specified by\r
235 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
236 driver specified by This has a user readable name in the language specified by\r
237 Language, then a pointer to the controller name is returned in ControllerName,\r
238 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
239 managing the controller specified by ControllerHandle and ChildHandle,\r
240 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
241 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
242\r
243 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
244 EFI_COMPONENT_NAME_PROTOCOL instance.\r
245\r
246 @param ControllerHandle[in] The handle of a controller that the driver\r
247 specified by This is managing. This handle\r
248 specifies the controller whose name is to be\r
249 returned.\r
250\r
251 @param ChildHandle[in] The handle of the child controller to retrieve\r
252 the name of. This is an optional parameter that\r
253 may be NULL. It will be NULL for device\r
254 drivers. It will also be NULL for a bus drivers\r
255 that wish to retrieve the name of the bus\r
256 controller. It will not be NULL for a bus\r
257 driver that wishes to retrieve the name of a\r
258 child controller.\r
259\r
260 @param Language[in] A pointer to a Null-terminated ASCII string\r
261 array indicating the language. This is the\r
262 language of the driver name that the caller is\r
263 requesting, and it must match one of the\r
264 languages specified in SupportedLanguages. The\r
265 number of languages supported by a driver is up\r
266 to the driver writer. Language is specified in\r
267 RFC 3066 or ISO 639-2 language code format.\r
268\r
269 @param ControllerName[out] A pointer to the Unicode string to return.\r
270 This Unicode string is the name of the\r
271 controller specified by ControllerHandle and\r
272 ChildHandle in the language specified by\r
273 Language from the point of view of the driver\r
274 specified by This.\r
275\r
276 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
277 the language specified by Language for the\r
278 driver specified by This was returned in\r
279 DriverName.\r
280\r
281 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
282\r
283 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
284 EFI_HANDLE.\r
285\r
286 @retval EFI_INVALID_PARAMETER Language is NULL.\r
287\r
288 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
289\r
290 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
291 managing the controller specified by\r
292 ControllerHandle and ChildHandle.\r
293\r
294 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
295 the language specified by Language.\r
296\r
297**/\r
ed838d0c 298EFI_STATUS\r
299EFIAPI\r
300UsbKeyboardComponentNameGetControllerName (\r
301 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
302 IN EFI_HANDLE ControllerHandle,\r
303 IN EFI_HANDLE ChildHandle OPTIONAL,\r
304 IN CHAR8 *Language,\r
305 OUT CHAR16 **ControllerName\r
306 )\r
ed838d0c 307{\r
308 EFI_STATUS Status;\r
309 USB_KB_DEV *UsbKbDev;\r
310 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTxtIn;\r
311 EFI_USB_IO_PROTOCOL *UsbIoProtocol;\r
312 //\r
313 // This is a device driver, so ChildHandle must be NULL.\r
314 //\r
315 if (ChildHandle != NULL) {\r
316 return EFI_UNSUPPORTED;\r
317 }\r
318\r
319 //\r
320 // Check Controller's handle\r
321 //\r
322 Status = gBS->OpenProtocol (\r
323 ControllerHandle,\r
324 &gEfiUsbIoProtocolGuid,\r
325 (VOID **) &UsbIoProtocol,\r
326 gUsbKeyboardDriverBinding.DriverBindingHandle,\r
327 ControllerHandle,\r
328 EFI_OPEN_PROTOCOL_BY_DRIVER\r
329 );\r
330 if (!EFI_ERROR (Status)) {\r
331 gBS->CloseProtocol (\r
332 ControllerHandle,\r
333 &gEfiUsbIoProtocolGuid,\r
334 gUsbKeyboardDriverBinding.DriverBindingHandle,\r
335 ControllerHandle\r
336 );\r
337\r
338 return EFI_UNSUPPORTED;\r
339 }\r
340\r
341 if (Status != EFI_ALREADY_STARTED) {\r
342 return EFI_UNSUPPORTED;\r
343 }\r
344 //\r
345 // Get the device context\r
346 //\r
347 Status = gBS->OpenProtocol (\r
348 ControllerHandle,\r
349 &gEfiSimpleTextInProtocolGuid,\r
350 (VOID **) &SimpleTxtIn,\r
351 gUsbKeyboardDriverBinding.DriverBindingHandle,\r
352 ControllerHandle,\r
353 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
354 );\r
355\r
356 if (EFI_ERROR (Status)) {\r
357 return Status;\r
358 }\r
359\r
360 UsbKbDev = USB_KB_DEV_FROM_THIS (SimpleTxtIn);\r
361\r
62b9bb55 362 return LookupUnicodeString2 (\r
363 Language,\r
364 This->SupportedLanguages,\r
365 UsbKbDev->ControllerNameTable,\r
366 ControllerName,\r
367 (BOOLEAN)(This == &gUsbKeyboardComponentName)\r
368 );\r
ed838d0c 369\r
370}\r