]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.h
CommitLineData
ed838d0c 1/** @file\r
5899f27e 2 Header file for USB Keyboard Driver's Data Structures.\r
a7022cec 3\r
3652f990 4Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
ed838d0c 6\r
ed838d0c 7**/\r
a7022cec 8#ifndef _EFI_USB_KB_H_\r
9#define _EFI_USB_KB_H_\r
ed838d0c 10\r
ed7748fe 11\r
60c93673 12#include <Uefi.h>\r
ed7748fe 13\r
ed838d0c 14#include <Protocol/SimpleTextIn.h>\r
66aa04e4 15#include <Protocol/SimpleTextInEx.h>\r
813acf3a 16#include <Protocol/HiiDatabase.h>\r
ed838d0c 17#include <Protocol/UsbIo.h>\r
18#include <Protocol/DevicePath.h>\r
8d4cd915 19\r
813acf3a 20#include <Guid/HiiKeyBoardLayout.h>\r
c8ad2d7a 21#include <Guid/UsbKeyBoardLayout.h>\r
ed7748fe 22\r
ed838d0c 23#include <Library/DebugLib.h>\r
24#include <Library/ReportStatusCodeLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
26#include <Library/UefiRuntimeServicesTableLib.h>\r
27#include <Library/UefiDriverEntryPoint.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/UefiLib.h>\r
30#include <Library/MemoryAllocationLib.h>\r
31#include <Library/PcdLib.h>\r
dfb74df5 32#include <Library/UefiUsbLib.h>\r
c41c3e55 33#include <Library/HiiLib.h>\r
ed838d0c 34\r
35#include <IndustryStandard/Usb.h>\r
36\r
c1fd2767
RN
37#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s\r
38\r
ed838d0c 39#define MAX_KEY_ALLOWED 32\r
40\r
41#define HZ 1000 * 1000 * 10\r
42#define USBKBD_REPEAT_DELAY ((HZ) / 2)\r
43#define USBKBD_REPEAT_RATE ((HZ) / 50)\r
44\r
45#define CLASS_HID 3\r
46#define SUBCLASS_BOOT 1\r
47#define PROTOCOL_KEYBOARD 1\r
48\r
49#define BOOT_PROTOCOL 0\r
50#define REPORT_PROTOCOL 1\r
51\r
52typedef struct {\r
b4e73a63 53 BOOLEAN Down;\r
54 UINT8 KeyCode;\r
ed838d0c 55} USB_KEY;\r
56\r
57typedef struct {\r
c1fd2767
RN
58 VOID *Buffer[MAX_KEY_ALLOWED + 1];\r
59 UINTN Head;\r
60 UINTN Tail;\r
61 UINTN ItemSize;\r
62} USB_SIMPLE_QUEUE;\r
ed838d0c 63\r
f3f2e05d 64#define USB_KB_DEV_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'd')\r
65#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'x')\r
66aa04e4 66\r
67typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
68 UINTN Signature;\r
66aa04e4 69 EFI_KEY_DATA KeyData;\r
70 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r
71 LIST_ENTRY NotifyEntry;\r
72} KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
813acf3a 73\r
f3f2e05d 74#define USB_NS_KEY_SIGNATURE SIGNATURE_32 ('u', 'n', 's', 'k')\r
813acf3a 75\r
76typedef struct {\r
77 UINTN Signature;\r
78 LIST_ENTRY Link;\r
79\r
80 //\r
81 // The number of EFI_NS_KEY_MODIFIER children definitions\r
82 //\r
83 UINTN KeyCount;\r
84\r
85 //\r
86 // NsKey[0] : Non-spacing key\r
87 // NsKey[1] ~ NsKey[KeyCount] : Physical keys\r
88 //\r
89 EFI_KEY_DESCRIPTOR *NsKey;\r
90} USB_NS_KEY;\r
91\r
92#define USB_NS_KEY_FORM_FROM_LINK(a) CR (a, USB_NS_KEY, Link, USB_NS_KEY_SIGNATURE)\r
93\r
5899f27e 94///\r
95/// Structure to describe USB keyboard device\r
96///\r
ed838d0c 97typedef struct {\r
5899f27e 98 UINTN Signature;\r
c41c3e55 99 EFI_HANDLE ControllerHandle;\r
5899f27e 100 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
101 EFI_EVENT DelayedRecoveryEvent;\r
102 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
66aa04e4 103 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r
5899f27e 104 EFI_USB_IO_PROTOCOL *UsbIo;\r
ed838d0c 105\r
5899f27e 106 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
107 EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r
ed838d0c 108\r
c1fd2767
RN
109 USB_SIMPLE_QUEUE UsbKeyQueue;\r
110 USB_SIMPLE_QUEUE EfiKeyQueue;\r
4ae46dba 111 USB_SIMPLE_QUEUE EfiKeyQueueForNotify;\r
b4e73a63 112 BOOLEAN CtrlOn;\r
113 BOOLEAN AltOn;\r
114 BOOLEAN ShiftOn;\r
115 BOOLEAN NumLockOn;\r
116 BOOLEAN CapsOn;\r
117 BOOLEAN ScrollOn;\r
5899f27e 118 UINT8 LastKeyCodeArray[8];\r
b4e73a63 119 UINT8 CurKeyCode;\r
ed838d0c 120\r
c1fd2767
RN
121 EFI_EVENT TimerEvent;\r
122\r
5899f27e 123 UINT8 RepeatKey;\r
124 EFI_EVENT RepeatTimer;\r
ed838d0c 125\r
5899f27e 126 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
3765794c 127\r
b4e73a63 128 BOOLEAN LeftCtrlOn;\r
129 BOOLEAN LeftAltOn;\r
130 BOOLEAN LeftShiftOn;\r
131 BOOLEAN LeftLogoOn;\r
132 BOOLEAN RightCtrlOn;\r
133 BOOLEAN RightAltOn;\r
134 BOOLEAN RightShiftOn;\r
3765794c 135 BOOLEAN RightLogoOn;\r
b4e73a63 136 BOOLEAN MenuKeyOn;\r
137 BOOLEAN SysReqOn;\r
138 BOOLEAN AltGrOn;\r
3765794c 139\r
140 BOOLEAN IsSupportPartialKey;\r
141\r
142 EFI_KEY_STATE KeyState;\r
66aa04e4 143 //\r
144 // Notification function list\r
145 //\r
5899f27e 146 LIST_ENTRY NotifyList;\r
4ae46dba 147 EFI_EVENT KeyNotifyProcessEvent;\r
813acf3a 148\r
149 //\r
150 // Non-spacing key list\r
151 //\r
5899f27e 152 LIST_ENTRY NsKeyList;\r
153 USB_NS_KEY *CurrentNsKey;\r
154 EFI_KEY_DESCRIPTOR *KeyConvertionTable;\r
155 EFI_EVENT KeyboardLayoutEvent;\r
ed838d0c 156} USB_KB_DEV;\r
157\r
158//\r
159// Global Variables\r
160//\r
62b9bb55 161extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;\r
162extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;\r
163extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;\r
ed838d0c 164\r
ed838d0c 165#define USB_KB_DEV_FROM_THIS(a) \\r
166 CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)\r
66aa04e4 167#define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \\r
168 CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE)\r
169\r
b4e73a63 170//\r
171// According to Universal Serial Bus HID Usage Tables document ver 1.12,\r
172// a Boot Keyboard should support the keycode range from 0x0 to 0x65 and 0xE0 to 0xE7.\r
173// 0xE0 to 0xE7 are for modifier keys, and 0x0 to 0x3 are reserved for typical\r
174// keyboard status or keyboard errors.\r
175// So the number of valid non-modifier USB keycodes is 0x62, and the number of\r
176// valid keycodes is 0x6A.\r
177//\r
178#define NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE 0x62\r
179#define NUMBER_OF_VALID_USB_KEYCODE 0x6A\r
180//\r
181// 0x0 to 0x3 are reserved for typical keyboard status or keyboard errors.\r
182//\r
183#define USBKBD_VALID_KEYCODE(Key) ((UINT8) (Key) > 3)\r
ed838d0c 184\r
185typedef struct {\r
186 UINT8 NumLock : 1;\r
187 UINT8 CapsLock : 1;\r
188 UINT8 ScrollLock : 1;\r
189 UINT8 Resrvd : 5;\r
190} LED_MAP;\r
66aa04e4 191\r
5899f27e 192//\r
193// Functions of Driver Binding Protocol\r
194//\r
195/**\r
196 Check whether USB keyboard driver supports this device.\r
197\r
198 @param This The USB keyboard driver binding protocol.\r
199 @param Controller The controller handle to check.\r
200 @param RemainingDevicePath The remaining device path.\r
201\r
202 @retval EFI_SUCCESS The driver supports this controller.\r
203 @retval other This device isn't supported.\r
204\r
205**/\r
206EFI_STATUS\r
207EFIAPI\r
208USBKeyboardDriverBindingSupported (\r
209 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
210 IN EFI_HANDLE Controller,\r
211 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
212 );\r
213\r
214/**\r
c92e277d 215 Starts the keyboard device with this driver.\r
b4e73a63 216\r
217 This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,\r
218 initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage\r
219 this keyboard device.\r
5899f27e 220\r
221 @param This The USB keyboard driver binding instance.\r
222 @param Controller Handle of device to bind driver to.\r
223 @param RemainingDevicePath Optional parameter use to pick a specific child\r
224 device to start.\r
225\r
226 @retval EFI_SUCCESS The controller is controlled by the usb keyboard driver.\r
227 @retval EFI_UNSUPPORTED No interrupt endpoint can be found.\r
b4e73a63 228 @retval Other This controller cannot be started.\r
5899f27e 229\r
230**/\r
231EFI_STATUS\r
232EFIAPI\r
233USBKeyboardDriverBindingStart (\r
234 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
235 IN EFI_HANDLE Controller,\r
236 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
237 );\r
238\r
239/**\r
b4e73a63 240 Stop the USB keyboard device handled by this driver.\r
5899f27e 241\r
242 @param This The USB keyboard driver binding protocol.\r
243 @param Controller The controller to release.\r
244 @param NumberOfChildren The number of handles in ChildHandleBuffer.\r
245 @param ChildHandleBuffer The array of child handle.\r
246\r
b4e73a63 247 @retval EFI_SUCCESS The device was stopped.\r
5899f27e 248 @retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol\r
249 is not installed on Controller.\r
b4e73a63 250 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
251 @retval Others Fail to uninstall protocols attached on the device.\r
5899f27e 252\r
253**/\r
254EFI_STATUS\r
255EFIAPI\r
256USBKeyboardDriverBindingStop (\r
257 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
258 IN EFI_HANDLE Controller,\r
259 IN UINTN NumberOfChildren,\r
260 IN EFI_HANDLE *ChildHandleBuffer\r
261 );\r
262\r
b4e73a63 263//\r
264// EFI Component Name Functions\r
265//\r
266/**\r
267 Retrieves a Unicode string that is the user readable name of the driver.\r
268\r
269 This function retrieves the user readable name of a driver in the form of a\r
270 Unicode string. If the driver specified by This has a user readable name in\r
271 the language specified by Language, then a pointer to the driver name is\r
272 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
273 by This does not support the language specified by Language,\r
274 then EFI_UNSUPPORTED is returned.\r
275\r
276 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
277 EFI_COMPONENT_NAME_PROTOCOL instance.\r
278 @param Language A pointer to a Null-terminated ASCII string\r
279 array indicating the language. This is the\r
280 language of the driver name that the caller is\r
281 requesting, and it must match one of the\r
282 languages specified in SupportedLanguages. The\r
283 number of languages supported by a driver is up\r
284 to the driver writer. Language is specified\r
0254efc0 285 in RFC 4646 or ISO 639-2 language code format.\r
b4e73a63 286 @param DriverName A pointer to the Unicode string to return.\r
287 This Unicode string is the name of the\r
288 driver specified by This in the language\r
289 specified by Language.\r
290\r
291 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
292 This and the language specified by Language was\r
293 returned in DriverName.\r
294 @retval EFI_INVALID_PARAMETER Language is NULL.\r
295 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
296 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
297 the language specified by Language.\r
298\r
299**/\r
300EFI_STATUS\r
301EFIAPI\r
302UsbKeyboardComponentNameGetDriverName (\r
303 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
304 IN CHAR8 *Language,\r
305 OUT CHAR16 **DriverName\r
306 );\r
307\r
308/**\r
309 Retrieves a Unicode string that is the user readable name of the controller\r
310 that is being managed by a driver.\r
311\r
312 This function retrieves the user readable name of the controller specified by\r
313 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
314 driver specified by This has a user readable name in the language specified by\r
315 Language, then a pointer to the controller name is returned in ControllerName,\r
316 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
317 managing the controller specified by ControllerHandle and ChildHandle,\r
318 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
319 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
320\r
321 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
322 EFI_COMPONENT_NAME_PROTOCOL instance.\r
323 @param ControllerHandle The handle of a controller that the driver\r
324 specified by This is managing. This handle\r
325 specifies the controller whose name is to be\r
326 returned.\r
327 @param ChildHandle The handle of the child controller to retrieve\r
328 the name of. This is an optional parameter that\r
329 may be NULL. It will be NULL for device\r
330 drivers. It will also be NULL for a bus drivers\r
331 that wish to retrieve the name of the bus\r
332 controller. It will not be NULL for a bus\r
333 driver that wishes to retrieve the name of a\r
334 child controller.\r
335 @param Language A pointer to a Null-terminated ASCII string\r
336 array indicating the language. This is the\r
337 language of the driver name that the caller is\r
338 requesting, and it must match one of the\r
339 languages specified in SupportedLanguages. The\r
340 number of languages supported by a driver is up\r
341 to the driver writer. Language is specified in\r
0254efc0 342 RFC 4646 or ISO 639-2 language code format.\r
b4e73a63 343 @param ControllerName A pointer to the Unicode string to return.\r
344 This Unicode string is the name of the\r
345 controller specified by ControllerHandle and\r
346 ChildHandle in the language specified by\r
347 Language from the point of view of the driver\r
348 specified by This.\r
349\r
350 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
351 the language specified by Language for the\r
352 driver specified by This was returned in\r
353 DriverName.\r
354 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
355 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
356 EFI_HANDLE.\r
357 @retval EFI_INVALID_PARAMETER Language is NULL.\r
358 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
359 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
360 managing the controller specified by\r
361 ControllerHandle and ChildHandle.\r
362 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
363 the language specified by Language.\r
364\r
365**/\r
366EFI_STATUS\r
367EFIAPI\r
368UsbKeyboardComponentNameGetControllerName (\r
369 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
370 IN EFI_HANDLE ControllerHandle,\r
371 IN EFI_HANDLE ChildHandle OPTIONAL,\r
372 IN CHAR8 *Language,\r
373 OUT CHAR16 **ControllerName\r
374 );\r
375\r
5899f27e 376//\r
377// Functions of Simple Text Input Protocol\r
378//\r
379/**\r
b4e73a63 380 Reset the input device and optionaly run diagnostics\r
5899f27e 381\r
382 There are 2 types of reset for USB keyboard.\r
383 For non-exhaustive reset, only keyboard buffer is cleared.\r
384 For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status\r
385 is also re-initialized.\r
386\r
b4e73a63 387 @param This Protocol instance pointer.\r
388 @param ExtendedVerification Driver may perform diagnostics on reset.\r
5899f27e 389\r
b4e73a63 390 @retval EFI_SUCCESS The device was reset.\r
391 @retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.\r
5899f27e 392\r
393**/\r
394EFI_STATUS\r
395EFIAPI\r
396USBKeyboardReset (\r
397 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
398 IN BOOLEAN ExtendedVerification\r
399 );\r
400\r
401/**\r
b4e73a63 402 Reads the next keystroke from the input device.\r
5899f27e 403\r
404 @param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance.\r
405 @param Key A pointer to a buffer that is filled in with the keystroke\r
406 information for the key that was pressed.\r
407\r
b4e73a63 408 @retval EFI_SUCCESS The keystroke information was returned.\r
409 @retval EFI_NOT_READY There was no keystroke data availiable.\r
410 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due to\r
411 hardware errors.\r
5899f27e 412\r
413**/\r
414EFI_STATUS\r
415EFIAPI\r
416USBKeyboardReadKeyStroke (\r
417 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
418 OUT EFI_INPUT_KEY *Key\r
419 );\r
420\r
66aa04e4 421//\r
422// Simple Text Input Ex protocol functions\r
423//\r
a7022cec 424/**\r
b4e73a63 425 Resets the input device hardware.\r
a7022cec 426\r
b4e73a63 427 The Reset() function resets the input device hardware. As part\r
428 of initialization process, the firmware/device will make a quick\r
429 but reasonable attempt to verify that the device is functioning.\r
430 If the ExtendedVerification flag is TRUE the firmware may take\r
431 an extended amount of time to verify the device is operating on\r
432 reset. Otherwise the reset operation is to occur as quickly as\r
433 possible. The hardware verification process is not defined by\r
434 this specification and is left up to the platform firmware or\r
435 driver to implement.\r
a7022cec 436\r
b4e73a63 437 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
438\r
439 @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
440 verification operation of the device during reset.\r
441\r
442 @retval EFI_SUCCESS The device was reset.\r
443 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.\r
a7022cec 444\r
445**/\r
66aa04e4 446EFI_STATUS\r
447EFIAPI\r
448USBKeyboardResetEx (\r
449 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
450 IN BOOLEAN ExtendedVerification\r
ed66e1bc 451 );\r
66aa04e4 452\r
a7022cec 453/**\r
b4e73a63 454 Reads the next keystroke from the input device.\r
66aa04e4 455\r
b4e73a63 456 @param This Protocol instance pointer.\r
457 @param KeyData A pointer to a buffer that is filled in with the keystroke\r
458 state data for the key that was pressed.\r
66aa04e4 459\r
b4e73a63 460 @retval EFI_SUCCESS The keystroke information was returned.\r
461 @retval EFI_NOT_READY There was no keystroke data available.\r
462 @retval EFI_DEVICE_ERROR The keystroke information was not returned due to\r
463 hardware errors.\r
464 @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
66aa04e4 465\r
a7022cec 466**/\r
66aa04e4 467EFI_STATUS\r
468EFIAPI\r
469USBKeyboardReadKeyStrokeEx (\r
470 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
471 OUT EFI_KEY_DATA *KeyData\r
ed66e1bc 472 );\r
66aa04e4 473\r
a7022cec 474/**\r
475 Set certain state for the input device.\r
66aa04e4 476\r
a7022cec 477 @param This Protocol instance pointer.\r
478 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
479 state for the input device.\r
66aa04e4 480\r
b4e73a63 481 @retval EFI_SUCCESS The device state was set appropriately.\r
482 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could\r
483 not have the setting adjusted.\r
484 @retval EFI_UNSUPPORTED The device does not support the ability to have its state set.\r
a7022cec 485 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
66aa04e4 486\r
a7022cec 487**/\r
66aa04e4 488EFI_STATUS\r
489EFIAPI\r
490USBKeyboardSetState (\r
491 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
492 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
ed66e1bc 493 );\r
66aa04e4 494\r
a7022cec 495/**\r
496 Register a notification function for a particular keystroke for the input device.\r
497\r
498 @param This Protocol instance pointer.\r
3652f990
DB
499 @param KeyData A pointer to a buffer that is filled in with\r
500 the keystroke information for the key that was\r
501 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState\r
502 and KeyData.KeyState.KeyShiftState are 0, then any incomplete\r
503 keystroke will trigger a notification of the KeyNotificationFunction.\r
a7022cec 504 @param KeyNotificationFunction Points to the function to be called when the key\r
3652f990
DB
505 sequence is typed specified by KeyData. This notification function\r
506 should be called at <=TPL_CALLBACK.\r
a7022cec 507 @param NotifyHandle Points to the unique handle assigned to the registered notification.\r
508\r
509 @retval EFI_SUCCESS The notification function was registered successfully.\r
510 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.\r
b4e73a63 511 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.\r
a7022cec 512\r
513**/\r
66aa04e4 514EFI_STATUS\r
515EFIAPI\r
516USBKeyboardRegisterKeyNotify (\r
517 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
518 IN EFI_KEY_DATA *KeyData,\r
519 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
402e4a9d 520 OUT VOID **NotifyHandle\r
ed66e1bc 521 );\r
66aa04e4 522\r
a7022cec 523/**\r
524 Remove a registered notification function from a particular keystroke.\r
525\r
526 @param This Protocol instance pointer.\r
527 @param NotificationHandle The handle of the notification function being unregistered.\r
528\r
529 @retval EFI_SUCCESS The notification function was unregistered successfully.\r
b4e73a63 530 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid\r
531 @retval EFI_NOT_FOUND Cannot find the matching entry in database.\r
a7022cec 532\r
533**/\r
66aa04e4 534EFI_STATUS\r
535EFIAPI\r
536USBKeyboardUnregisterKeyNotify (\r
537 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
402e4a9d 538 IN VOID *NotificationHandle\r
ed66e1bc 539 );\r
66aa04e4 540\r
5899f27e 541/**\r
b4e73a63 542 Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx\r
543 and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.\r
5899f27e 544\r
545 @param Event Event to be signaled when a key is pressed.\r
546 @param Context Points to USB_KB_DEV instance.\r
547\r
548**/\r
549VOID\r
550EFIAPI\r
551USBKeyboardWaitForKey (\r
552 IN EFI_EVENT Event,\r
553 IN VOID *Context\r
554 );\r
555\r
556/**\r
557 Free keyboard notify list.\r
558\r
b4e73a63 559 @param NotifyList The keyboard notify list to free.\r
5899f27e 560\r
561 @retval EFI_SUCCESS Free the notify list successfully.\r
b4e73a63 562 @retval EFI_INVALID_PARAMETER NotifyList is NULL.\r
5899f27e 563\r
564**/\r
565EFI_STATUS\r
5899f27e 566KbdFreeNotifyList (\r
b4e73a63 567 IN OUT LIST_ENTRY *NotifyList\r
5899f27e 568 );\r
569\r
5899f27e 570/**\r
b4e73a63 571 Check whether the pressed key matches a registered key or not.\r
5899f27e 572\r
b4e73a63 573 @param RegsiteredData A pointer to keystroke data for the key that was registered.\r
574 @param InputData A pointer to keystroke data for the key that was pressed.\r
5899f27e 575\r
576 @retval TRUE Key pressed matches a registered key.\r
b4e73a63 577 @retval FLASE Key pressed does not matche a registered key.\r
5899f27e 578\r
579**/\r
580BOOLEAN\r
5899f27e 581IsKeyRegistered (\r
582 IN EFI_KEY_DATA *RegsiteredData,\r
583 IN EFI_KEY_DATA *InputData\r
584 );\r
585\r
c1fd2767
RN
586/**\r
587 Timer handler to convert the key from USB.\r
588\r
589 @param Event Indicates the event that invoke this function.\r
590 @param Context Indicates the calling context.\r
591**/\r
592VOID\r
593EFIAPI\r
594USBKeyboardTimerHandler (\r
595 IN EFI_EVENT Event,\r
596 IN VOID *Context\r
597 );\r
598\r
4ae46dba
SZ
599/**\r
600 Process key notify.\r
601\r
602 @param Event Indicates the event that invoke this function.\r
603 @param Context Indicates the calling context.\r
604**/\r
605VOID\r
606EFIAPI\r
607KeyNotifyProcessHandler (\r
608 IN EFI_EVENT Event,\r
609 IN VOID *Context\r
610 );\r
611\r
ed838d0c 612#endif\r
66aa04e4 613\r