]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c
Refine the comments.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / ComponentName.c
CommitLineData
f713c4fe 1/** @file\r
2 Routines related Component Name protocol.\r
3 \r
4Copyright (c) 2006 - 2009, Intel Corporation\r
df0dcb5e 5All rights reserved. This 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
05fbd06d 12\r
f8cd287b 13**/\r
05fbd06d 14\r
05fbd06d 15#include "Ps2Keyboard.h"\r
16\r
17//\r
18// EFI Component Name Functions\r
19//\r
f3d08ccf 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
4bca47e1 40 in RFC 4646 or ISO 639-2 language code format.\r
f3d08ccf 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
05fbd06d 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
f3d08ccf 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
4bca47e1 105 RFC 4646 or ISO 639-2 language code format.\r
f3d08ccf 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 not a valid EFI_HANDLE.\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
05fbd06d 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
f3d08ccf 146\r
05fbd06d 147//\r
148// EFI Component Name Protocol\r
149//\r
1307dcd7 150GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {\r
05fbd06d 151 Ps2KeyboardComponentNameGetDriverName,\r
152 Ps2KeyboardComponentNameGetControllerName,\r
153 "eng"\r
1307dcd7 154};\r
f3d08ccf 155\r
156//\r
157// EFI Component Name 2 Protocol\r
158//\r
1307dcd7 159GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2 = {\r
f3d08ccf 160 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2KeyboardComponentNameGetDriverName,\r
161 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2KeyboardComponentNameGetControllerName,\r
162 "en"\r
1307dcd7 163};\r
f3d08ccf 164\r
05fbd06d 165\r
d1aeb0bd 166GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {\r
05fbd06d 167 {\r
f3d08ccf 168 "eng;en",\r
05fbd06d 169 L"PS/2 Keyboard Driver"\r
170 },\r
171 {\r
172 NULL,\r
173 NULL\r
174 }\r
175};\r
176\r
f3d08ccf 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
4bca47e1 197 in RFC 4646 or ISO 639-2 language code format.\r
f3d08ccf 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
05fbd06d 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
f3d08ccf 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
05fbd06d 232\r
f3d08ccf 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
05fbd06d 236\r
f3d08ccf 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
05fbd06d 245\r
f3d08ccf 246 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
247 EFI_COMPONENT_NAME_PROTOCOL instance.\r
05fbd06d 248\r
f3d08ccf 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
05fbd06d 253\r
f3d08ccf 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
05fbd06d 262\r
f3d08ccf 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
4bca47e1 270 RFC 4646 or ISO 639-2 language code format.\r
05fbd06d 271\r
f3d08ccf 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
05fbd06d 283\r
f3d08ccf 284 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\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
05fbd06d 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
05fbd06d 310{\r
311 EFI_STATUS Status;\r
312 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r
313 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
314 EFI_ISA_IO_PROTOCOL *IsaIoProtocol;\r
315\r
316 //\r
317 // This is a device driver, so ChildHandle must be NULL.\r
318 //\r
319 if (ChildHandle != NULL) {\r
320 return EFI_UNSUPPORTED;\r
321 }\r
322 //\r
323 // Check Controller's handle\r
324 //\r
325 Status = gBS->OpenProtocol (\r
326 ControllerHandle,\r
327 &gEfiIsaIoProtocolGuid,\r
328 (VOID **) &IsaIoProtocol,\r
329 gKeyboardControllerDriver.DriverBindingHandle,\r
330 ControllerHandle,\r
331 EFI_OPEN_PROTOCOL_BY_DRIVER\r
332 );\r
c21fc3e8 333\r
05fbd06d 334 if (!EFI_ERROR (Status)) {\r
335 gBS->CloseProtocol (\r
336 ControllerHandle,\r
337 &gEfiIsaIoProtocolGuid,\r
338 gKeyboardControllerDriver.DriverBindingHandle,\r
339 ControllerHandle\r
340 );\r
341\r
342 return EFI_UNSUPPORTED;\r
343 }\r
344\r
345 if (Status != EFI_ALREADY_STARTED) {\r
346 return EFI_UNSUPPORTED;\r
347 }\r
348 //\r
349 // Get the device context\r
350 //\r
351 Status = gBS->OpenProtocol (\r
352 ControllerHandle,\r
353 &gEfiSimpleTextInProtocolGuid,\r
354 (VOID **) &ConIn,\r
355 gKeyboardControllerDriver.DriverBindingHandle,\r
356 ControllerHandle,\r
357 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
358 );\r
359 if (EFI_ERROR (Status)) {\r
360 return Status;\r
361 }\r
362\r
363 ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
364\r
f3d08ccf 365 return LookupUnicodeString2 (\r
05fbd06d 366 Language,\r
f3d08ccf 367 This->SupportedLanguages,\r
05fbd06d 368 ConsoleIn->ControllerNameTable,\r
f3d08ccf 369 ControllerName,\r
370 (BOOLEAN)(This == &gPs2KeyboardComponentName)\r
05fbd06d 371 );\r
372}\r