]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
Fix the USB keyboard driver to call hotkey callback even no one is calling ReadKeyStroke
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / KeyBoard.h
index 60ebee1daafcf47ccd374e80077238919d0a0a64..73efef8f62c2e1ca4f6429e45c3024cf44a4d66c 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Function prototype for USB Keyboard Driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -18,6 +18,48 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "EfiKey.h"\r
 \r
+#define USB_KEYBOARD_LAYOUT_PACKAGE_GUID \\r
+  { \\r
+    0xc0f3b43, 0x44de, 0x4907, { 0xb4, 0x78, 0x22, 0x5f, 0x6f, 0x62, 0x89, 0xdc } \\r
+  }\r
+\r
+#define USB_KEYBOARD_LAYOUT_KEY_GUID \\r
+  { \\r
+    0x3a4d7a7c, 0x18a, 0x4b42, { 0x81, 0xb3, 0xdc, 0x10, 0xe3, 0xb5, 0x91, 0xbd } \\r
+  }\r
+\r
+#define USB_KEYBOARD_KEY_COUNT            104\r
+\r
+#define USB_KEYBOARD_LANGUAGE_STR_LEN     5         // RFC4646 Language Code: "en-US"\r
+#define USB_KEYBOARD_DESCRIPTION_STR_LEN  (16 + 1)  // Description: "English Keyboard"\r
+\r
+#pragma pack (1)\r
+typedef struct {\r
+  //\r
+  // This 4-bytes total array length is required by PreparePackageList()\r
+  //\r
+  UINT32                 Length;\r
+\r
+  //\r
+  // Keyboard Layout package definition\r
+  //\r
+  EFI_HII_PACKAGE_HEADER PackageHeader;\r
+  UINT16                 LayoutCount;\r
+\r
+  //\r
+  // EFI_HII_KEYBOARD_LAYOUT\r
+  //\r
+  UINT16                 LayoutLength;\r
+  EFI_GUID               Guid;\r
+  UINT32                 LayoutDescriptorStringOffset;\r
+  UINT8                  DescriptorCount;\r
+  EFI_KEY_DESCRIPTOR     KeyDescriptor[USB_KEYBOARD_KEY_COUNT];\r
+  UINT16                 DescriptionCount;\r
+  CHAR16                 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];\r
+  CHAR16                 Space;\r
+  CHAR16                 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];\r
+} USB_KEYBOARD_LAYOUT_PACK_BIN;\r
+#pragma pack()\r
 /**\r
   Uses USB I/O to check whether the device is a USB keyboard device.\r
 \r
@@ -28,7 +70,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 IsUSBKeyboard (\r
   IN  EFI_USB_IO_PROTOCOL       *UsbIo\r
   );\r
@@ -43,7 +84,6 @@ IsUSBKeyboard (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InitUSBKeyboard (\r
   IN OUT USB_KB_DEV   *UsbKeyboardDevice\r
   );\r
@@ -64,7 +104,6 @@ InitUSBKeyboard (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InitKeyboardLayout (\r
   OUT USB_KB_DEV   *UsbKeyboardDevice\r
   );\r
@@ -76,7 +115,6 @@ InitKeyboardLayout (
 \r
 **/\r
 VOID\r
-EFIAPI\r
 ReleaseKeyboardLayoutResources (\r
   IN OUT USB_KB_DEV              *UsbKeyboardDevice\r
   );\r
@@ -142,7 +180,6 @@ USBKeyboardRecoveryHandler (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 USBParseKey (\r
   IN OUT  USB_KB_DEV  *UsbKeyboardDevice,\r
   OUT     UINT8       *KeyCode\r
@@ -153,7 +190,7 @@ USBParseKey (
 \r
   @param  UsbKeyboardDevice     The USB_KB_DEV instance.\r
   @param  KeyCode               Indicates the key code that will be interpreted.\r
-  @param  Key                   A pointer to a buffer that is filled in with\r
+  @param  KeyData               A pointer to a buffer that is filled in with\r
                                 the keystroke information for the key that\r
                                 was pressed.\r
 \r
@@ -165,87 +202,98 @@ USBParseKey (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 UsbKeyCodeToEfiInputKey (\r
   IN  USB_KB_DEV      *UsbKeyboardDevice,\r
   IN  UINT8           KeyCode,\r
-  OUT EFI_INPUT_KEY   *Key\r
+  OUT EFI_KEY_DATA    *KeyData\r
   );\r
 \r
+\r
 /**\r
-  Resets USB keyboard buffer.\r
+  Create the queue.\r
 \r
-  @param  KeyboardBuffer     Points to the USB keyboard buffer.\r
+  @param  Queue     Points to the queue.\r
+  @param  ItemSize  Size of the single item.\r
 \r
 **/\r
 VOID\r
-EFIAPI\r
-InitUSBKeyBuffer (\r
-  OUT  USB_KB_BUFFER   *KeyboardBuffer\r
+InitQueue (\r
+  IN OUT  USB_SIMPLE_QUEUE   *Queue,\r
+  IN      UINTN              ItemSize\r
+  );\r
+\r
+/**\r
+  Destroy the queue\r
+\r
+  @param Queue    Points to the queue.\r
+**/\r
+VOID\r
+DestroyQueue (\r
+  IN OUT USB_SIMPLE_QUEUE   *Queue\r
   );\r
 \r
+\r
 /**\r
-  Check whether USB keyboard buffer is empty.\r
+  Check whether the queue is empty.\r
 \r
-  @param  KeyboardBuffer     USB keyboard buffer\r
+  @param  Queue     Points to the queue.\r
 \r
-  @retval TRUE               Keyboard buffer is empty.\r
-  @retval FALSE              Keyboard buffer is not empty.\r
+  @retval TRUE      Queue is empty.\r
+  @retval FALSE     Queue is not empty.\r
 \r
 **/\r
 BOOLEAN\r
-EFIAPI\r
-IsUSBKeyboardBufferEmpty (\r
-  IN  USB_KB_BUFFER   *KeyboardBuffer\r
+IsQueueEmpty (\r
+  IN  USB_SIMPLE_QUEUE   *Queue\r
   );\r
 \r
+\r
 /**\r
-  Check whether USB keyboard buffer is full.\r
+  Check whether the queue is full.\r
 \r
-  @param  KeyboardBuffer     USB keyboard buffer\r
+  @param  Queue     Points to the queue.\r
 \r
-  @retval TRUE               Keyboard buffer is full.\r
-  @retval FALSE              Keyboard buffer is not full.\r
+  @retval TRUE      Queue is full.\r
+  @retval FALSE     Queue is not full.\r
 \r
 **/\r
 BOOLEAN\r
-EFIAPI\r
-IsUSBKeyboardBufferFull (\r
-  IN  USB_KB_BUFFER   *KeyboardBuffer\r
+IsQueueFull (\r
+  IN  USB_SIMPLE_QUEUE   *Queue\r
   );\r
 \r
-/**\r
-  Inserts a keycode into keyboard buffer.\r
 \r
-  @param  KeyboardBuffer     Points to the USB keyboard buffer.\r
-  @param  Key                Keycode to insert.\r
-  @param  Down               TRUE means key is pressed.\r
-                             FALSE means key is released.\r
+/**\r
+  Enqueue the item to the queue.\r
 \r
+  @param  Queue     Points to the queue.\r
+  @param  Item      Points to the item to be enqueued.\r
+  @param  ItemSize  Size of the item.\r
 **/\r
 VOID\r
-EFIAPI\r
-InsertKeyCode (\r
-  IN OUT  USB_KB_BUFFER *KeyboardBuffer,\r
-  IN      UINT8         Key,\r
-  IN      BOOLEAN       Down\r
+Enqueue (\r
+  IN OUT  USB_SIMPLE_QUEUE *Queue,\r
+  IN      VOID             *Item,\r
+  IN      UINTN            ItemSize\r
   );\r
 \r
+\r
 /**\r
-  Remove a keycode from keyboard buffer and return it.\r
+  Dequeue a item from the queue.\r
 \r
-  @param  KeyboardBuffer     Points to the USB keyboard buffer.\r
-  @param  UsbKey             Points to the buffer that contains keycode for output.\r
+  @param  Queue     Points to the queue.\r
+  @param  Item      Receives the item.\r
+  @param  ItemSize  Size of the item.\r
 \r
-  @retval EFI_SUCCESS        Keycode successfully removed from keyboard buffer.\r
-  @retval EFI_DEVICE_ERROR   Keyboard buffer is empty.\r
+  @retval EFI_SUCCESS        Item was successfully dequeued.\r
+  @retval EFI_DEVICE_ERROR   The queue is empty.\r
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-RemoveKeyCode (\r
-  IN OUT  USB_KB_BUFFER *KeyboardBuffer,\r
-     OUT  USB_KEY       *UsbKey\r
+Dequeue (\r
+  IN OUT  USB_SIMPLE_QUEUE *Queue,\r
+     OUT  VOID             *Item,\r
+  IN      UINTN            ItemSize\r
   );\r
 \r
 /**\r
@@ -275,7 +323,6 @@ USBKeyboardRepeatHandler (
 \r
 **/\r
 VOID\r
-EFIAPI\r
 SetKeyLED (\r
   IN  USB_KB_DEV    *UsbKeyboardDevice\r
   );\r