]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Isa / Ps2KeyboardDxe / ComponentName.c
1 /** @file
2 Routines related Component Name protocol.
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "Ps2Keyboard.h"
10
11 //
12 // EFI Component Name Functions
13 //
14 /**
15 Retrieves a Unicode string that is the user readable name of the driver.
16
17 This function retrieves the user readable name of a driver in the form of a
18 Unicode string. If the driver specified by This has a user readable name in
19 the language specified by Language, then a pointer to the driver name is
20 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
21 by This does not support the language specified by Language,
22 then EFI_UNSUPPORTED is returned.
23
24 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
25 EFI_COMPONENT_NAME_PROTOCOL instance.
26
27 @param Language[in] A pointer to a Null-terminated ASCII string
28 array indicating the language. This is the
29 language of the driver name that the caller is
30 requesting, and it must match one of the
31 languages specified in SupportedLanguages. The
32 number of languages supported by a driver is up
33 to the driver writer. Language is specified
34 in RFC 4646 or ISO 639-2 language code format.
35
36 @param DriverName[out] A pointer to the Unicode string to return.
37 This Unicode string is the name of the
38 driver specified by This in the language
39 specified by Language.
40
41 @retval EFI_SUCCESS The Unicode string for the Driver specified by
42 This and the language specified by Language was
43 returned in DriverName.
44
45 @retval EFI_INVALID_PARAMETER Language is NULL.
46
47 @retval EFI_INVALID_PARAMETER DriverName is NULL.
48
49 @retval EFI_UNSUPPORTED The driver specified by This does not support
50 the language specified by Language.
51
52 **/
53 EFI_STATUS
54 EFIAPI
55 Ps2KeyboardComponentNameGetDriverName (
56 IN EFI_COMPONENT_NAME_PROTOCOL *This,
57 IN CHAR8 *Language,
58 OUT CHAR16 **DriverName
59 );
60
61
62 /**
63 Retrieves a Unicode string that is the user readable name of the controller
64 that is being managed by a driver.
65
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.
74
75 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
76 EFI_COMPONENT_NAME_PROTOCOL instance.
77
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
81 returned.
82
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
90 child controller.
91
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.
100
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
106 specified by This.
107
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
111 DriverName.
112
113 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
114
115 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
116 EFI_HANDLE.
117
118 @retval EFI_INVALID_PARAMETER Language is NULL.
119
120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
121
122 @retval EFI_UNSUPPORTED The driver specified by This is not currently
123 managing the controller specified by
124 ControllerHandle and ChildHandle.
125
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
128
129 **/
130 EFI_STATUS
131 EFIAPI
132 Ps2KeyboardComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL *This,
134 IN EFI_HANDLE ControllerHandle,
135 IN EFI_HANDLE ChildHandle OPTIONAL,
136 IN CHAR8 *Language,
137 OUT CHAR16 **ControllerName
138 );
139
140
141 //
142 // EFI Component Name Protocol
143 //
144 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
145 Ps2KeyboardComponentNameGetDriverName,
146 Ps2KeyboardComponentNameGetControllerName,
147 "eng"
148 };
149
150 //
151 // EFI Component Name 2 Protocol
152 //
153 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2 = {
154 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2KeyboardComponentNameGetDriverName,
155 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2KeyboardComponentNameGetControllerName,
156 "en"
157 };
158
159
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
161 {
162 "eng;en",
163 L"PS/2 Keyboard Driver"
164 },
165 {
166 NULL,
167 NULL
168 }
169 };
170
171 /**
172 Retrieves a Unicode string that is the user readable name of the driver.
173
174 This function retrieves the user readable name of a driver in the form of a
175 Unicode string. If the driver specified by This has a user readable name in
176 the language specified by Language, then a pointer to the driver name is
177 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
178 by This does not support the language specified by Language,
179 then EFI_UNSUPPORTED is returned.
180
181 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
182 EFI_COMPONENT_NAME_PROTOCOL instance.
183
184 @param Language[in] A pointer to a Null-terminated ASCII string
185 array indicating the language. This is the
186 language of the driver name that the caller is
187 requesting, and it must match one of the
188 languages specified in SupportedLanguages. The
189 number of languages supported by a driver is up
190 to the driver writer. Language is specified
191 in RFC 4646 or ISO 639-2 language code format.
192
193 @param DriverName[out] A pointer to the Unicode string to return.
194 This Unicode string is the name of the
195 driver specified by This in the language
196 specified by Language.
197
198 @retval EFI_SUCCESS The Unicode string for the Driver specified by
199 This and the language specified by Language was
200 returned in DriverName.
201
202 @retval EFI_INVALID_PARAMETER Language is NULL.
203
204 @retval EFI_INVALID_PARAMETER DriverName is NULL.
205
206 @retval EFI_UNSUPPORTED The driver specified by This does not support
207 the language specified by Language.
208
209 **/
210 EFI_STATUS
211 EFIAPI
212 Ps2KeyboardComponentNameGetDriverName (
213 IN EFI_COMPONENT_NAME_PROTOCOL *This,
214 IN CHAR8 *Language,
215 OUT CHAR16 **DriverName
216 )
217 {
218 return LookupUnicodeString2 (
219 Language,
220 This->SupportedLanguages,
221 mPs2KeyboardDriverNameTable,
222 DriverName,
223 (BOOLEAN)(This == &gPs2KeyboardComponentName)
224 );
225 }
226
227 /**
228 Retrieves a Unicode string that is the user readable name of the controller
229 that is being managed by a driver.
230
231 This function retrieves the user readable name of the controller specified by
232 ControllerHandle and ChildHandle in the form of a Unicode string. If the
233 driver specified by This has a user readable name in the language specified by
234 Language, then a pointer to the controller name is returned in ControllerName,
235 and EFI_SUCCESS is returned. If the driver specified by This is not currently
236 managing the controller specified by ControllerHandle and ChildHandle,
237 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
238 support the language specified by Language, then EFI_UNSUPPORTED is returned.
239
240 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
241 EFI_COMPONENT_NAME_PROTOCOL instance.
242
243 @param ControllerHandle[in] The handle of a controller that the driver
244 specified by This is managing. This handle
245 specifies the controller whose name is to be
246 returned.
247
248 @param ChildHandle[in] The handle of the child controller to retrieve
249 the name of. This is an optional parameter that
250 may be NULL. It will be NULL for device
251 drivers. It will also be NULL for a bus drivers
252 that wish to retrieve the name of the bus
253 controller. It will not be NULL for a bus
254 driver that wishes to retrieve the name of a
255 child controller.
256
257 @param Language[in] A pointer to a Null-terminated ASCII string
258 array indicating the language. This is the
259 language of the driver name that the caller is
260 requesting, and it must match one of the
261 languages specified in SupportedLanguages. The
262 number of languages supported by a driver is up
263 to the driver writer. Language is specified in
264 RFC 4646 or ISO 639-2 language code format.
265
266 @param ControllerName[out] A pointer to the Unicode string to return.
267 This Unicode string is the name of the
268 controller specified by ControllerHandle and
269 ChildHandle in the language specified by
270 Language from the point of view of the driver
271 specified by This.
272
273 @retval EFI_SUCCESS The Unicode string for the user readable name in
274 the language specified by Language for the
275 driver specified by This was returned in
276 DriverName.
277
278 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
279
280 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
281 EFI_HANDLE.
282
283 @retval EFI_INVALID_PARAMETER Language is NULL.
284
285 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
286
287 @retval EFI_UNSUPPORTED The driver specified by This is not currently
288 managing the controller specified by
289 ControllerHandle and ChildHandle.
290
291 @retval EFI_UNSUPPORTED The driver specified by This does not support
292 the language specified by Language.
293
294 **/
295 EFI_STATUS
296 EFIAPI
297 Ps2KeyboardComponentNameGetControllerName (
298 IN EFI_COMPONENT_NAME_PROTOCOL *This,
299 IN EFI_HANDLE ControllerHandle,
300 IN EFI_HANDLE ChildHandle OPTIONAL,
301 IN CHAR8 *Language,
302 OUT CHAR16 **ControllerName
303 )
304 {
305 EFI_STATUS Status;
306 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
307 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
308 //
309 // This is a device driver, so ChildHandle must be NULL.
310 //
311 if (ChildHandle != NULL) {
312 return EFI_UNSUPPORTED;
313 }
314
315 //
316 // Check Controller's handle
317 //
318 Status = EfiTestManagedDevice (ControllerHandle, gKeyboardControllerDriver.DriverBindingHandle, &gEfiSioProtocolGuid);
319 if (EFI_ERROR (Status)) {
320 return Status;
321 }
322 //
323 // Get the device context
324 //
325 Status = gBS->OpenProtocol (
326 ControllerHandle,
327 &gEfiSimpleTextInProtocolGuid,
328 (VOID **) &ConIn,
329 gKeyboardControllerDriver.DriverBindingHandle,
330 ControllerHandle,
331 EFI_OPEN_PROTOCOL_GET_PROTOCOL
332 );
333 if (EFI_ERROR (Status)) {
334 return Status;
335 }
336
337 ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
338
339 return LookupUnicodeString2 (
340 Language,
341 This->SupportedLanguages,
342 ConsoleIn->ControllerNameTable,
343 ControllerName,
344 (BOOLEAN)(This == &gPs2KeyboardComponentName)
345 );
346 }