]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c
MdeModulePkg: Apply uncrustify changes
[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 /**
16 Retrieves a Unicode string that is the user readable name of the driver.
17
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.
24
25 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
26 EFI_COMPONENT_NAME_PROTOCOL instance.
27
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.
36
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.
41
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.
45
46 @retval EFI_INVALID_PARAMETER Language is NULL.
47
48 @retval EFI_INVALID_PARAMETER DriverName is NULL.
49
50 @retval EFI_UNSUPPORTED The driver specified by This does not support
51 the language specified by Language.
52
53 **/
54 EFI_STATUS
55 EFIAPI
56 Ps2KeyboardComponentNameGetDriverName (
57 IN EFI_COMPONENT_NAME_PROTOCOL *This,
58 IN CHAR8 *Language,
59 OUT CHAR16 **DriverName
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 // EFI Component Name Protocol
142 //
143 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
144 Ps2KeyboardComponentNameGetDriverName,
145 Ps2KeyboardComponentNameGetControllerName,
146 "eng"
147 };
148
149 //
150 // EFI Component Name 2 Protocol
151 //
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,
155 "en"
156 };
157
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
159 {
160 "eng;en",
161 L"PS/2 Keyboard Driver"
162 },
163 {
164 NULL,
165 NULL
166 }
167 };
168
169 /**
170 Retrieves a Unicode string that is the user readable name of the driver.
171
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.
178
179 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
180 EFI_COMPONENT_NAME_PROTOCOL instance.
181
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.
190
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.
195
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.
199
200 @retval EFI_INVALID_PARAMETER Language is NULL.
201
202 @retval EFI_INVALID_PARAMETER DriverName is NULL.
203
204 @retval EFI_UNSUPPORTED The driver specified by This does not support
205 the language specified by Language.
206
207 **/
208 EFI_STATUS
209 EFIAPI
210 Ps2KeyboardComponentNameGetDriverName (
211 IN EFI_COMPONENT_NAME_PROTOCOL *This,
212 IN CHAR8 *Language,
213 OUT CHAR16 **DriverName
214 )
215 {
216 return LookupUnicodeString2 (
217 Language,
218 This->SupportedLanguages,
219 mPs2KeyboardDriverNameTable,
220 DriverName,
221 (BOOLEAN)(This == &gPs2KeyboardComponentName)
222 );
223 }
224
225 /**
226 Retrieves a Unicode string that is the user readable name of the controller
227 that is being managed by a driver.
228
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.
237
238 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
239 EFI_COMPONENT_NAME_PROTOCOL instance.
240
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
244 returned.
245
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
253 child controller.
254
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.
263
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
269 specified by This.
270
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
274 DriverName.
275
276 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
277
278 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
279 EFI_HANDLE.
280
281 @retval EFI_INVALID_PARAMETER Language is NULL.
282
283 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
284
285 @retval EFI_UNSUPPORTED The driver specified by This is not currently
286 managing the controller specified by
287 ControllerHandle and ChildHandle.
288
289 @retval EFI_UNSUPPORTED The driver specified by This does not support
290 the language specified by Language.
291
292 **/
293 EFI_STATUS
294 EFIAPI
295 Ps2KeyboardComponentNameGetControllerName (
296 IN EFI_COMPONENT_NAME_PROTOCOL *This,
297 IN EFI_HANDLE ControllerHandle,
298 IN EFI_HANDLE ChildHandle OPTIONAL,
299 IN CHAR8 *Language,
300 OUT CHAR16 **ControllerName
301 )
302 {
303 EFI_STATUS Status;
304 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
305 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
306
307 //
308 // This is a device driver, so ChildHandle must be NULL.
309 //
310 if (ChildHandle != NULL) {
311 return EFI_UNSUPPORTED;
312 }
313
314 //
315 // Check Controller's handle
316 //
317 Status = EfiTestManagedDevice (ControllerHandle, gKeyboardControllerDriver.DriverBindingHandle, &gEfiSioProtocolGuid);
318 if (EFI_ERROR (Status)) {
319 return Status;
320 }
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 }