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