/** @file\r
Header file for USB Keyboard Driver's Data Structures.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
#ifndef _EFI_USB_KB_H_\r
#include <Protocol/HiiDatabase.h>\r
#include <Protocol/UsbIo.h>\r
#include <Protocol/DevicePath.h>\r
+\r
#include <Guid/HiiKeyBoardLayout.h>\r
-#include <Guid/HotPlugDevice.h>\r
+#include <Guid/UsbKeyBoardLayout.h>\r
\r
#include <Library/DebugLib.h>\r
#include <Library/ReportStatusCodeLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
#include <Library/UefiUsbLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiUsbLib.h>\r
+#include <Library/HiiLib.h>\r
\r
#include <IndustryStandard/Usb.h>\r
\r
+#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s\r
+\r
#define MAX_KEY_ALLOWED 32\r
\r
#define HZ 1000 * 1000 * 10\r
} USB_KEY;\r
\r
typedef struct {\r
- USB_KEY Buffer[MAX_KEY_ALLOWED + 1];\r
- UINT8 BufferHead;\r
- UINT8 BufferTail;\r
-} USB_KB_BUFFER;\r
+ VOID *Buffer[MAX_KEY_ALLOWED + 1];\r
+ UINTN Head;\r
+ UINTN Tail;\r
+ UINTN ItemSize;\r
+} USB_SIMPLE_QUEUE;\r
\r
-#define USB_KB_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'd')\r
-#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'x')\r
+#define USB_KB_DEV_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'd')\r
+#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'x')\r
\r
typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
UINTN Signature;\r
- EFI_HANDLE NotifyHandle;\r
EFI_KEY_DATA KeyData;\r
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r
LIST_ENTRY NotifyEntry;\r
} KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
\r
-#define USB_NS_KEY_SIGNATURE EFI_SIGNATURE_32 ('u', 'n', 's', 'k')\r
+#define USB_NS_KEY_SIGNATURE SIGNATURE_32 ('u', 'n', 's', 'k')\r
\r
typedef struct {\r
UINTN Signature;\r
///\r
typedef struct {\r
UINTN Signature;\r
+ EFI_HANDLE ControllerHandle;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_EVENT DelayedRecoveryEvent;\r
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r
EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r
\r
- USB_KB_BUFFER KeyboardBuffer;\r
+ USB_SIMPLE_QUEUE UsbKeyQueue;\r
+ USB_SIMPLE_QUEUE EfiKeyQueue;\r
+ USB_SIMPLE_QUEUE EfiKeyQueueForNotify;\r
BOOLEAN CtrlOn;\r
BOOLEAN AltOn;\r
BOOLEAN ShiftOn;\r
UINT8 LastKeyCodeArray[8];\r
UINT8 CurKeyCode;\r
\r
+ EFI_EVENT TimerEvent;\r
+\r
UINT8 RepeatKey;\r
EFI_EVENT RepeatTimer;\r
\r
EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
- \r
+\r
BOOLEAN LeftCtrlOn;\r
BOOLEAN LeftAltOn;\r
BOOLEAN LeftShiftOn;\r
BOOLEAN RightCtrlOn;\r
BOOLEAN RightAltOn;\r
BOOLEAN RightShiftOn;\r
- BOOLEAN RightLogoOn; \r
+ BOOLEAN RightLogoOn;\r
BOOLEAN MenuKeyOn;\r
BOOLEAN SysReqOn;\r
BOOLEAN AltGrOn;\r
\r
+ BOOLEAN IsSupportPartialKey;\r
+\r
EFI_KEY_STATE KeyState;\r
//\r
// Notification function list\r
//\r
LIST_ENTRY NotifyList;\r
+ EFI_EVENT KeyNotifyProcessEvent;\r
\r
//\r
// Non-spacing key list\r
extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;\r
extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;\r
extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;\r
-extern EFI_GUID gSimpleTextInExNotifyGuid;\r
\r
#define USB_KB_DEV_FROM_THIS(a) \\r
CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)\r
);\r
\r
/**\r
- Starts the device with this driver.\r
+ Starts the keyboard device with this driver.\r
\r
This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,\r
initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified\r
- in RFC 3066 or ISO 639-2 language code format.\r
+ in RFC 4646 or ISO 639-2 language code format.\r
@param DriverName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
driver specified by This in the language\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified in\r
- RFC 3066 or ISO 639-2 language code format.\r
+ RFC 4646 or ISO 639-2 language code format.\r
@param ControllerName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
controller specified by ControllerHandle and\r
Register a notification function for a particular keystroke for the input device.\r
\r
@param This Protocol instance pointer.\r
- @param KeyData A pointer to a buffer that is filled in with the keystroke\r
- information data for the key that was pressed.\r
+ @param KeyData A pointer to a buffer that is filled in with\r
+ the keystroke information for the key that was\r
+ pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState\r
+ and KeyData.KeyState.KeyShiftState are 0, then any incomplete\r
+ keystroke will trigger a notification of the KeyNotificationFunction.\r
@param KeyNotificationFunction Points to the function to be called when the key\r
- sequence is typed specified by KeyData.\r
+ sequence is typed specified by KeyData. This notification function\r
+ should be called at <=TPL_CALLBACK.\r
@param NotifyHandle Points to the unique handle assigned to the registered notification.\r
\r
@retval EFI_SUCCESS The notification function was registered successfully.\r
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
IN EFI_KEY_DATA *KeyData,\r
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
- OUT EFI_HANDLE *NotifyHandle\r
+ OUT VOID **NotifyHandle\r
);\r
\r
/**\r
EFIAPI\r
USBKeyboardUnregisterKeyNotify (\r
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
- IN EFI_HANDLE NotificationHandle\r
+ IN VOID *NotificationHandle\r
);\r
\r
/**\r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
KbdFreeNotifyList (\r
IN OUT LIST_ENTRY *NotifyList\r
);\r
\r
-/**\r
- Check whether there is key pending in the keyboard buffer.\r
-\r
- @param UsbKeyboardDevice The USB_KB_DEV instance.\r
-\r
- @retval EFI_SUCCESS There is pending key to read.\r
- @retval EFI_NOT_READY No pending key to read.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-USBKeyboardCheckForKey (\r
- IN OUT USB_KB_DEV *UsbKeyboardDevice\r
- );\r
-\r
/**\r
Check whether the pressed key matches a registered key or not.\r
\r
\r
**/\r
BOOLEAN\r
-EFIAPI\r
IsKeyRegistered (\r
IN EFI_KEY_DATA *RegsiteredData,\r
IN EFI_KEY_DATA *InputData\r
);\r
\r
+/**\r
+ Timer handler to convert the key from USB.\r
+\r
+ @param Event Indicates the event that invoke this function.\r
+ @param Context Indicates the calling context.\r
+**/\r
+VOID\r
+EFIAPI\r
+USBKeyboardTimerHandler (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Process key notify.\r
+\r
+ @param Event Indicates the event that invoke this function.\r
+ @param Context Indicates the calling context.\r
+**/\r
+VOID\r
+EFIAPI\r
+KeyNotifyProcessHandler (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
#endif\r
\r