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