3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 // EFI Component Name Functions
28 Retrieves a Unicode string that is the user readable name of the driver.
30 This function retrieves the user readable name of a driver in the form of a
31 Unicode string. If the driver specified by This has a user readable name in
32 the language specified by Language, then a pointer to the driver name is
33 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
34 by This does not support the language specified by Language,
35 then EFI_UNSUPPORTED is returned.
37 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
38 EFI_COMPONENT_NAME_PROTOCOL instance.
40 @param Language[in] A pointer to a Null-terminated ASCII string
41 array indicating the language. This is the
42 language of the driver name that the caller is
43 requesting, and it must match one of the
44 languages specified in SupportedLanguages. The
45 number of languages supported by a driver is up
46 to the driver writer. Language is specified
47 in RFC 3066 or ISO 639-2 language code format.
49 @param DriverName[out] A pointer to the Unicode string to return.
50 This Unicode string is the name of the
51 driver specified by This in the language
52 specified by Language.
54 @retval EFI_SUCCESS The Unicode string for the Driver specified by
55 This and the language specified by Language was
56 returned in DriverName.
58 @retval EFI_INVALID_PARAMETER Language is NULL.
60 @retval EFI_INVALID_PARAMETER DriverName is NULL.
62 @retval EFI_UNSUPPORTED The driver specified by This does not support
63 the language specified by Language.
68 UsbKeyboardComponentNameGetDriverName (
69 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
71 OUT CHAR16
**DriverName
76 Retrieves a Unicode string that is the user readable name of the controller
77 that is being managed by a driver.
79 This function retrieves the user readable name of the controller specified by
80 ControllerHandle and ChildHandle in the form of a Unicode string. If the
81 driver specified by This has a user readable name in the language specified by
82 Language, then a pointer to the controller name is returned in ControllerName,
83 and EFI_SUCCESS is returned. If the driver specified by This is not currently
84 managing the controller specified by ControllerHandle and ChildHandle,
85 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
86 support the language specified by Language, then EFI_UNSUPPORTED is returned.
88 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
89 EFI_COMPONENT_NAME_PROTOCOL instance.
91 @param ControllerHandle[in] The handle of a controller that the driver
92 specified by This is managing. This handle
93 specifies the controller whose name is to be
96 @param ChildHandle[in] The handle of the child controller to retrieve
97 the name of. This is an optional parameter that
98 may be NULL. It will be NULL for device
99 drivers. It will also be NULL for a bus drivers
100 that wish to retrieve the name of the bus
101 controller. It will not be NULL for a bus
102 driver that wishes to retrieve the name of a
105 @param Language[in] A pointer to a Null-terminated ASCII string
106 array indicating the language. This is the
107 language of the driver name that the caller is
108 requesting, and it must match one of the
109 languages specified in SupportedLanguages. The
110 number of languages supported by a driver is up
111 to the driver writer. Language is specified in
112 RFC 3066 or ISO 639-2 language code format.
114 @param ControllerName[out] A pointer to the Unicode string to return.
115 This Unicode string is the name of the
116 controller specified by ControllerHandle and
117 ChildHandle in the language specified by
118 Language from the point of view of the driver
121 @retval EFI_SUCCESS The Unicode string for the user readable name in
122 the language specified by Language for the
123 driver specified by This was returned in
126 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
128 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
131 @retval EFI_INVALID_PARAMETER Language is NULL.
133 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
135 @retval EFI_UNSUPPORTED The driver specified by This is not currently
136 managing the controller specified by
137 ControllerHandle and ChildHandle.
139 @retval EFI_UNSUPPORTED The driver specified by This does not support
140 the language specified by Language.
145 UsbKeyboardComponentNameGetControllerName (
146 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
147 IN EFI_HANDLE ControllerHandle
,
148 IN EFI_HANDLE ChildHandle OPTIONAL
,
150 OUT CHAR16
**ControllerName
155 // EFI Component Name Protocol
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName
= {
158 UsbKeyboardComponentNameGetDriverName
,
159 UsbKeyboardComponentNameGetControllerName
,
164 // EFI Component Name 2 Protocol
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2
= {
167 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) UsbKeyboardComponentNameGetDriverName
,
168 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) UsbKeyboardComponentNameGetControllerName
,
173 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable
[] = {
174 { "eng;en", L
"Usb Keyboard Driver" },
180 Retrieves a Unicode string that is the user readable name of the driver.
182 This function retrieves the user readable name of a driver in the form of a
183 Unicode string. If the driver specified by This has a user readable name in
184 the language specified by Language, then a pointer to the driver name is
185 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
186 by This does not support the language specified by Language,
187 then EFI_UNSUPPORTED is returned.
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
192 @param Language[in] A pointer to a Null-terminated ASCII string
193 array indicating the language. This is the
194 language of the driver name that the caller is
195 requesting, and it must match one of the
196 languages specified in SupportedLanguages. The
197 number of languages supported by a driver is up
198 to the driver writer. Language is specified
199 in RFC 3066 or ISO 639-2 language code format.
201 @param DriverName[out] A pointer to the Unicode string to return.
202 This Unicode string is the name of the
203 driver specified by This in the language
204 specified by Language.
206 @retval EFI_SUCCESS The Unicode string for the Driver specified by
207 This and the language specified by Language was
208 returned in DriverName.
210 @retval EFI_INVALID_PARAMETER Language is NULL.
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
220 UsbKeyboardComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
229 mUsbKeyboardDriverNameTable
,
231 (BOOLEAN
)(This
== &gUsbKeyboardComponentName
)
236 Retrieves a Unicode string that is the user readable name of the controller
237 that is being managed by a driver.
239 This function retrieves the user readable name of the controller specified by
240 ControllerHandle and ChildHandle in the form of a Unicode string. If the
241 driver specified by This has a user readable name in the language specified by
242 Language, then a pointer to the controller name is returned in ControllerName,
243 and EFI_SUCCESS is returned. If the driver specified by This is not currently
244 managing the controller specified by ControllerHandle and ChildHandle,
245 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
246 support the language specified by Language, then EFI_UNSUPPORTED is returned.
248 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
249 EFI_COMPONENT_NAME_PROTOCOL instance.
251 @param ControllerHandle[in] The handle of a controller that the driver
252 specified by This is managing. This handle
253 specifies the controller whose name is to be
256 @param ChildHandle[in] The handle of the child controller to retrieve
257 the name of. This is an optional parameter that
258 may be NULL. It will be NULL for device
259 drivers. It will also be NULL for a bus drivers
260 that wish to retrieve the name of the bus
261 controller. It will not be NULL for a bus
262 driver that wishes to retrieve the name of a
265 @param Language[in] A pointer to a Null-terminated ASCII string
266 array indicating the language. This is the
267 language of the driver name that the caller is
268 requesting, and it must match one of the
269 languages specified in SupportedLanguages. The
270 number of languages supported by a driver is up
271 to the driver writer. Language is specified in
272 RFC 3066 or ISO 639-2 language code format.
274 @param ControllerName[out] A pointer to the Unicode string to return.
275 This Unicode string is the name of the
276 controller specified by ControllerHandle and
277 ChildHandle in the language specified by
278 Language from the point of view of the driver
281 @retval EFI_SUCCESS The Unicode string for the user readable name in
282 the language specified by Language for the
283 driver specified by This was returned in
286 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
288 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
291 @retval EFI_INVALID_PARAMETER Language is NULL.
293 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
295 @retval EFI_UNSUPPORTED The driver specified by This is not currently
296 managing the controller specified by
297 ControllerHandle and ChildHandle.
299 @retval EFI_UNSUPPORTED The driver specified by This does not support
300 the language specified by Language.
305 UsbKeyboardComponentNameGetControllerName (
306 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
307 IN EFI_HANDLE ControllerHandle
,
308 IN EFI_HANDLE ChildHandle OPTIONAL
,
310 OUT CHAR16
**ControllerName
314 USB_KB_DEV
*UsbKbDev
;
315 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*SimpleTxtIn
;
316 EFI_USB_IO_PROTOCOL
*UsbIoProtocol
;
318 // This is a device driver, so ChildHandle must be NULL.
320 if (ChildHandle
!= NULL
) {
321 return EFI_UNSUPPORTED
;
325 // Check Controller's handle
327 Status
= gBS
->OpenProtocol (
329 &gEfiUsbIoProtocolGuid
,
330 (VOID
**) &UsbIoProtocol
,
331 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
333 EFI_OPEN_PROTOCOL_BY_DRIVER
335 if (!EFI_ERROR (Status
)) {
338 &gEfiUsbIoProtocolGuid
,
339 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
343 return EFI_UNSUPPORTED
;
346 if (Status
!= EFI_ALREADY_STARTED
) {
347 return EFI_UNSUPPORTED
;
350 // Get the device context
352 Status
= gBS
->OpenProtocol (
354 &gEfiSimpleTextInProtocolGuid
,
355 (VOID
**) &SimpleTxtIn
,
356 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
358 EFI_OPEN_PROTOCOL_GET_PROTOCOL
361 if (EFI_ERROR (Status
)) {
365 UsbKbDev
= USB_KB_DEV_FROM_THIS (SimpleTxtIn
);
367 return LookupUnicodeString2 (
369 This
->SupportedLanguages
,
370 UsbKbDev
->ControllerNameTable
,
372 (BOOLEAN
)(This
== &gUsbKeyboardComponentName
)