]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
IntelFrameworkModule/Ps2Kb: ReadKeyStrokeEx always return key state
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / Ps2Keyboard.h
CommitLineData
f713c4fe 1/** @file\r
f3d1e940 2 PS/2 keyboard driver header file\r
05fbd06d 3\r
896ae6fc 4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
180a5a35 5This program and the accompanying materials\r
df0dcb5e 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
13**/\r
14\r
f713c4fe 15#ifndef _PS2KEYBOARD_H_\r
16#define _PS2KEYBOARD_H_\r
05fbd06d 17\r
265dd403 18#include <Uefi.h>\r
752f2e26 19\r
20#include <Protocol/SimpleTextIn.h>\r
f3d1e940 21#include <Protocol/SimpleTextInEx.h>\r
752f2e26 22#include <Protocol/IsaIo.h>\r
23#include <Protocol/DevicePath.h>\r
24#include <Protocol/Ps2Policy.h>\r
25\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/UefiLib.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/ReportStatusCodeLib.h>\r
30#include <Library/DebugLib.h>\r
31#include <Library/UefiRuntimeServicesTableLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
f3d1e940 33#include <Library/BaseLib.h>\r
34#include <Library/BaseMemoryLib.h>\r
b6763e03 35#include <Library/TimerLib.h>\r
f6c014fb 36#include <Library/PcdLib.h>\r
05fbd06d 37\r
9f6531d1 38//\r
39// Global Variables\r
40//\r
41extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver;\r
42extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName;\r
43extern EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2;\r
44\r
05fbd06d 45//\r
46// Driver Private Data\r
47//\r
c220787b 48#define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32 ('k', 'k', 'e', 'y')\r
f02bd376 49#define KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n')\r
f3d1e940 50\r
51typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
c220787b 52 UINTN Signature;\r
c220787b
RN
53 EFI_KEY_DATA KeyData;\r
54 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r
55 LIST_ENTRY NotifyEntry;\r
f3d1e940 56} KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
57\r
c220787b
RN
58#define KEYBOARD_SCAN_CODE_MAX_COUNT 32\r
59typedef struct {\r
60 UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];\r
61 UINTN Head;\r
62 UINTN Tail;\r
63} SCAN_CODE_QUEUE;\r
64\r
65#define KEYBOARD_EFI_KEY_MAX_COUNT 256\r
66typedef struct {\r
67 EFI_KEY_DATA Buffer[KEYBOARD_EFI_KEY_MAX_COUNT];\r
68 UINTN Head;\r
69 UINTN Tail;\r
70} EFI_KEY_QUEUE;\r
05fbd06d 71\r
72typedef struct {\r
73 UINTN Signature;\r
74\r
75 EFI_HANDLE Handle;\r
76 EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;\r
f3d1e940 77 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx;\r
05fbd06d 78 EFI_ISA_IO_PROTOCOL *IsaIo;\r
79\r
80 EFI_EVENT TimerEvent;\r
81\r
82 UINT32 DataRegisterAddress;\r
83 UINT32 StatusRegisterAddress;\r
84 UINT32 CommandRegisterAddress;\r
85\r
0d0bbc9f
RN
86 BOOLEAN LeftCtrl;\r
87 BOOLEAN RightCtrl;\r
88 BOOLEAN LeftAlt;\r
89 BOOLEAN RightAlt;\r
f3d1e940 90 BOOLEAN LeftShift;\r
5829afe3 91 BOOLEAN RightShift;\r
f3d1e940 92 BOOLEAN LeftLogo;\r
93 BOOLEAN RightLogo;\r
94 BOOLEAN Menu;\r
95 BOOLEAN SysReq;\r
05fbd06d 96\r
05fbd06d 97 BOOLEAN CapsLock;\r
98 BOOLEAN NumLock;\r
99 BOOLEAN ScrollLock;\r
100\r
5829afe3 101 BOOLEAN IsSupportPartialKey;\r
05fbd06d 102 //\r
c220787b 103 // Queue storing key scancodes\r
05fbd06d 104 //\r
c220787b
RN
105 SCAN_CODE_QUEUE ScancodeQueue;\r
106 EFI_KEY_QUEUE EfiKeyQueue;\r
7863d11c 107 EFI_KEY_QUEUE EfiKeyQueueForNotify;\r
05fbd06d 108\r
109 //\r
110 // Error state\r
111 //\r
112 BOOLEAN KeyboardErr;\r
113\r
114 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
115\r
116 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
f3d1e940 117 //\r
118 // Notification Function List\r
119 //\r
120 LIST_ENTRY NotifyList;\r
7863d11c 121 EFI_EVENT KeyNotifyProcessEvent;\r
05fbd06d 122} KEYBOARD_CONSOLE_IN_DEV;\r
123\r
124#define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)\r
f3d1e940 125#define TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) \\r
126 CR (a, \\r
127 KEYBOARD_CONSOLE_IN_DEV, \\r
128 ConInEx, \\r
129 KEYBOARD_CONSOLE_IN_DEV_SIGNATURE \\r
130 )\r
05fbd06d 131\r
132#define TABLE_END 0x0\r
133\r
05fbd06d 134//\r
135// Driver entry point\r
136//\r
bcd70414 137/**\r
138 The user Entry Point for module Ps2Keyboard. The user code starts with this function.\r
139\r
5829afe3 140 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
bcd70414 141 @param[in] SystemTable A pointer to the EFI System Table.\r
5829afe3 142\r
bcd70414 143 @retval EFI_SUCCESS The entry point is executed successfully.\r
144 @retval other Some error occurs when executing this entry point.\r
145\r
146**/\r
05fbd06d 147EFI_STATUS\r
f3d1e940 148EFIAPI\r
05fbd06d 149InstallPs2KeyboardDriver (\r
150 IN EFI_HANDLE ImageHandle,\r
151 IN EFI_SYSTEM_TABLE *SystemTable\r
ed66e1bc 152 );\r
05fbd06d 153\r
154#define KEYBOARD_8042_DATA_REGISTER 0x60\r
155#define KEYBOARD_8042_STATUS_REGISTER 0x64\r
156#define KEYBOARD_8042_COMMAND_REGISTER 0x64\r
157\r
158#define KEYBOARD_KBEN 0xF4\r
159#define KEYBOARD_CMDECHO_ACK 0xFA\r
160\r
05f89b17 161#define KEYBOARD_MAX_TRY 256 // 256\r
05fbd06d 162#define KEYBOARD_TIMEOUT 65536 // 0.07s\r
163#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s\r
164#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s\r
165#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s\r
0d0bbc9f 166#define SCANCODE_EXTENDED0 0xE0\r
05fbd06d 167#define SCANCODE_EXTENDED1 0xE1\r
168#define SCANCODE_CTRL_MAKE 0x1D\r
169#define SCANCODE_CTRL_BREAK 0x9D\r
170#define SCANCODE_ALT_MAKE 0x38\r
171#define SCANCODE_ALT_BREAK 0xB8\r
172#define SCANCODE_LEFT_SHIFT_MAKE 0x2A\r
173#define SCANCODE_LEFT_SHIFT_BREAK 0xAA\r
174#define SCANCODE_RIGHT_SHIFT_MAKE 0x36\r
175#define SCANCODE_RIGHT_SHIFT_BREAK 0xB6\r
176#define SCANCODE_CAPS_LOCK_MAKE 0x3A\r
177#define SCANCODE_NUM_LOCK_MAKE 0x45\r
178#define SCANCODE_SCROLL_LOCK_MAKE 0x46\r
c220787b 179#define SCANCODE_DELETE_MAKE 0x53\r
f3d1e940 180#define SCANCODE_LEFT_LOGO_MAKE 0x5B //GUI key defined in Keyboard scan code\r
181#define SCANCODE_LEFT_LOGO_BREAK 0xDB\r
182#define SCANCODE_RIGHT_LOGO_MAKE 0x5C\r
183#define SCANCODE_RIGHT_LOGO_BREAK 0xDC\r
5829afe3 184#define SCANCODE_MENU_MAKE 0x5D //APPS key defined in Keyboard scan code\r
f3d1e940 185#define SCANCODE_MENU_BREAK 0xDD\r
186#define SCANCODE_SYS_REQ_MAKE 0x37\r
0d0bbc9f
RN
187#define SCANCODE_SYS_REQ_BREAK 0xB7\r
188#define SCANCODE_SYS_REQ_MAKE_WITH_ALT 0x54\r
189#define SCANCODE_SYS_REQ_BREAK_WITH_ALT 0xD4\r
190\r
f3d1e940 191#define SCANCODE_MAX_MAKE 0x60\r
05fbd06d 192\r
e8123186 193\r
b6763e03 194#define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA BIT0 ///< 0 - Output register has no data; 1 - Output register has data\r
195#define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA BIT1 ///< 0 - Input register has no data; 1 - Input register has data\r
196#define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG BIT2 ///< Set to 0 after power on reset\r
197#define KEYBOARD_STATUS_REGISTER_INPUT_DATA_TYPE BIT3 ///< 0 - Data in input register is data; 1 - Data in input register is command\r
198#define KEYBOARD_STATUS_REGISTER_ENABLE_FLAG BIT4 ///< 0 - Keyboard is disable; 1 - Keyboard is enable\r
199#define KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT BIT5 ///< 0 - Transmit is complete without timeout; 1 - Transmit is timeout without complete\r
200#define KEYBOARD_STATUS_REGISTER_RECEIVE_TIMEOUT BIT6 ///< 0 - Receive is complete without timeout; 1 - Receive is timeout without complete\r
201#define KEYBOARD_STATUS_REGISTER_PARITY BIT7 ///< 0 - Odd parity; 1 - Even parity\r
202\r
203#define KEYBOARD_8042_COMMAND_READ 0x20\r
204#define KEYBOARD_8042_COMMAND_WRITE 0x60\r
205#define KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE 0xA7\r
206#define KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE 0xA8\r
207#define KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST 0xAA\r
208#define KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST 0xAB\r
209#define KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE 0xAD\r
210\r
211#define KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA 0xF4\r
212#define KEYBOARD_8048_COMMAND_RESET 0xFF\r
213#define KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET 0xF0\r
214\r
215#define KEYBOARD_8048_RETURN_8042_BAT_SUCCESS 0xAA\r
216#define KEYBOARD_8048_RETURN_8042_BAT_ERROR 0xFC\r
217#define KEYBOARD_8048_RETURN_8042_ACK 0xFA\r
218\r
219\r
007c18f5 220//\r
221// Keyboard Controller Status\r
222//\r
223#define KBC_PARE 0x80 // Parity Error\r
224#define KBC_TIM 0x40 // General Time Out\r
225\r
05fbd06d 226//\r
227// Other functions that are used among .c files\r
228//\r
bcd70414 229/**\r
230 Show keyboard status lights according to\r
231 indicators in ConsoleIn.\r
232\r
233 @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
5829afe3 234\r
bcd70414 235 @return status\r
f3d1e940 236\r
bcd70414 237**/\r
f3d1e940 238EFI_STATUS\r
239UpdateStatusLights (\r
240 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
ed66e1bc 241 );\r
f3d1e940 242\r
bcd70414 243/**\r
f713c4fe 244 write key to keyboard.\r
f3d1e940 245\r
bcd70414 246 @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
247 @param Data value wanted to be written\r
f3d1e940 248\r
bcd70414 249 @retval EFI_TIMEOUT - GC_TODO: Add description for return value\r
250 @retval EFI_SUCCESS - GC_TODO: Add description for return value\r
f3d1e940 251\r
bcd70414 252**/\r
05fbd06d 253EFI_STATUS\r
254KeyboardRead (\r
255 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
256 OUT UINT8 *Data\r
ed66e1bc 257 );\r
05fbd06d 258\r
bcd70414 259/**\r
c220787b 260 Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.\r
05fbd06d 261\r
c220787b 262 The function is always called in TPL_NOTIFY.\r
05fbd06d 263\r
c220787b 264 @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer\r
05fbd06d 265\r
bcd70414 266**/\r
c220787b 267VOID\r
05fbd06d 268KeyGetchar (\r
269 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
ed66e1bc 270 );\r
05fbd06d 271\r
7863d11c
SZ
272/**\r
273 Process key notify.\r
274\r
275 @param Event Indicates the event that invoke this function.\r
276 @param Context Indicates the calling context.\r
277**/\r
278VOID\r
279EFIAPI\r
280KeyNotifyProcessHandler (\r
281 IN EFI_EVENT Event,\r
282 IN VOID *Context\r
283 );\r
284\r
bcd70414 285/**\r
f713c4fe 286 Perform 8042 controller and keyboard Initialization.\r
bcd70414 287 If ExtendedVerification is TRUE, do additional test for\r
288 the keyboard interface\r
05fbd06d 289\r
bcd70414 290 @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer\r
291 @param ExtendedVerification - indicates a thorough initialization\r
05fbd06d 292\r
bcd70414 293 @retval EFI_DEVICE_ERROR Fail to init keyboard\r
294 @retval EFI_SUCCESS Success to init keyboard\r
295**/\r
05fbd06d 296EFI_STATUS\r
297InitKeyboard (\r
298 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
299 IN BOOLEAN ExtendedVerification\r
ed66e1bc 300 );\r
05fbd06d 301\r
bcd70414 302/**\r
f713c4fe 303 Disable the keyboard interface of the 8042 controller.\r
05fbd06d 304\r
bcd70414 305 @param ConsoleIn - the device instance\r
05fbd06d 306\r
bcd70414 307 @return status of issuing disable command\r
05fbd06d 308\r
bcd70414 309**/\r
05fbd06d 310EFI_STATUS\r
311DisableKeyboard (\r
312 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
ed66e1bc 313 );\r
05fbd06d 314\r
bcd70414 315/**\r
316 Timer event handler: read a series of scancodes from 8042\r
317 and put them into memory scancode buffer.\r
318 it read as much scancodes to either fill\r
319 the memory buffer or empty the keyboard buffer.\r
320 It is registered as running under TPL_NOTIFY\r
05fbd06d 321\r
bcd70414 322 @param Event - The timer event\r
323 @param Context - A KEYBOARD_CONSOLE_IN_DEV pointer\r
05fbd06d 324\r
bcd70414 325**/\r
05fbd06d 326VOID\r
327EFIAPI\r
328KeyboardTimerHandler (\r
329 IN EFI_EVENT Event,\r
330 IN VOID *Context\r
ed66e1bc 331 );\r
05fbd06d 332\r
bcd70414 333/**\r
334 logic reset keyboard\r
335 Implement SIMPLE_TEXT_IN.Reset()\r
336 Perform 8042 controller and keyboard initialization\r
05fbd06d 337\r
bcd70414 338 @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
5829afe3 339 @param ExtendedVerification Indicate that the driver may perform a more\r
340 exhaustive verification operation of the device during\r
341 reset, now this par is ignored in this driver\r
05fbd06d 342\r
bcd70414 343**/\r
05fbd06d 344EFI_STATUS\r
345EFIAPI\r
346KeyboardEfiReset (\r
347 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
348 IN BOOLEAN ExtendedVerification\r
ed66e1bc 349 );\r
05fbd06d 350\r
bcd70414 351/**\r
352 Implement SIMPLE_TEXT_IN.ReadKeyStroke().\r
353 Retrieve key values for driver user.\r
05fbd06d 354\r
bcd70414 355 @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
5829afe3 356 @param Key The output buffer for key value\r
05fbd06d 357\r
bcd70414 358 @retval EFI_SUCCESS success to read key stroke\r
359**/\r
05fbd06d 360EFI_STATUS\r
361EFIAPI\r
362KeyboardReadKeyStroke (\r
363 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
364 OUT EFI_INPUT_KEY *Key\r
ed66e1bc 365 );\r
05fbd06d 366\r
bcd70414 367/**\r
368 Event notification function for SIMPLE_TEXT_IN.WaitForKey event\r
369 Signal the event if there is key available\r
05fbd06d 370\r
bcd70414 371 @param Event the event object\r
372 @param Context waitting context\r
05fbd06d 373\r
bcd70414 374**/\r
05fbd06d 375VOID\r
376EFIAPI\r
377KeyboardWaitForKey (\r
378 IN EFI_EVENT Event,\r
379 IN VOID *Context\r
ed66e1bc 380 );\r
05fbd06d 381\r
bcd70414 382/**\r
f713c4fe 383 Read status register.\r
05fbd06d 384\r
bcd70414 385 @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
05fbd06d 386\r
bcd70414 387 @return value in status register\r
05fbd06d 388\r
bcd70414 389**/\r
05fbd06d 390UINT8\r
391KeyReadStatusRegister (\r
392 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
ed66e1bc 393 );\r
05fbd06d 394\r
395/**\r
396 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
397 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
398 should not be in system.\r
399\r
f713c4fe 400 @param[in] ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
05fbd06d 401\r
f3d1e940 402 @retval TRUE Keyboard in System.\r
403 @retval FALSE Keyboard not in System.\r
05fbd06d 404**/\r
405BOOLEAN\r
406EFIAPI\r
407CheckKeyboardConnect (\r
408 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
ed66e1bc 409 );\r
f3d1e940 410\r
bcd70414 411/**\r
412 Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
413 Signal the event if there is key available\r
414\r
415 @param Event event object\r
416 @param Context waiting context\r
417\r
418**/\r
f3d1e940 419VOID\r
420EFIAPI\r
421KeyboardWaitForKeyEx (\r
422 IN EFI_EVENT Event,\r
423 IN VOID *Context\r
5829afe3 424 );\r
f3d1e940 425\r
426//\r
427// Simple Text Input Ex protocol function prototypes\r
428//\r
429\r
bcd70414 430/**\r
431 Reset the input device and optionaly run diagnostics\r
432\r
433 @param This - Protocol instance pointer.\r
434 @param ExtendedVerification - Driver may perform diagnostics on reset.\r
435\r
436 @retval EFI_SUCCESS - The device was reset.\r
5829afe3 437 @retval EFI_DEVICE_ERROR - The device is not functioning properly and could\r
bcd70414 438 not be reset.\r
439\r
440**/\r
f3d1e940 441EFI_STATUS\r
442EFIAPI\r
443KeyboardEfiResetEx (\r
444 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
445 IN BOOLEAN ExtendedVerification\r
ed66e1bc 446 );\r
f3d1e940 447\r
bcd70414 448/**\r
5829afe3 449 Reads the next keystroke from the input device. The WaitForKey Event can\r
bcd70414 450 be used to test for existance of a keystroke via WaitForEvent () call.\r
f3d1e940 451\r
f3d1e940 452\r
bcd70414 453 @param This - Protocol instance pointer.\r
5829afe3 454 @param KeyData - A pointer to a buffer that is filled in with the keystroke\r
bcd70414 455 state data for the key that was pressed.\r
f3d1e940 456\r
bcd70414 457 @retval EFI_SUCCESS - The keystroke information was returned.\r
458 @retval EFI_NOT_READY - There was no keystroke data availiable.\r
5829afe3 459 @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to\r
bcd70414 460 hardware errors.\r
5829afe3 461 @retval EFI_INVALID_PARAMETER - KeyData is NULL.\r
f3d1e940 462\r
bcd70414 463**/\r
f3d1e940 464EFI_STATUS\r
465EFIAPI\r
466KeyboardReadKeyStrokeEx (\r
467 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
468 OUT EFI_KEY_DATA *KeyData\r
ed66e1bc 469 );\r
f3d1e940 470\r
bcd70414 471/**\r
472 Set certain state for the input device.\r
f3d1e940 473\r
bcd70414 474 @param This - Protocol instance pointer.\r
5829afe3 475 @param KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
bcd70414 476 state for the input device.\r
f3d1e940 477\r
bcd70414 478 @retval EFI_SUCCESS - The device state was set successfully.\r
5829afe3 479 @retval EFI_DEVICE_ERROR - The device is not functioning correctly and could\r
bcd70414 480 not have the setting adjusted.\r
481 @retval EFI_UNSUPPORTED - The device does not have the ability to set its state.\r
5829afe3 482 @retval EFI_INVALID_PARAMETER - KeyToggleState is NULL.\r
f3d1e940 483\r
bcd70414 484**/\r
f3d1e940 485EFI_STATUS\r
486EFIAPI\r
487KeyboardSetState (\r
488 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
489 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
ed66e1bc 490 );\r
f3d1e940 491\r
bcd70414 492/**\r
493 Register a notification function for a particular keystroke for the input device.\r
494\r
495 @param This - Protocol instance pointer.\r
5829afe3 496 @param KeyData - A pointer to a buffer that is filled in with the keystroke\r
cc9a430c
DB
497 information data for the key that was pressed. If KeyData.Key,\r
498 KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState\r
499 are 0, then any incomplete keystroke will trigger a notification of\r
500 the KeyNotificationFunction.\r
5829afe3 501 @param KeyNotificationFunction - Points to the function to be called when the key\r
cc9a430c
DB
502 sequence is typed specified by KeyData. This notification function\r
503 should be called at <=TPL_CALLBACK.\r
5829afe3 504 @param NotifyHandle - Points to the unique handle assigned to the registered notification.\r
bcd70414 505\r
506 @retval EFI_SUCCESS - The notification function was registered successfully.\r
507 @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.\r
5829afe3 508 @retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.\r
509\r
510**/\r
f3d1e940 511EFI_STATUS\r
512EFIAPI\r
513KeyboardRegisterKeyNotify (\r
514 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
515 IN EFI_KEY_DATA *KeyData,\r
516 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
402e4a9d 517 OUT VOID **NotifyHandle\r
ed66e1bc 518 );\r
f3d1e940 519\r
bcd70414 520/**\r
521 Remove a registered notification function from a particular keystroke.\r
f3d1e940 522\r
5829afe3 523 @param This - Protocol instance pointer.\r
bcd70414 524 @param NotificationHandle - The handle of the notification function being unregistered.\r
f3d1e940 525\r
5829afe3 526\r
bcd70414 527 @retval EFI_SUCCESS - The notification function was unregistered successfully.\r
528 @retval EFI_INVALID_PARAMETER - The NotificationHandle is invalid.\r
5829afe3 529 @retval EFI_NOT_FOUND - Can not find the matching entry in database.\r
530\r
531**/\r
f3d1e940 532EFI_STATUS\r
533EFIAPI\r
534KeyboardUnregisterKeyNotify (\r
535 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
402e4a9d 536 IN VOID *NotificationHandle\r
ed66e1bc 537 );\r
f3d1e940 538\r
c220787b
RN
539/**\r
540 Push one key data to the EFI key buffer.\r
541\r
542 @param Queue Pointer to instance of EFI_KEY_QUEUE.\r
543 @param KeyData The key data to push.\r
544**/\r
545VOID\r
546PushEfikeyBufTail (\r
547 IN EFI_KEY_QUEUE *Queue,\r
548 IN EFI_KEY_DATA *KeyData\r
549 );\r
550\r
551/**\r
552 Judge whether is a registed key\r
553\r
5829afe3 554 @param RegsiteredData A pointer to a buffer that is filled in with the keystroke\r
c220787b 555 state data for the key that was registered.\r
5829afe3 556 @param InputData A pointer to a buffer that is filled in with the keystroke\r
c220787b
RN
557 state data for the key that was pressed.\r
558\r
559 @retval TRUE Key be pressed matches a registered key.\r
5829afe3 560 @retval FLASE Match failed.\r
561\r
c220787b
RN
562**/\r
563BOOLEAN\r
564IsKeyRegistered (\r
565 IN EFI_KEY_DATA *RegsiteredData,\r
566 IN EFI_KEY_DATA *InputData\r
567 );\r
5829afe3 568\r
896ae6fc
RN
569/**\r
570 Initialize the key state.\r
571\r
572 @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance.\r
573 @param KeyState A pointer to receive the key state information.\r
574**/\r
575VOID\r
576InitializeKeyState (\r
577 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
578 OUT EFI_KEY_STATE *KeyState\r
579 );\r
580\r
05fbd06d 581#endif\r