2 UEFI Component Name(2) protocol implementation for USB Keyboard driver.
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // EFI Component Name Protocol
15 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName
= {
16 UsbKeyboardComponentNameGetDriverName
,
17 UsbKeyboardComponentNameGetControllerName
,
22 // EFI Component Name 2 Protocol
24 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2
= {
25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) UsbKeyboardComponentNameGetDriverName
,
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) UsbKeyboardComponentNameGetControllerName
,
31 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable
[] = {
32 { "eng;en", L
"Usb Keyboard Driver" },
37 Retrieves a Unicode string that is the user readable name of the driver.
39 This function retrieves the user readable name of a driver in the form of a
40 Unicode string. If the driver specified by This has a user readable name in
41 the language specified by Language, then a pointer to the driver name is
42 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
43 by This does not support the language specified by Language,
44 then EFI_UNSUPPORTED is returned.
46 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
47 EFI_COMPONENT_NAME_PROTOCOL instance.
48 @param Language A pointer to a Null-terminated ASCII string
49 array indicating the language. This is the
50 language of the driver name that the caller is
51 requesting, and it must match one of the
52 languages specified in SupportedLanguages. The
53 number of languages supported by a driver is up
54 to the driver writer. Language is specified
55 in RFC 4646 or ISO 639-2 language code format.
56 @param DriverName A pointer to the Unicode string to return.
57 This Unicode string is the name of the
58 driver specified by This in the language
59 specified by Language.
61 @retval EFI_SUCCESS The Unicode string for the Driver specified by
62 This and the language specified by Language was
63 returned in DriverName.
64 @retval EFI_INVALID_PARAMETER Language is NULL.
65 @retval EFI_INVALID_PARAMETER DriverName is NULL.
66 @retval EFI_UNSUPPORTED The driver specified by This does not support
67 the language specified by Language.
72 UsbKeyboardComponentNameGetDriverName (
73 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
75 OUT CHAR16
**DriverName
78 return LookupUnicodeString2 (
80 This
->SupportedLanguages
,
81 mUsbKeyboardDriverNameTable
,
83 (BOOLEAN
)(This
== &gUsbKeyboardComponentName
)
88 Retrieves a Unicode string that is the user readable name of the controller
89 that is being managed by a driver.
91 This function retrieves the user readable name of the controller specified by
92 ControllerHandle and ChildHandle in the form of a Unicode string. If the
93 driver specified by This has a user readable name in the language specified by
94 Language, then a pointer to the controller name is returned in ControllerName,
95 and EFI_SUCCESS is returned. If the driver specified by This is not currently
96 managing the controller specified by ControllerHandle and ChildHandle,
97 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
98 support the language specified by Language, then EFI_UNSUPPORTED is returned.
100 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
101 EFI_COMPONENT_NAME_PROTOCOL instance.
102 @param ControllerHandle The handle of a controller that the driver
103 specified by This is managing. This handle
104 specifies the controller whose name is to be
106 @param ChildHandle The handle of the child controller to retrieve
107 the name of. This is an optional parameter that
108 may be NULL. It will be NULL for device
109 drivers. It will also be NULL for a bus drivers
110 that wish to retrieve the name of the bus
111 controller. It will not be NULL for a bus
112 driver that wishes to retrieve the name of a
114 @param Language A pointer to a Null-terminated ASCII string
115 array indicating the language. This is the
116 language of the driver name that the caller is
117 requesting, and it must match one of the
118 languages specified in SupportedLanguages. The
119 number of languages supported by a driver is up
120 to the driver writer. Language is specified in
121 RFC 4646 or ISO 639-2 language code format.
122 @param ControllerName A pointer to the Unicode string to return.
123 This Unicode string is the name of the
124 controller specified by ControllerHandle and
125 ChildHandle in the language specified by
126 Language from the point of view of the driver
129 @retval EFI_SUCCESS The Unicode string for the user readable name in
130 the language specified by Language for the
131 driver specified by This was returned in
133 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
134 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
136 @retval EFI_INVALID_PARAMETER Language is NULL.
137 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
138 @retval EFI_UNSUPPORTED The driver specified by This is not currently
139 managing the controller specified by
140 ControllerHandle and ChildHandle.
141 @retval EFI_UNSUPPORTED The driver specified by This does not support
142 the language specified by Language.
147 UsbKeyboardComponentNameGetControllerName (
148 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
149 IN EFI_HANDLE ControllerHandle
,
150 IN EFI_HANDLE ChildHandle OPTIONAL
,
152 OUT CHAR16
**ControllerName
156 USB_KB_DEV
*UsbKbDev
;
157 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*SimpleTxtIn
;
158 EFI_USB_IO_PROTOCOL
*UsbIoProtocol
;
160 // This is a device driver, so ChildHandle must be NULL.
162 if (ChildHandle
!= NULL
) {
163 return EFI_UNSUPPORTED
;
167 // Check Controller's handle
169 Status
= gBS
->OpenProtocol (
171 &gEfiUsbIoProtocolGuid
,
172 (VOID
**) &UsbIoProtocol
,
173 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
175 EFI_OPEN_PROTOCOL_BY_DRIVER
177 if (!EFI_ERROR (Status
)) {
180 &gEfiUsbIoProtocolGuid
,
181 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
185 return EFI_UNSUPPORTED
;
188 if (Status
!= EFI_ALREADY_STARTED
) {
189 return EFI_UNSUPPORTED
;
192 // Get the device context
194 Status
= gBS
->OpenProtocol (
196 &gEfiSimpleTextInProtocolGuid
,
197 (VOID
**) &SimpleTxtIn
,
198 gUsbKeyboardDriverBinding
.DriverBindingHandle
,
200 EFI_OPEN_PROTOCOL_GET_PROTOCOL
203 if (EFI_ERROR (Status
)) {
207 UsbKbDev
= USB_KB_DEV_FROM_THIS (SimpleTxtIn
);
209 return LookupUnicodeString2 (
211 This
->SupportedLanguages
,
212 UsbKbDev
->ControllerNameTable
,
214 (BOOLEAN
)(This
== &gUsbKeyboardComponentName
)