2 Routines related Component Name protocol.
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "Ps2Keyboard.h"
12 // EFI Component Name Functions
16 Retrieves a Unicode string that is the user readable name of the driver.
18 This function retrieves the user readable name of a driver in the form of a
19 Unicode string. If the driver specified by This has a user readable name in
20 the language specified by Language, then a pointer to the driver name is
21 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
22 by This does not support the language specified by Language,
23 then EFI_UNSUPPORTED is returned.
25 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
26 EFI_COMPONENT_NAME_PROTOCOL instance.
28 @param Language[in] A pointer to a Null-terminated ASCII string
29 array indicating the language. This is the
30 language of the driver name that the caller is
31 requesting, and it must match one of the
32 languages specified in SupportedLanguages. The
33 number of languages supported by a driver is up
34 to the driver writer. Language is specified
35 in RFC 4646 or ISO 639-2 language code format.
37 @param DriverName[out] A pointer to the Unicode string to return.
38 This Unicode string is the name of the
39 driver specified by This in the language
40 specified by Language.
42 @retval EFI_SUCCESS The Unicode string for the Driver specified by
43 This and the language specified by Language was
44 returned in DriverName.
46 @retval EFI_INVALID_PARAMETER Language is NULL.
48 @retval EFI_INVALID_PARAMETER DriverName is NULL.
50 @retval EFI_UNSUPPORTED The driver specified by This does not support
51 the language specified by Language.
56 Ps2KeyboardComponentNameGetDriverName (
57 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
59 OUT CHAR16
**DriverName
63 Retrieves a Unicode string that is the user readable name of the controller
64 that is being managed by a driver.
66 This function retrieves the user readable name of the controller specified by
67 ControllerHandle and ChildHandle in the form of a Unicode string. If the
68 driver specified by This has a user readable name in the language specified by
69 Language, then a pointer to the controller name is returned in ControllerName,
70 and EFI_SUCCESS is returned. If the driver specified by This is not currently
71 managing the controller specified by ControllerHandle and ChildHandle,
72 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
73 support the language specified by Language, then EFI_UNSUPPORTED is returned.
75 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
76 EFI_COMPONENT_NAME_PROTOCOL instance.
78 @param ControllerHandle[in] The handle of a controller that the driver
79 specified by This is managing. This handle
80 specifies the controller whose name is to be
83 @param ChildHandle[in] The handle of the child controller to retrieve
84 the name of. This is an optional parameter that
85 may be NULL. It will be NULL for device
86 drivers. It will also be NULL for a bus drivers
87 that wish to retrieve the name of the bus
88 controller. It will not be NULL for a bus
89 driver that wishes to retrieve the name of a
92 @param Language[in] A pointer to a Null-terminated ASCII string
93 array indicating the language. This is the
94 language of the driver name that the caller is
95 requesting, and it must match one of the
96 languages specified in SupportedLanguages. The
97 number of languages supported by a driver is up
98 to the driver writer. Language is specified in
99 RFC 4646 or ISO 639-2 language code format.
101 @param ControllerName[out] A pointer to the Unicode string to return.
102 This Unicode string is the name of the
103 controller specified by ControllerHandle and
104 ChildHandle in the language specified by
105 Language from the point of view of the driver
108 @retval EFI_SUCCESS The Unicode string for the user readable name in
109 the language specified by Language for the
110 driver specified by This was returned in
113 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
115 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
118 @retval EFI_INVALID_PARAMETER Language is NULL.
120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
122 @retval EFI_UNSUPPORTED The driver specified by This is not currently
123 managing the controller specified by
124 ControllerHandle and ChildHandle.
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
132 Ps2KeyboardComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
134 IN EFI_HANDLE ControllerHandle
,
135 IN EFI_HANDLE ChildHandle OPTIONAL
,
137 OUT CHAR16
**ControllerName
141 // EFI Component Name Protocol
143 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName
= {
144 Ps2KeyboardComponentNameGetDriverName
,
145 Ps2KeyboardComponentNameGetControllerName
,
150 // EFI Component Name 2 Protocol
152 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2
= {
153 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)Ps2KeyboardComponentNameGetDriverName
,
154 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)Ps2KeyboardComponentNameGetControllerName
,
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable
[] = {
161 L
"PS/2 Keyboard Driver"
170 Retrieves a Unicode string that is the user readable name of the driver.
172 This function retrieves the user readable name of a driver in the form of a
173 Unicode string. If the driver specified by This has a user readable name in
174 the language specified by Language, then a pointer to the driver name is
175 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
176 by This does not support the language specified by Language,
177 then EFI_UNSUPPORTED is returned.
179 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
180 EFI_COMPONENT_NAME_PROTOCOL instance.
182 @param Language[in] A pointer to a Null-terminated ASCII string
183 array indicating the language. This is the
184 language of the driver name that the caller is
185 requesting, and it must match one of the
186 languages specified in SupportedLanguages. The
187 number of languages supported by a driver is up
188 to the driver writer. Language is specified
189 in RFC 4646 or ISO 639-2 language code format.
191 @param DriverName[out] A pointer to the Unicode string to return.
192 This Unicode string is the name of the
193 driver specified by This in the language
194 specified by Language.
196 @retval EFI_SUCCESS The Unicode string for the Driver specified by
197 This and the language specified by Language was
198 returned in DriverName.
200 @retval EFI_INVALID_PARAMETER Language is NULL.
202 @retval EFI_INVALID_PARAMETER DriverName is NULL.
204 @retval EFI_UNSUPPORTED The driver specified by This does not support
205 the language specified by Language.
210 Ps2KeyboardComponentNameGetDriverName (
211 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
213 OUT CHAR16
**DriverName
216 return LookupUnicodeString2 (
218 This
->SupportedLanguages
,
219 mPs2KeyboardDriverNameTable
,
221 (BOOLEAN
)(This
== &gPs2KeyboardComponentName
)
226 Retrieves a Unicode string that is the user readable name of the controller
227 that is being managed by a driver.
229 This function retrieves the user readable name of the controller specified by
230 ControllerHandle and ChildHandle in the form of a Unicode string. If the
231 driver specified by This has a user readable name in the language specified by
232 Language, then a pointer to the controller name is returned in ControllerName,
233 and EFI_SUCCESS is returned. If the driver specified by This is not currently
234 managing the controller specified by ControllerHandle and ChildHandle,
235 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
236 support the language specified by Language, then EFI_UNSUPPORTED is returned.
238 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
239 EFI_COMPONENT_NAME_PROTOCOL instance.
241 @param ControllerHandle[in] The handle of a controller that the driver
242 specified by This is managing. This handle
243 specifies the controller whose name is to be
246 @param ChildHandle[in] The handle of the child controller to retrieve
247 the name of. This is an optional parameter that
248 may be NULL. It will be NULL for device
249 drivers. It will also be NULL for a bus drivers
250 that wish to retrieve the name of the bus
251 controller. It will not be NULL for a bus
252 driver that wishes to retrieve the name of a
255 @param Language[in] A pointer to a Null-terminated ASCII string
256 array indicating the language. This is the
257 language of the driver name that the caller is
258 requesting, and it must match one of the
259 languages specified in SupportedLanguages. The
260 number of languages supported by a driver is up
261 to the driver writer. Language is specified in
262 RFC 4646 or ISO 639-2 language code format.
264 @param ControllerName[out] A pointer to the Unicode string to return.
265 This Unicode string is the name of the
266 controller specified by ControllerHandle and
267 ChildHandle in the language specified by
268 Language from the point of view of the driver
271 @retval EFI_SUCCESS The Unicode string for the user readable name in
272 the language specified by Language for the
273 driver specified by This was returned in
276 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
278 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
281 @retval EFI_INVALID_PARAMETER Language is NULL.
283 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
285 @retval EFI_UNSUPPORTED The driver specified by This is not currently
286 managing the controller specified by
287 ControllerHandle and ChildHandle.
289 @retval EFI_UNSUPPORTED The driver specified by This does not support
290 the language specified by Language.
295 Ps2KeyboardComponentNameGetControllerName (
296 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
297 IN EFI_HANDLE ControllerHandle
,
298 IN EFI_HANDLE ChildHandle OPTIONAL
,
300 OUT CHAR16
**ControllerName
304 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*ConIn
;
305 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
308 // This is a device driver, so ChildHandle must be NULL.
310 if (ChildHandle
!= NULL
) {
311 return EFI_UNSUPPORTED
;
315 // Check Controller's handle
317 Status
= EfiTestManagedDevice (ControllerHandle
, gKeyboardControllerDriver
.DriverBindingHandle
, &gEfiSioProtocolGuid
);
318 if (EFI_ERROR (Status
)) {
323 // Get the device context
325 Status
= gBS
->OpenProtocol (
327 &gEfiSimpleTextInProtocolGuid
,
329 gKeyboardControllerDriver
.DriverBindingHandle
,
331 EFI_OPEN_PROTOCOL_GET_PROTOCOL
333 if (EFI_ERROR (Status
)) {
337 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn
);
339 return LookupUnicodeString2 (
341 This
->SupportedLanguages
,
342 ConsoleIn
->ControllerNameTable
,
344 (BOOLEAN
)(This
== &gPs2KeyboardComponentName
)