]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Usb/UsbKb/Dxe/keyboard.c
Add some definitions for efi event in Uefi/UefiSpec.h to follow spec.
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbKb / Dxe / keyboard.c
index 64bbd30d4ba79ca36602a5246040edab29739d79..d81a976fb0750f45880141c9b5653c59a9f0caae 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
-Copyright (c) 2006, 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) 2006, 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
 \r
 Module Name:\r
 \r
   Keyboard.c\r
-    \r
+\r
 Abstract:\r
 \r
   Helper functions for USB Keyboard Driver\r
@@ -85,8 +85,8 @@ UINT8 KeyConvertionTable[USB_KEYCODE_MAX_MAKE][3] = {
   { SCAN_NULL,      0x00,     0x00 },     // 0x39   CapsLock\r
   { SCAN_F1,        0x00,     0x00 },     // 0x3A\r
   { SCAN_F2,        0x00,     0x00 },     // 0x3B\r
-  { SCAN_F3,        0x00,     0x00 },     // 0x3C  \r
-  { SCAN_F4,        0x00,     0x00 },     // 0x3D  \r
+  { SCAN_F3,        0x00,     0x00 },     // 0x3C\r
+  { SCAN_F4,        0x00,     0x00 },     // 0x3D\r
   { SCAN_F5,        0x00,     0x00 },     // 0x3E\r
   { SCAN_F6,        0x00,     0x00 },     // 0x3F\r
   { SCAN_F7,        0x00,     0x00 },     // 0x40\r
@@ -132,14 +132,14 @@ UINT8 KeyConvertionTable[USB_KEYCODE_MAX_MAKE][3] = {
 };\r
 \r
 STATIC KB_MODIFIER  KB_Mod[8] = {\r
-  { MOD_CONTROL_L,  0xe0 }, // 11100000 \r
-  { MOD_CONTROL_R,  0xe4 }, // 11100100 \r
-  { MOD_SHIFT_L,    0xe1 }, // 11100001 \r
-  { MOD_SHIFT_R,    0xe5 }, // 11100101 \r
-  { MOD_ALT_L,      0xe2 }, // 11100010 \r
-  { MOD_ALT_R,      0xe6 }, // 11100110 \r
-  { MOD_WIN_L,      0xe3 }, // 11100011 \r
-  { MOD_WIN_R,      0xe7 }  // 11100111 \r
+  { MOD_CONTROL_L,  0xe0 }, // 11100000\r
+  { MOD_CONTROL_R,  0xe4 }, // 11100100\r
+  { MOD_SHIFT_L,    0xe1 }, // 11100001\r
+  { MOD_SHIFT_R,    0xe5 }, // 11100101\r
+  { MOD_ALT_L,      0xe2 }, // 11100010\r
+  { MOD_ALT_R,      0xe6 }, // 11100110\r
+  { MOD_WIN_L,      0xe3 }, // 11100011\r
+  { MOD_WIN_R,      0xe7 }  // 11100111\r
 };\r
 \r
 \r
@@ -148,16 +148,16 @@ IsUSBKeyboard (
   IN  EFI_USB_IO_PROTOCOL       *UsbIo\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Uses USB I/O to check whether the device is a USB Keyboard device.\r
-  \r
+\r
   Arguments:\r
     UsbIo:    Points to a USB I/O protocol instance.\r
-    \r
+\r
   Returns:\r
-  \r
---*/  \r
+\r
+--*/\r
 {\r
   EFI_STATUS                    Status;\r
   EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDescriptor;\r
@@ -192,13 +192,13 @@ InitUSBKeyboard (
   IN USB_KB_DEV   *UsbKeyboardDevice\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Initialize USB Keyboard device and all private data structures.\r
-    \r
+\r
   Arguments:\r
     UsbKeyboardDevice    The USB_KB_DEV instance.\r
-    \r
+\r
   Returns:\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware Error\r
@@ -289,7 +289,7 @@ InitUSBKeyboard (
   UsbKeyboardDevice->ShiftOn    = 0;\r
   UsbKeyboardDevice->NumLockOn  = 0;\r
   UsbKeyboardDevice->CapsOn     = 0;\r
-  UsbKeyboardDevice->ScrollOn   = 0;  \r
+  UsbKeyboardDevice->ScrollOn   = 0;\r
   ZeroMem (UsbKeyboardDevice->LastKeyCodeArray, sizeof (UINT8) * 8);\r
 \r
   //\r
@@ -301,8 +301,8 @@ InitUSBKeyboard (
   }\r
 \r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,\r
-                  EFI_TPL_NOTIFY,\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   USBKeyboardRepeatHandler,\r
                   UsbKeyboardDevice,\r
                   &UsbKeyboardDevice->RepeatTimer\r
@@ -314,8 +314,8 @@ InitUSBKeyboard (
   }\r
 \r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,\r
-                  EFI_TPL_NOTIFY,\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
                   USBKeyboardRecoveryHandler,\r
                   UsbKeyboardDevice,\r
                   &UsbKeyboardDevice->DelayedRecoveryEvent\r
@@ -333,21 +333,21 @@ KeyboardHandler (
   IN  UINT32        Result\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Handler function for USB Keyboard's asynchronous interrupt transfer.\r
-    \r
+\r
   Arguments:\r
     Data       A pointer to a buffer that is filled with key data which is\r
                retrieved via asynchronous interrupt transfer.\r
     DataLength Indicates the size of the data buffer.\r
     Context    Pointing to USB_KB_DEV instance.\r
     Result     Indicates the result of the asynchronous interrupt transfer.\r
-    \r
+\r
   Returns:\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware Error\r
---*/  \r
+--*/\r
 {\r
   USB_KB_DEV          *UsbKeyboardDevice;\r
   EFI_USB_IO_PROTOCOL *UsbIo;\r
@@ -402,11 +402,11 @@ KeyboardHandler (
         &UsbStatus\r
         );\r
     }\r
-    \r
+\r
     //\r
     // Delete & Submit this interrupt again\r
     //\r
-    \r
+\r
     UsbIo->UsbAsyncInterruptTransfer (\r
              UsbIo,\r
              UsbKeyboardDevice->IntEndpointDescriptor.EndpointAddress,\r
@@ -446,7 +446,7 @@ KeyboardHandler (
   if (Index == 8) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // Parse the modifier key\r
   //\r
@@ -469,7 +469,7 @@ KeyboardHandler (
       InsertKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), KB_Mod[Index].Key, Down);\r
     }\r
   }\r
-  \r
+\r
   //\r
   // handle normal key's releasing situation\r
   //\r
@@ -507,7 +507,7 @@ KeyboardHandler (
       }\r
     }\r
   }\r
-    \r
+\r
   //\r
   // original repeat key is released, cancel the repeat timer\r
   //\r
@@ -518,7 +518,7 @@ KeyboardHandler (
           USBKBD_REPEAT_RATE\r
           );\r
   }\r
-  \r
+\r
   //\r
   // handle normal key's pressing situation\r
   //\r
@@ -558,7 +558,7 @@ KeyboardHandler (
       }\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Update LastKeycodeArray[] buffer in the\r
   // Usb Keyboard Device data structure.\r
@@ -566,7 +566,7 @@ KeyboardHandler (
   for (Index = 0; Index < 8; Index++) {\r
     UsbKeyboardDevice->LastKeyCodeArray[Index] = CurKeyCodeBuffer[Index];\r
   }\r
-  \r
+\r
   //\r
   // pre-process KeyboardBuffer, pop out the ctrl,alt,del key in sequence\r
   // and judge whether it will invoke reset event.\r
@@ -611,7 +611,7 @@ KeyboardHandler (
     default:\r
       break;\r
     }\r
-    \r
+\r
     //\r
     // insert the key back to the buffer.\r
     // so the key sequence will not be destroyed.\r
@@ -651,18 +651,18 @@ USBParseKey (
   OUT     UINT8       *KeyChar\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Retrieves a key character after parsing the raw data in keyboard buffer.\r
-    \r
+\r
   Arguments:\r
     UsbKeyboardDevice    The USB_KB_DEV instance.\r
     KeyChar              Points to the Key character after key parsing.\r
-    \r
+\r
   Returns:\r
     EFI_SUCCESS   - Success\r
-    EFI_NOT_READY - Device is not ready \r
---*/  \r
+    EFI_NOT_READY - Device is not ready\r
+--*/\r
 {\r
   USB_KEY UsbKey;\r
 \r
@@ -698,7 +698,7 @@ USBParseKey (
 \r
       continue;\r
     }\r
-    \r
+\r
     //\r
     // Analyzes key pressing situation\r
     //\r
@@ -762,7 +762,7 @@ USBParseKey (
       UsbKeyboardDevice->ScrollOn ^= 1;\r
       SetKeyLED (UsbKeyboardDevice);\r
       continue;\r
-      break;    \r
+      break;\r
     case 0x48:\r
     //\r
     // fall through\r
@@ -775,7 +775,7 @@ USBParseKey (
     default:\r
       break;\r
     }\r
-    \r
+\r
     //\r
     // When encountered Del Key...\r
     //\r
@@ -801,15 +801,15 @@ USBKeyCodeToEFIScanCode (
   OUT EFI_INPUT_KEY   *Key\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Converts USB Keyboard code to EFI Scan Code.\r
-    \r
-  Arguments:  \r
+\r
+  Arguments:\r
     UsbKeyboardDevice    The USB_KB_DEV instance.\r
-    KeyChar              Indicates the key code that will be interpreted.    \r
-    Key                  A pointer to a buffer that is filled in with \r
-                         the keystroke information for the key that \r
+    KeyChar              Indicates the key code that will be interpreted.\r
+    Key                  A pointer to a buffer that is filled in with\r
+                         the keystroke information for the key that\r
                          was pressed.\r
   Returns:\r
     EFI_NOT_READY - Device is not ready\r
@@ -821,7 +821,7 @@ USBKeyCodeToEFIScanCode (
   if (!USBKBD_VALID_KEYCODE (KeyChar)) {\r
     return EFI_NOT_READY;\r
   }\r
-  \r
+\r
   //\r
   // valid USB Key Code starts from 4\r
   //\r
@@ -881,16 +881,16 @@ InitUSBKeyBuffer (
   IN OUT  USB_KB_BUFFER   *KeyboardBuffer\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Resets USB Keyboard Buffer.\r
-    \r
+\r
   Arguments:\r
     KeyboardBuffer - Points to the USB Keyboard Buffer.\r
-    \r
+\r
   Returns:\r
     EFI_SUCCESS - Success\r
---*/  \r
+--*/\r
 {\r
   ZeroMem (KeyboardBuffer, sizeof (USB_KB_BUFFER));\r
 \r
@@ -904,15 +904,15 @@ IsUSBKeyboardBufferEmpty (
   IN  USB_KB_BUFFER   *KeyboardBuffer\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Check whether USB Keyboard buffer is empty.\r
-    \r
+\r
   Arguments:\r
     KeyboardBuffer - USB Keyboard Buffer.\r
-    \r
+\r
   Returns:\r
-  \r
+\r
 --*/\r
 {\r
   //\r
@@ -927,18 +927,18 @@ IsUSBKeyboardBufferFull (
   IN  USB_KB_BUFFER   *KeyboardBuffer\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Check whether USB Keyboard buffer is full.\r
-    \r
+\r
   Arguments:\r
     KeyboardBuffer - USB Keyboard Buffer.\r
-    \r
+\r
   Returns:\r
-  \r
+\r
 --*/\r
 {\r
-  return (BOOLEAN)(((KeyboardBuffer->bTail + 1) % (MAX_KEY_ALLOWED + 1)) == \r
+  return (BOOLEAN)(((KeyboardBuffer->bTail + 1) % (MAX_KEY_ALLOWED + 1)) ==\r
                                                         KeyboardBuffer->bHead);\r
 }\r
 \r
@@ -950,10 +950,10 @@ InsertKeyCode (
   IN      UINT8         Down\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Inserts a key code into keyboard buffer.\r
-    \r
+\r
   Arguments:\r
     KeyboardBuffer - Points to the USB Keyboard Buffer.\r
     Key            - Key code\r
@@ -989,18 +989,18 @@ RemoveKeyCode (
   OUT     USB_KEY       *UsbKey\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Pops a key code off from keyboard buffer.\r
-    \r
+\r
   Arguments:\r
     KeyboardBuffer -  Points to the USB Keyboard Buffer.\r
     UsbKey         -  Points to the buffer that contains a usb key code.\r
-  \r
+\r
   Returns:\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware Error\r
---*/  \r
+--*/\r
 {\r
   if (IsUSBKeyboardBufferEmpty (KeyboardBuffer)) {\r
     return EFI_DEVICE_ERROR;\r
@@ -1022,16 +1022,16 @@ SetKeyLED (
   IN  USB_KB_DEV    *UsbKeyboardDevice\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Sets USB Keyboard LED state.\r
-    \r
+\r
   Arguments:\r
     UsbKeyboardDevice - The USB_KB_DEV instance.\r
-  \r
+\r
   Returns:\r
     EFI_SUCCESS - Success\r
---*/  \r
+--*/\r
 {\r
   LED_MAP Led;\r
   UINT8   ReportId;\r
@@ -1041,7 +1041,7 @@ SetKeyLED (
   //\r
   Led.NumLock   = (UINT8) UsbKeyboardDevice->NumLockOn;\r
   Led.CapsLock  = (UINT8) UsbKeyboardDevice->CapsOn;\r
-  Led.ScrollLock = (UINT8) UsbKeyboardDevice->ScrollOn;  \r
+  Led.ScrollLock = (UINT8) UsbKeyboardDevice->ScrollOn;\r
   Led.Resrvd    = 0;\r
 \r
   ReportId      = 0;\r
@@ -1067,17 +1067,17 @@ USBKeyboardRepeatHandler (
   IN    VOID         *Context\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Timer handler for Repeat Key timer.\r
-    \r
+\r
   Arguments:\r
     Event   - The Repeat Key event.\r
     Context - Points to the USB_KB_DEV instance.\r
-    \r
+\r
   Returns:\r
-  \r
---*/    \r
+\r
+--*/\r
 {\r
   USB_KB_DEV  *UsbKeyboardDevice;\r
 \r
@@ -1115,17 +1115,17 @@ USBKeyboardRecoveryHandler (
   IN    VOID         *Context\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
     Timer handler for Delayed Recovery timer.\r
-    \r
+\r
   Arguments:\r
     Event   -  The Delayed Recovery event.\r
     Context -  Points to the USB_KB_DEV instance.\r
-    \r
+\r
   Returns:\r
-  \r
---*/    \r
+\r
+--*/\r
 {\r
 \r
   USB_KB_DEV          *UsbKeyboardDevice;\r