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