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