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