]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h
Update to support EFI_SIMPLE_INPUT_EX protocol
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / efikey.h
index 710ec7c19e761abed66ab7b2519ee5ea49d86a74..bab22a3b883ea05970a5d20f3eda57984b704747 100644 (file)
@@ -26,6 +26,7 @@ Revision History
 #include <PiDxe.h>\r
 \r
 #include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/SimpleTextInEx.h>\r
 #include <Guid/HotPlugDevice.h>\r
 #include <Protocol/UsbIo.h>\r
 #include <Protocol/DevicePath.h>\r
@@ -40,7 +41,7 @@ Revision History
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UsbLib.h>\r
-\r
+#include <Library/BaseLib.h>\r
 \r
 #include <IndustryStandard/Usb.h>\r
 \r
@@ -69,12 +70,22 @@ typedef struct {
 } USB_KB_BUFFER;\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
+\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
 typedef struct {\r
   UINTN                          Signature;\r
   EFI_DEVICE_PATH_PROTOCOL       *DevicePath;\r
   EFI_EVENT                      DelayedRecoveryEvent;\r
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
-  EFI_USB_IO_PROTOCOL            *UsbIo;\r
+  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r
+  EFI_USB_IO_PROTOCOL           *UsbIo;\r
 \r
   EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDescriptor;\r
   EFI_USB_ENDPOINT_DESCRIPTOR   IntEndpointDescriptor;\r
@@ -93,7 +104,23 @@ typedef struct {
   EFI_EVENT                     RepeatTimer;\r
 \r
   EFI_UNICODE_STRING_TABLE      *ControllerNameTable;\r
-\r
+  \r
+  UINT8                         LeftCtrlOn;\r
+  UINT8                         LeftAltOn;\r
+  UINT8                         LeftShiftOn;\r
+  UINT8                         LeftLogoOn;\r
+  UINT8                         RightCtrlOn;\r
+  UINT8                         RightAltOn;\r
+  UINT8                         RightShiftOn;\r
+  UINT8                         RightLogoOn;  \r
+  UINT8                         MenuKeyOn;\r
+  UINT8                         SysReqOn;\r
+\r
+  EFI_KEY_STATE                 KeyState;\r
+  //\r
+  // Notification function list\r
+  //\r
+  LIST_ENTRY                    NotifyList;\r
 } USB_KB_DEV;\r
 \r
 //\r
@@ -103,6 +130,7 @@ extern EFI_DRIVER_BINDING_PROTOCOL   gUsbKeyboardDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL   gUsbKeyboardComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL  gUsbKeyboardComponentName2;\r
 extern EFI_GUID                      gEfiUsbKeyboardDriverGuid;\r
+extern EFI_GUID                      gSimpleTextInExNotifyGuid;\r
 \r
 VOID\r
 KbdReportStatusCode (\r
@@ -113,6 +141,9 @@ KbdReportStatusCode (
 \r
 #define USB_KB_DEV_FROM_THIS(a) \\r
     CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)\r
+#define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \\r
+    CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE)\r
+\r
 \r
 #define MOD_CONTROL_L           0x01\r
 #define MOD_CONTROL_R           0x10\r
@@ -128,7 +159,7 @@ typedef struct {
   UINT8 Key;\r
 } KB_MODIFIER;\r
 \r
-#define USB_KEYCODE_MAX_MAKE      0x64\r
+#define USB_KEYCODE_MAX_MAKE      0x7E\r
 \r
 #define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)\r
 \r
@@ -138,4 +169,137 @@ typedef struct {
   UINT8 ScrollLock : 1;\r
   UINT8 Resrvd : 5;\r
 } LED_MAP;\r
+\r
+//\r
+// Simple Text Input Ex protocol functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+USBKeyboardResetEx (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN BOOLEAN                            ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the input device and optionaly run diagnostics\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBKeyboardReadKeyStrokeEx (\r
+  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
+  OUT EFI_KEY_DATA                      *KeyData\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the next keystroke from the input device. The WaitForKey Event can \r
+    be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    KeyData    - A pointer to a buffer that is filled in with the keystroke \r
+                 state data for the key that was pressed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The keystroke information was returned.\r
+    EFI_NOT_READY         - There was no keystroke data availiable.\r
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to \r
+                            hardware errors.\r
+    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBKeyboardSetState (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set certain state for the input device.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    KeyToggleState        - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
+                            state for the input device.\r
+                          \r
+  Returns:                \r
+    EFI_SUCCESS           - The device state was set successfully.\r
+    EFI_DEVICE_ERROR      - The device is not functioning correctly and could \r
+                            not have the setting adjusted.\r
+    EFI_UNSUPPORTED       - The device does not have the ability to set its state.\r
+    EFI_INVALID_PARAMETER - KeyToggleState is NULL.                       \r
+\r
+--*/   \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBKeyboardRegisterKeyNotify (\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
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a notification function for a particular keystroke for the input device.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.\r
+    KeyData                 - A pointer to a buffer that is filled in with the keystroke \r
+                              information data for the key that was pressed.\r
+    KeyNotificationFunction - Points to the function to be called when the key \r
+                              sequence is typed specified by KeyData.                        \r
+    NotifyHandle            - Points to the unique handle assigned to the registered notification.                          \r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was registered successfully.\r
+    EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necesssary data structures.\r
+    EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.                       \r
+                              \r
+--*/   \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+USBKeyboardUnregisterKeyNotify (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_HANDLE                         NotificationHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Remove a registered notification function from a particular keystroke.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.    \r
+    NotificationHandle      - The handle of the notification function being unregistered.\r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was unregistered successfully.\r
+    EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.\r
+    EFI_NOT_FOUND           - Can not find the matching entry in database.  \r
+                              \r
+--*/   \r
+;\r
+\r
 #endif\r
+\r