]>
Commit | Line | Data |
---|---|---|
bcecde14 | 1 | /** @file\r |
2 | \r | |
cc9a430c | 3 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
bcecde14 | 4 | \r |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions\r | |
7 | of the BSD License which accompanies this distribution. The\r | |
8 | full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _BIOS_KEYBOARD_H_\r | |
17 | #define _BIOS_KEYBOARD_H_\r | |
18 | \r | |
19 | \r | |
20 | #include <FrameworkDxe.h>\r | |
21 | \r | |
22 | #include <Guid/StatusCodeDataTypeId.h>\r | |
23 | #include <Protocol/SimpleTextIn.h>\r | |
24 | #include <Protocol/SimpleTextInEx.h>\r | |
25 | #include <Protocol/LegacyBios.h>\r | |
26 | #include <Protocol/IsaIo.h>\r | |
27 | #include <Protocol/DevicePath.h>\r | |
28 | #include <Protocol/Ps2Policy.h>\r | |
29 | \r | |
30 | #include <Library/DebugLib.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
33 | #include <Library/ReportStatusCodeLib.h>\r | |
34 | #include <Library/UefiDriverEntryPoint.h>\r | |
35 | #include <Library/UefiBootServicesTableLib.h>\r | |
36 | #include <Library/MemoryAllocationLib.h>\r | |
37 | #include <Library/BaseLib.h>\r | |
f6c014fb | 38 | #include <Library/PcdLib.h>\r |
bcecde14 | 39 | \r |
40 | //\r | |
41 | // Driver Binding Externs\r | |
42 | //\r | |
43 | extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;\r | |
44 | extern EFI_COMPONENT_NAME_PROTOCOL gBiosKeyboardComponentName;\r | |
45 | extern EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2;\r | |
46 | \r | |
47 | \r | |
48 | #include <IndustryStandard/Pci.h>\r | |
49 | \r | |
50 | //\r | |
51 | // BISO Keyboard Defines\r | |
52 | //\r | |
53 | #define CHAR_SCANCODE 0xe0\r | |
54 | #define CHAR_ESC 0x1b\r | |
55 | \r | |
56 | #define KEYBOARD_8042_DATA_REGISTER 0x60\r | |
57 | #define KEYBOARD_8042_STATUS_REGISTER 0x64\r | |
58 | #define KEYBOARD_8042_COMMAND_REGISTER 0x64\r | |
59 | \r | |
60 | #define KEYBOARD_TIMEOUT 65536 // 0.07s\r | |
61 | #define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s\r | |
62 | #define KEYBOARD_BAT_TIMEOUT 4000000 // 4s\r | |
63 | #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s\r | |
64 | // KEYBOARD COMMAND BYTE -- read by writing command KBC_CMDREG_VIA64_CMDBYTE_R to 64H, then read from 60H\r | |
65 | // write by wrting command KBC_CMDREG_VIA64_CMDBYTE_W to 64H, then write to 60H\r | |
66 | // 7: Reserved\r | |
67 | // 6: PC/XT translation mode convert\r | |
68 | // 5: Disable Auxiliary device interface\r | |
69 | // 4: Disable keyboard interface\r | |
70 | // 3: Reserved\r | |
71 | // 2: System Flag: selftest successful\r | |
72 | // 1: Enable Auxiliary device interrupt\r | |
73 | // 0: Enable Keyboard interrupt )\r | |
74 | //\r | |
75 | #define KB_CMMBYTE_KSCAN2UNI_COV (0x1 << 6)\r | |
76 | #define KB_CMMBYTE_DISABLE_AUX (0x1 << 5)\r | |
77 | #define KB_CMMBYTE_DISABLE_KB (0x1 << 4)\r | |
78 | #define KB_CMMBYTE_SLFTEST_SUCC (0x1 << 2)\r | |
79 | #define KB_CMMBYTE_ENABLE_AUXINT (0x1 << 1)\r | |
80 | #define KB_CMMBYTE_ENABLE_KBINT (0x1 << 0)\r | |
81 | \r | |
82 | //\r | |
83 | // KEYBOARD CONTROLLER STATUS REGISTER - read from 64h\r | |
84 | // 7: Parity error\r | |
85 | // 6: General time out\r | |
86 | // 5: Output buffer holds data for AUX\r | |
87 | // 4: Keyboard is not locked\r | |
88 | // 3: Command written via 64h / Data written via 60h\r | |
89 | // 2: KBC self-test successful / Power-on reset\r | |
90 | // 1: Input buffer holds CPU data / empty\r | |
91 | // 0: Output buffer holds keyboard data / empty\r | |
92 | //\r | |
93 | #define KBC_STSREG_VIA64_PARE (0x1 << 7)\r | |
94 | #define KBC_STSREG_VIA64_TIM (0x1 << 6)\r | |
95 | #define KBC_STSREG_VIA64_AUXB (0x1 << 5)\r | |
96 | #define KBC_STSREG_VIA64_KEYL (0x1 << 4)\r | |
97 | #define KBC_STSREG_VIA64_C_D (0x1 << 3)\r | |
98 | #define KBC_STSREG_VIA64_SYSF (0x1 << 2)\r | |
99 | #define KBC_STSREG_VIA64_INPB (0x1 << 1)\r | |
100 | #define KBC_STSREG_VIA64_OUTB (0x1 << 0)\r | |
101 | \r | |
102 | //\r | |
103 | // COMMANDs of KEYBOARD CONTROLLER COMMAND REGISTER - write to 64h\r | |
104 | //\r | |
105 | #define KBC_CMDREG_VIA64_CMDBYTE_R 0x20\r | |
106 | #define KBC_CMDREG_VIA64_CMDBYTE_W 0x60\r | |
107 | #define KBC_CMDREG_VIA64_AUX_DISABLE 0xA7\r | |
108 | #define KBC_CMDREG_VIA64_AUX_ENABLE 0xA8\r | |
109 | #define KBC_CMDREG_VIA64_KBC_SLFTEST 0xAA\r | |
110 | #define KBC_CMDREG_VIA64_KB_CKECK 0xAB\r | |
111 | #define KBC_CMDREG_VIA64_KB_DISABLE 0xAD\r | |
112 | #define KBC_CMDREG_VIA64_KB_ENABLE 0xAE\r | |
113 | #define KBC_CMDREG_VIA64_INTP_LOW_R 0xC0\r | |
114 | #define KBC_CMDREG_VIA64_INTP_HIGH_R 0xC2\r | |
115 | #define KBC_CMDREG_VIA64_OUTP_R 0xD0\r | |
116 | #define KBC_CMDREG_VIA64_OUTP_W 0xD1\r | |
117 | #define KBC_CMDREG_VIA64_OUTB_KB_W 0xD2\r | |
118 | #define KBC_CMDREG_VIA64_OUTB_AUX_W 0xD3\r | |
119 | #define KBC_CMDREG_VIA64_AUX_W 0xD4\r | |
120 | \r | |
121 | //\r | |
122 | // echos of KEYBOARD CONTROLLER COMMAND - read from 60h\r | |
123 | //\r | |
124 | #define KBC_CMDECHO_KBCSLFTEST_OK 0x55\r | |
125 | #define KBC_CMDECHO_KBCHECK_OK 0x00\r | |
126 | #define KBC_CMDECHO_ACK 0xFA\r | |
127 | #define KBC_CMDECHO_BATTEST_OK 0xAA\r | |
128 | #define KBC_CMDECHO_BATTEST_FAILE 0xFC\r | |
129 | \r | |
130 | //\r | |
131 | // OUTPUT PORT COMMANDs - write port by writing KBC_CMDREG_VIA64_OUTP_W via 64H, then write the command to 60H\r | |
132 | // drive data and clock of KB to high for at least 500us for BAT needs\r | |
133 | //\r | |
134 | #define KBC_OUTPORT_DCHIGH_BAT 0xC0\r | |
135 | //\r | |
136 | // scan code set type\r | |
137 | //\r | |
138 | #define KBC_INPBUF_VIA60_SCODESET1 0x01\r | |
139 | #define KBC_INPBUF_VIA60_SCODESET2 0x02\r | |
140 | #define KBC_INPBUF_VIA60_SCODESET3 0x03\r | |
141 | \r | |
142 | //\r | |
143 | // COMMANDs written to INPUT BUFFER - write to 60h\r | |
144 | //\r | |
145 | #define KBC_INPBUF_VIA60_KBECHO 0xEE\r | |
146 | #define KBC_INPBUF_VIA60_KBSCODE 0xF0\r | |
147 | #define KBC_INPBUF_VIA60_KBTYPE 0xF2\r | |
148 | #define KBC_INPBUF_VIA60_KBDELAY 0xF3\r | |
149 | #define KBC_INPBUF_VIA60_KBEN 0xF4\r | |
150 | #define KBC_INPBUF_VIA60_KBSTDDIS 0xF5\r | |
151 | #define KBC_INPBUF_VIA60_KBSTDEN 0xF6\r | |
152 | #define KBC_INPBUF_VIA60_KBRESEND 0xFE\r | |
153 | #define KBC_INPBUF_VIA60_KBRESET 0xFF\r | |
154 | \r | |
155 | //\r | |
156 | // 0040h:0017h - KEYBOARD - STATUS FLAGS 1\r | |
157 | // 7 INSert active\r | |
158 | // 6 Caps Lock active\r | |
159 | // 5 Num Lock active\r | |
160 | // 4 Scroll Lock active\r | |
161 | // 3 either Alt pressed\r | |
162 | // 2 either Ctrl pressed\r | |
163 | // 1 Left Shift pressed\r | |
164 | // 0 Right Shift pressed\r | |
165 | //\r | |
166 | // 0040h:0018h - KEYBOARD - STATUS FLAGS 2\r | |
167 | // 7: insert key is depressed\r | |
168 | // 6: caps-lock key is depressed (does not work well)\r | |
169 | // 5: num-lock key is depressed (does not work well)\r | |
170 | // 4: scroll lock key is depressed (does not work well)\r | |
171 | // 3: suspend key has been toggled (does not work well)\r | |
172 | // 2: system key is pressed and held (does not work well)\r | |
173 | // 1: left ALT key is pressed\r | |
174 | // 0: left CTRL key is pressed\r | |
175 | //\r | |
176 | #define KB_INSERT_BIT (0x1 << 7)\r | |
177 | #define KB_CAPS_LOCK_BIT (0x1 << 6)\r | |
178 | #define KB_NUM_LOCK_BIT (0x1 << 5)\r | |
179 | #define KB_SCROLL_LOCK_BIT (0x1 << 4)\r | |
180 | #define KB_ALT_PRESSED (0x1 << 3)\r | |
181 | #define KB_CTRL_PRESSED (0x1 << 2)\r | |
182 | #define KB_LEFT_SHIFT_PRESSED (0x1 << 1)\r | |
183 | #define KB_RIGHT_SHIFT_PRESSED (0x1 << 0)\r | |
184 | \r | |
185 | #define KB_SUSPEND_PRESSED (0x1 << 3)\r | |
186 | #define KB_SYSREQ_PRESSED (0x1 << 2)\r | |
187 | #define KB_LEFT_ALT_PRESSED (0x1 << 1)\r | |
188 | #define KB_LEFT_CTRL_PRESSED (0x1 << 0)\r | |
189 | \r | |
190 | //\r | |
191 | // BIOS Keyboard Device Structure\r | |
192 | //\r | |
193 | #define BIOS_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('B', 'K', 'B', 'D')\r | |
194 | #define BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('c', 'b', 'k', 'h')\r | |
195 | \r | |
196 | typedef struct _BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r | |
197 | UINTN Signature;\r | |
bcecde14 | 198 | EFI_KEY_DATA KeyData;\r |
199 | EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r | |
200 | LIST_ENTRY NotifyEntry;\r | |
201 | } BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r | |
202 | \r | |
203 | #define QUEUE_MAX_COUNT 32\r | |
204 | typedef struct {\r | |
205 | UINTN Front;\r | |
206 | UINTN Rear;\r | |
207 | EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];\r | |
208 | } SIMPLE_QUEUE;\r | |
209 | \r | |
210 | typedef struct {\r | |
211 | UINTN Signature;\r | |
212 | EFI_HANDLE Handle;\r | |
213 | EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;\r | |
214 | EFI_ISA_IO_PROTOCOL *IsaIo;\r | |
215 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;\r | |
216 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;\r | |
217 | UINT16 DataRegisterAddress;\r | |
218 | UINT16 StatusRegisterAddress;\r | |
219 | UINT16 CommandRegisterAddress;\r | |
220 | BOOLEAN ExtendedKeyboard;\r | |
bcecde14 | 221 | \r |
222 | //\r | |
223 | // Buffer storing EFI_KEY_DATA\r | |
224 | //\r | |
225 | SIMPLE_QUEUE Queue;\r | |
1f20b298 | 226 | SIMPLE_QUEUE QueueForNotify;\r |
bcecde14 | 227 | \r |
228 | //\r | |
229 | // Notification Function List\r | |
230 | //\r | |
231 | LIST_ENTRY NotifyList;\r | |
1f20b298 | 232 | EFI_EVENT KeyNotifyProcessEvent;\r |
bcecde14 | 233 | EFI_EVENT TimerEvent;\r |
234 | \r | |
235 | } BIOS_KEYBOARD_DEV;\r | |
236 | \r | |
237 | #define BIOS_KEYBOARD_DEV_FROM_THIS(a) CR (a, BIOS_KEYBOARD_DEV, SimpleTextIn, BIOS_KEYBOARD_DEV_SIGNATURE)\r | |
238 | #define TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS(a) \\r | |
239 | CR (a, \\r | |
240 | BIOS_KEYBOARD_DEV, \\r | |
241 | SimpleTextInputEx, \\r | |
242 | BIOS_KEYBOARD_DEV_SIGNATURE \\r | |
243 | )\r | |
244 | \r | |
245 | //\r | |
246 | // Global Variables\r | |
247 | //\r | |
248 | extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;\r | |
249 | \r | |
250 | //\r | |
251 | // Driver Binding Protocol functions\r | |
252 | //\r | |
253 | \r | |
254 | /**\r | |
255 | Check whether the driver supports this device.\r | |
256 | \r | |
257 | @param This The Udriver binding protocol.\r | |
258 | @param Controller The controller handle to check.\r | |
259 | @param RemainingDevicePath The remaining device path.\r | |
260 | \r | |
261 | @retval EFI_SUCCESS The driver supports this controller.\r | |
262 | @retval other This device isn't supported.\r | |
263 | \r | |
264 | **/\r | |
265 | EFI_STATUS\r | |
266 | EFIAPI\r | |
267 | BiosKeyboardDriverBindingSupported (\r | |
268 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
269 | IN EFI_HANDLE Controller,\r | |
270 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
271 | );\r | |
272 | \r | |
273 | /**\r | |
274 | Starts the device with this driver.\r | |
275 | \r | |
276 | @param This The driver binding instance.\r | |
277 | @param Controller Handle of device to bind driver to.\r | |
278 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
279 | device to start.\r | |
280 | \r | |
281 | @retval EFI_SUCCESS The controller is controlled by the driver.\r | |
282 | @retval Other This controller cannot be started.\r | |
283 | \r | |
284 | **/\r | |
285 | EFI_STATUS\r | |
286 | EFIAPI\r | |
287 | BiosKeyboardDriverBindingStart (\r | |
288 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
289 | IN EFI_HANDLE Controller,\r | |
290 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
291 | );\r | |
292 | \r | |
293 | /**\r | |
294 | Stop the device handled by this driver.\r | |
295 | \r | |
296 | @param This The driver binding protocol.\r | |
297 | @param Controller The controller to release.\r | |
298 | @param NumberOfChildren The number of handles in ChildHandleBuffer.\r | |
299 | @param ChildHandleBuffer The array of child handle.\r | |
300 | \r | |
301 | @retval EFI_SUCCESS The device was stopped.\r | |
302 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
303 | @retval Others Fail to uninstall protocols attached on the device.\r | |
304 | \r | |
305 | **/\r | |
306 | EFI_STATUS\r | |
307 | EFIAPI\r | |
308 | BiosKeyboardDriverBindingStop (\r | |
309 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
310 | IN EFI_HANDLE Controller,\r | |
311 | IN UINTN NumberOfChildren,\r | |
312 | IN EFI_HANDLE *ChildHandleBuffer\r | |
313 | );\r | |
314 | \r | |
315 | /**\r | |
316 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
317 | \r | |
318 | This function retrieves the user readable name of a driver in the form of a\r | |
319 | Unicode string. If the driver specified by This has a user readable name in\r | |
320 | the language specified by Language, then a pointer to the driver name is\r | |
321 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
322 | by This does not support the language specified by Language,\r | |
323 | then EFI_UNSUPPORTED is returned.\r | |
324 | \r | |
325 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
326 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
327 | \r | |
328 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
329 | array indicating the language. This is the\r | |
330 | language of the driver name that the caller is\r | |
331 | requesting, and it must match one of the\r | |
332 | languages specified in SupportedLanguages. The\r | |
333 | number of languages supported by a driver is up\r | |
334 | to the driver writer. Language is specified\r | |
335 | in RFC 4646 or ISO 639-2 language code format.\r | |
336 | \r | |
337 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
338 | This Unicode string is the name of the\r | |
339 | driver specified by This in the language\r | |
340 | specified by Language.\r | |
341 | \r | |
342 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
343 | This and the language specified by Language was\r | |
344 | returned in DriverName.\r | |
345 | \r | |
346 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
347 | \r | |
348 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
349 | \r | |
350 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
351 | the language specified by Language.\r | |
352 | \r | |
353 | **/\r | |
354 | EFI_STATUS\r | |
355 | EFIAPI\r | |
356 | BiosKeyboardComponentNameGetDriverName (\r | |
357 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
358 | IN CHAR8 *Language,\r | |
359 | OUT CHAR16 **DriverName\r | |
360 | );\r | |
361 | \r | |
362 | \r | |
363 | /**\r | |
364 | Retrieves a Unicode string that is the user readable name of the controller\r | |
365 | that is being managed by a driver.\r | |
366 | \r | |
367 | This function retrieves the user readable name of the controller specified by\r | |
368 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
369 | driver specified by This has a user readable name in the language specified by\r | |
370 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
371 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
372 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
373 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
374 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
375 | \r | |
376 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
377 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
378 | \r | |
379 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
380 | specified by This is managing. This handle\r | |
381 | specifies the controller whose name is to be\r | |
382 | returned.\r | |
383 | \r | |
384 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
385 | the name of. This is an optional parameter that\r | |
386 | may be NULL. It will be NULL for device\r | |
387 | drivers. It will also be NULL for a bus drivers\r | |
388 | that wish to retrieve the name of the bus\r | |
389 | controller. It will not be NULL for a bus\r | |
390 | driver that wishes to retrieve the name of a\r | |
391 | child controller.\r | |
392 | \r | |
393 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
394 | array indicating the language. This is the\r | |
395 | language of the driver name that the caller is\r | |
396 | requesting, and it must match one of the\r | |
397 | languages specified in SupportedLanguages. The\r | |
398 | number of languages supported by a driver is up\r | |
399 | to the driver writer. Language is specified in\r | |
400 | RFC 4646 or ISO 639-2 language code format.\r | |
401 | \r | |
402 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
403 | This Unicode string is the name of the\r | |
404 | controller specified by ControllerHandle and\r | |
405 | ChildHandle in the language specified by\r | |
406 | Language from the point of view of the driver\r | |
407 | specified by This.\r | |
408 | \r | |
409 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
410 | the language specified by Language for the\r | |
411 | driver specified by This was returned in\r | |
412 | DriverName.\r | |
413 | \r | |
0c9f676d | 414 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
bcecde14 | 415 | \r |
416 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
417 | EFI_HANDLE.\r | |
418 | \r | |
419 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
420 | \r | |
421 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
422 | \r | |
423 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
424 | managing the controller specified by\r | |
425 | ControllerHandle and ChildHandle.\r | |
426 | \r | |
427 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
428 | the language specified by Language.\r | |
429 | \r | |
430 | **/\r | |
431 | EFI_STATUS\r | |
432 | EFIAPI\r | |
433 | BiosKeyboardComponentNameGetControllerName (\r | |
434 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
435 | IN EFI_HANDLE ControllerHandle,\r | |
436 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
437 | IN CHAR8 *Language,\r | |
438 | OUT CHAR16 **ControllerName\r | |
439 | );\r | |
440 | \r | |
441 | \r | |
442 | //\r | |
443 | // Simple Text Input Protocol functions\r | |
444 | //\r | |
445 | /**\r | |
446 | Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.\r | |
447 | \r | |
448 | @param This Pointer of simple text Protocol.\r | |
449 | @param ExtendedVerification Whether perform the extra validation of keyboard. True: perform; FALSE: skip.\r | |
450 | \r | |
451 | @retval EFI_SUCCESS The command byte is written successfully.\r | |
70d3fe9d | 452 | @retval EFI_DEVICE_ERROR Errors occurred during resetting keyboard.\r |
bcecde14 | 453 | \r |
454 | **/\r | |
455 | EFI_STATUS\r | |
456 | EFIAPI\r | |
457 | BiosKeyboardReset (\r | |
458 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
459 | IN BOOLEAN ExtendedVerification\r | |
460 | );\r | |
461 | \r | |
462 | /**\r | |
463 | Read out the scan code of the key that has just been stroked.\r | |
464 | \r | |
465 | @param This Pointer of simple text Protocol.\r | |
466 | @param Key Pointer for store the key that read out.\r | |
467 | \r | |
468 | @retval EFI_SUCCESS The key is read out successfully.\r | |
469 | @retval other The key reading failed.\r | |
470 | \r | |
471 | **/\r | |
472 | EFI_STATUS\r | |
473 | EFIAPI\r | |
474 | BiosKeyboardReadKeyStroke (\r | |
475 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
476 | OUT EFI_INPUT_KEY *Key\r | |
477 | );\r | |
478 | \r | |
479 | //\r | |
480 | // Private worker functions\r | |
481 | //\r | |
482 | /**\r | |
483 | Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r | |
484 | \r | |
485 | @param Event The event that be siganlled when any key has been stroked.\r | |
486 | @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.\r | |
487 | \r | |
488 | **/\r | |
489 | VOID\r | |
490 | EFIAPI\r | |
491 | BiosKeyboardWaitForKey (\r | |
492 | IN EFI_EVENT Event,\r | |
493 | IN VOID *Context\r | |
494 | );\r | |
495 | \r | |
496 | /**\r | |
497 | Check key buffer to get the key stroke status.\r | |
498 | \r | |
499 | @param This Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.\r | |
500 | \r | |
501 | @retval EFI_SUCCESS A key is being pressed now.\r | |
502 | @retval Other No key is now pressed.\r | |
503 | \r | |
504 | **/\r | |
505 | EFI_STATUS\r | |
506 | EFIAPI\r | |
507 | BiosKeyboardCheckForKey (\r | |
508 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r | |
509 | );\r | |
510 | \r | |
511 | /**\r | |
512 | Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.\r | |
513 | \r | |
514 | @param KeyChar Unicode of key.\r | |
515 | @param ScanCode Scan code of key.\r | |
516 | \r | |
517 | @return The value of EFI Scancode for the key. \r | |
518 | @retval SCAN_NULL No corresponding value in the EFI convert table is found for the key.\r | |
519 | \r | |
520 | **/\r | |
521 | UINT16\r | |
522 | ConvertToEFIScanCode (\r | |
523 | IN CHAR16 KeyChar,\r | |
524 | IN UINT16 ScanCode\r | |
525 | );\r | |
526 | \r | |
527 | /**\r | |
528 | Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r | |
529 | If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r | |
530 | should not be in system. \r | |
531 | \r | |
532 | @param BiosKeyboardPrivate Keyboard Private Data Struture\r | |
533 | \r | |
534 | @retval TRUE Keyboard in System.\r | |
535 | @retval FALSE Keyboard not in System.\r | |
536 | \r | |
537 | **/\r | |
538 | BOOLEAN\r | |
539 | CheckKeyboardConnect (\r | |
540 | IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate\r | |
541 | );\r | |
542 | \r | |
543 | /**\r | |
544 | Timer event handler: read a series of key stroke from 8042\r | |
545 | and put them into memory key buffer. \r | |
546 | It is registered as running under TPL_NOTIFY\r | |
547 | \r | |
548 | @param Event The timer event\r | |
549 | @param Context A BIOS_KEYBOARD_DEV pointer\r | |
550 | \r | |
551 | **/\r | |
552 | VOID\r | |
553 | EFIAPI\r | |
554 | BiosKeyboardTimerHandler (\r | |
555 | IN EFI_EVENT Event,\r | |
556 | IN VOID *Context\r | |
557 | );\r | |
558 | \r | |
1f20b298 SZ |
559 | /**\r |
560 | Process key notify.\r | |
561 | \r | |
562 | @param Event Indicates the event that invoke this function.\r | |
563 | @param Context Indicates the calling context.\r | |
564 | **/\r | |
565 | VOID\r | |
566 | EFIAPI\r | |
567 | KeyNotifyProcessHandler (\r | |
568 | IN EFI_EVENT Event,\r | |
569 | IN VOID *Context\r | |
570 | );\r | |
571 | \r | |
bcecde14 | 572 | /**\r |
573 | Reset the input device and optionaly run diagnostics\r | |
574 | \r | |
575 | @param This Protocol instance pointer.\r | |
576 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
577 | \r | |
578 | @retval EFI_SUCCESS The device was reset.\r | |
579 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could \r | |
580 | not be reset.\r | |
581 | \r | |
582 | **/\r | |
583 | EFI_STATUS\r | |
584 | EFIAPI\r | |
585 | BiosKeyboardResetEx (\r | |
586 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
587 | IN BOOLEAN ExtendedVerification\r | |
588 | );\r | |
589 | \r | |
590 | /**\r | |
591 | Reads the next keystroke from the input device. The WaitForKey Event can \r | |
592 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
593 | \r | |
594 | @param This Protocol instance pointer.\r | |
595 | @param KeyData A pointer to a buffer that is filled in with the keystroke \r | |
596 | state data for the key that was pressed.\r | |
597 | \r | |
598 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
599 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
600 | @retval EFI_DEVICE_ERROR The keystroke information was not returned due to \r | |
601 | hardware errors.\r | |
602 | @retval EFI_INVALID_PARAMETER KeyData is NULL. \r | |
603 | \r | |
604 | **/\r | |
605 | EFI_STATUS\r | |
606 | EFIAPI\r | |
607 | BiosKeyboardReadKeyStrokeEx (\r | |
608 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
609 | OUT EFI_KEY_DATA *KeyData\r | |
610 | );\r | |
611 | \r | |
612 | /**\r | |
613 | Set certain state for the input device.\r | |
614 | \r | |
615 | @param This Protocol instance pointer.\r | |
616 | @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the \r | |
617 | state for the input device.\r | |
618 | \r | |
619 | @retval EFI_SUCCESS The device state was set successfully.\r | |
620 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and could \r | |
621 | not have the setting adjusted.\r | |
622 | @retval EFI_UNSUPPORTED The device does not have the ability to set its state.\r | |
623 | @retval EFI_INVALID_PARAMETER KeyToggleState is NULL. \r | |
624 | \r | |
625 | **/ \r | |
626 | EFI_STATUS\r | |
627 | EFIAPI\r | |
628 | BiosKeyboardSetState (\r | |
629 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
630 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r | |
631 | );\r | |
632 | \r | |
633 | /**\r | |
634 | Register a notification function for a particular keystroke for the input device.\r | |
635 | \r | |
636 | @param This Protocol instance pointer.\r | |
637 | @param KeyData A pointer to a buffer that is filled in with the keystroke \r | |
cc9a430c DB |
638 | information data for the key that was pressed. If KeyData.Key,\r |
639 | KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r | |
640 | are 0, then any incomplete keystroke will trigger a notification of\r | |
641 | the KeyNotificationFunction.\r | |
bcecde14 | 642 | @param KeyNotificationFunction Points to the function to be called when the key \r |
cc9a430c DB |
643 | sequence is typed specified by KeyData. This notification function\r |
644 | should be called at <=TPL_CALLBACK.\r | |
645 | @param NotifyHandle Points to the unique handle assigned to the registered notification.\r | |
bcecde14 | 646 | \r |
647 | \r | |
648 | @retval EFI_SUCCESS The notification function was registered successfully.\r | |
649 | @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.\r | |
650 | @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.\r | |
cc9a430c DB |
651 | \r |
652 | **/\r | |
bcecde14 | 653 | EFI_STATUS\r |
654 | EFIAPI\r | |
655 | BiosKeyboardRegisterKeyNotify (\r | |
656 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
657 | IN EFI_KEY_DATA *KeyData,\r | |
658 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r | |
402e4a9d | 659 | OUT VOID **NotifyHandle\r |
bcecde14 | 660 | );\r |
661 | \r | |
662 | /**\r | |
663 | Remove a registered notification function from a particular keystroke.\r | |
664 | \r | |
665 | @param This Protocol instance pointer. \r | |
666 | @param NotificationHandle The handle of the notification function being unregistered.\r | |
667 | \r | |
668 | @retval EFI_SUCCESS The notification function was unregistered successfully.\r | |
669 | @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r | |
670 | \r | |
671 | **/ \r | |
672 | EFI_STATUS\r | |
673 | EFIAPI\r | |
674 | BiosKeyboardUnregisterKeyNotify (\r | |
675 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
402e4a9d | 676 | IN VOID *NotificationHandle\r |
bcecde14 | 677 | );\r |
678 | \r | |
679 | /**\r | |
680 | Wait for a specific value to be presented in\r | |
681 | Data register of Keyboard Controller by keyboard and then read it,\r | |
682 | used in keyboard commands ack\r | |
683 | \r | |
684 | @param BiosKeyboardPrivate Keyboard instance pointer.\r | |
685 | @param Value The value to be waited for\r | |
686 | @param WaitForValueTimeOut The limit of microseconds for timeout\r | |
687 | \r | |
688 | @retval EFI_SUCCESS The command byte is written successfully.\r | |
689 | @retval EFI_TIMEOUT Timeout occurred during writing.\r | |
690 | \r | |
691 | **/\r | |
692 | EFI_STATUS\r | |
693 | KeyboardWaitForValue (\r | |
694 | IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,\r | |
695 | IN UINT8 Value,\r | |
696 | IN UINTN WaitForValueTimeOut\r | |
697 | );\r | |
698 | \r | |
699 | /**\r | |
700 | Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.\r | |
701 | \r | |
702 | @param BiosKeyboardPrivate Keyboard instance pointer.\r | |
703 | @param Data Data byte to write.\r | |
704 | \r | |
705 | @retval EFI_SUCCESS The data byte is written successfully.\r | |
706 | @retval EFI_TIMEOUT Timeout occurred during writing.\r | |
707 | \r | |
708 | **/\r | |
709 | EFI_STATUS\r | |
710 | KeyboardWrite (\r | |
711 | IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,\r | |
712 | IN UINT8 Data\r | |
713 | );\r | |
714 | \r | |
715 | /**\r | |
716 | Free keyboard notify list.\r | |
717 | \r | |
718 | @param ListHead The list head\r | |
719 | \r | |
720 | @retval EFI_SUCCESS Free the notify list successfully\r | |
721 | @retval EFI_INVALID_PARAMETER ListHead is invalid.\r | |
722 | \r | |
723 | **/\r | |
724 | EFI_STATUS\r | |
725 | BiosKeyboardFreeNotifyList (\r | |
726 | IN OUT LIST_ENTRY *ListHead\r | |
727 | ); \r | |
728 | \r | |
729 | /**\r | |
730 | Check if key is registered.\r | |
731 | \r | |
732 | @param RegsiteredData A pointer to a buffer that is filled in with the keystroke \r | |
733 | state data for the key that was registered.\r | |
734 | @param InputData A pointer to a buffer that is filled in with the keystroke \r | |
735 | state data for the key that was pressed.\r | |
736 | \r | |
737 | @retval TRUE Key be pressed matches a registered key.\r | |
738 | @retval FLASE Match failed. \r | |
739 | \r | |
740 | **/\r | |
741 | BOOLEAN\r | |
742 | IsKeyRegistered (\r | |
743 | IN EFI_KEY_DATA *RegsiteredData,\r | |
744 | IN EFI_KEY_DATA *InputData\r | |
745 | );\r | |
746 | \r | |
747 | /**\r | |
748 | Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r | |
749 | \r | |
750 | @param Event The event that be siganlled when any key has been stroked.\r | |
751 | @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.\r | |
752 | \r | |
753 | **/\r | |
754 | VOID\r | |
755 | EFIAPI\r | |
756 | BiosKeyboardWaitForKeyEx (\r | |
757 | IN EFI_EVENT Event,\r | |
758 | IN VOID *Context\r | |
759 | );\r | |
760 | \r | |
761 | #endif\r | |
762 | \r |