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