]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.h
index 08bfc68b3930ee34b1a74e55c30032e6894c034b..65819e43e6bdcece599f385854eef59973898f50 100644 (file)
@@ -1,14 +1,8 @@
 /** @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
@@ -22,8 +16,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -35,11 +30,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -59,23 +55,23 @@ typedef struct {
 } 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
@@ -100,6 +96,7 @@ typedef struct {
 ///\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
@@ -109,7 +106,9 @@ typedef struct {
   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
@@ -119,11 +118,13 @@ typedef struct {
   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
@@ -131,16 +132,19 @@ typedef struct {
   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
@@ -157,7 +161,6 @@ typedef struct {
 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
@@ -209,7 +212,7 @@ USBKeyboardDriverBindingSupported (
   );\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
@@ -279,7 +282,7 @@ USBKeyboardDriverBindingStop (
                                 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
@@ -336,7 +339,7 @@ UsbKeyboardComponentNameGetDriverName (
                                 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
@@ -493,10 +496,14 @@ USBKeyboardSetState (
   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
@@ -510,7 +517,7 @@ USBKeyboardRegisterKeyNotify (
   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
@@ -528,7 +535,7 @@ EFI_STATUS
 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
@@ -556,26 +563,10 @@ USBKeyboardWaitForKey (
 \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
@@ -587,11 +578,36 @@ USBKeyboardCheckForKey (
 \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