]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
Clean up the Ps2keyboardDxe module
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / Ps2KbdTextIn.c
index cc4ce812f111935bb5df2ab56a00be495b6b359b..49245c6496834a94f35615f954e4e41292df78c4 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
-  PS/2 Keyboard  driver\r
-  Routines that support SIMPLE_TEXT_IN protocol\r
+  Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces\r
+  provided by Ps2KbdCtrller.c.\r
 \r
 Copyright (c) 2006 - 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -16,66 +16,89 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Ps2Keyboard.h"\r
 \r
-//\r
-// function declarations\r
-//\r
+/**\r
+  Check keyboard for given key value\r
+  \r
+  @param  This  Point to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
+  \r
+  @retval EFI_SUCCESS   success check keyboard value\r
+  @retval !EFI_SUCCESS  Fail to get char from keyboard\r
+**/\r
 EFI_STATUS\r
-EFIAPI\r
-KeyboardEfiReset (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  IN  BOOLEAN                         ExtendedVerification\r
-  );\r
+KeyboardCheckForKey (\r
+  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
+  )\r
+{\r
+  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-KeyboardReadKeyStroke (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
-  OUT EFI_INPUT_KEY                   *Key\r
-  );\r
+  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
 \r
-VOID\r
-EFIAPI\r
-KeyboardWaitForKey (\r
-  IN  EFI_EVENT               Event,\r
-  IN  VOID                    *Context\r
-  );\r
+  //\r
+  // If ready to read next key, check it\r
+  //\r
+  if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {\r
+    return KeyGetchar (ConsoleIn);\r
+  }\r
 \r
-EFI_STATUS\r
-KeyboardCheckForKey (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
-  );\r
+  return EFI_SUCCESS;\r
+}\r
 \r
 /**\r
-  @param RegsiteredData    - A pointer to a buffer that is filled in with the keystroke \r
-                      state data for the key that was registered.\r
-  @param InputData         - A pointer to a buffer that is filled in with the keystroke \r
-                      state data for the key that was pressed.\r
+  Judge whether is a registed key\r
+\r
+  @param RegsiteredData       A pointer to a buffer that is filled in with the keystroke \r
+                              state data for the key that was registered.\r
+  @param InputData            A pointer to a buffer that is filled in with the keystroke \r
+                              state data for the key that was pressed.\r
 \r
-  @retval TRUE              - Key be pressed matches a registered key.\r
-  @retval FALSE             - Match failed. \r
+  @retval TRUE                Key be pressed matches a registered key.\r
+  @retval FLASE               Match failed. \r
   \r
 **/\r
 BOOLEAN\r
 IsKeyRegistered (\r
   IN EFI_KEY_DATA  *RegsiteredData,\r
   IN EFI_KEY_DATA  *InputData\r
-  );\r
+  )\r
+\r
+{\r
+  ASSERT (RegsiteredData != NULL && InputData != NULL);\r
+  \r
+  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
+      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
+    return FALSE;  \r
+  }      \r
+  \r
+  //\r
+  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
+  //\r
+  if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
+      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
+    return FALSE;    \r
+  }   \r
+  if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
+      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
+    return FALSE;    \r
+  }     \r
+  \r
+  return TRUE;\r
+\r
+}\r
 \r
 /**\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
   \r
-    @param ConsoleInDev          Ps2 Keyboard private structure\r
-    @param KeyData               A pointer to a buffer that is filled in with the keystroke \r
-                            state data for the key that was pressed.\r
+    @param ConsoleInDev          Ps2 Keyboard private structure\r
+    @param KeyData               A pointer to a buffer that is filled in with the keystroke \r
+                                 state data for the key that was pressed.\r
 \r
   \r
-    @retval EFI_SUCCESS           - The keystroke information was returned.\r
-    @retval EFI_NOT_READY         - There was no keystroke data availiable.\r
-    @retval EFI_DEVICE_ERROR      - The keystroke information was not returned due to \r
-                            hardware errors.\r
-    @retval EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+    @retval EFI_SUCCESS             The keystroke information was returned.\r
+    @retval EFI_NOT_READY           There was no keystroke data availiable.\r
+    @retval EFI_DEVICE_ERROR        The keystroke information was not returned due to \r
+                                    hardware errors.\r
+    @retval EFI_INVALID_PARAMETER   KeyData is NULL.                        \r
 \r
 **/\r
 EFI_STATUS\r
@@ -90,6 +113,7 @@ KeyboardReadKeyStrokeWorker (
   LIST_ENTRY                            *Link;\r
   KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;\r
   EFI_KEY_DATA                          OriginalKeyData;\r
+  \r
   if (KeyData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -111,6 +135,7 @@ KeyboardReadKeyStrokeWorker (
     gBS->RestoreTPL (OldTpl);\r
     return EFI_NOT_READY;\r
   }\r
+  \r
   CopyMem (&KeyData->Key, &ConsoleInDev->Key, sizeof (EFI_INPUT_KEY));\r
 \r
   ConsoleInDev->Key.ScanCode    = SCAN_NULL;          \r
@@ -128,9 +153,9 @@ KeyboardReadKeyStrokeWorker (
   if (ConsoleInDev->Ctrled) {\r
     if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) {\r
       if (ConsoleInDev->CapsLock) {\r
-        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1);\r
+        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + L'A' - 1);\r
       } else {\r
-        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1);\r
+        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + L'a' - 1);\r
       } \r
     }\r
   }\r
@@ -153,11 +178,9 @@ KeyboardReadKeyStrokeWorker (
 }\r
 \r
 /**\r
-  logic reset keyboard\r
-  Implement SIMPLE_TEXT_IN.Reset()\r
-  Perform 8042 controller and keyboard initialization\r
+  Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset()\r
 \r
-  @param This    Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
+  @param This                 Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
   @param ExtendedVerification Indicate that the driver may perform a more \r
                               exhaustive verification operation of the device during \r
                               reset, now this par is ignored in this driver    \r
@@ -237,8 +260,7 @@ KeyboardEfiReset (
 }\r
 \r
 /**\r
-  Implement SIMPLE_TEXT_IN.ReadKeyStroke().\r
-  Retrieve key values for driver user.\r
+  Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().\r
 \r
   @param This    Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
   @param Key     The output buffer for key value \r
@@ -314,74 +336,6 @@ KeyboardWaitForKey (
   return ;\r
 }\r
 \r
-/**\r
-  Check keyboard for given key value\r
-  \r
-  @param  This  Point to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
-  \r
-  @retval EFI_SUCCESS success check keyboard value\r
-**/\r
-EFI_STATUS\r
-KeyboardCheckForKey (\r
-  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
-  )\r
-{\r
-  KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
-\r
-  ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // If ready to read next key, check it\r
-  //\r
-  if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {\r
-    return KeyGetchar (ConsoleIn);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Judge whether is a registed key\r
-\r
-  @param RegsiteredData    - A pointer to a buffer that is filled in with the keystroke \r
-                      state data for the key that was registered.\r
-  @param InputData         - A pointer to a buffer that is filled in with the keystroke \r
-                      state data for the key that was pressed.\r
-\r
-  @retval TRUE              - Key be pressed matches a registered key.\r
-  @retval FLASE             - Match failed. \r
-  \r
-**/\r
-BOOLEAN\r
-IsKeyRegistered (\r
-  IN EFI_KEY_DATA  *RegsiteredData,\r
-  IN EFI_KEY_DATA  *InputData\r
-  )\r
-\r
-{\r
-  ASSERT (RegsiteredData != NULL && InputData != NULL);\r
-  \r
-  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
-      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
-    return FALSE;  \r
-  }      \r
-  \r
-  //\r
-  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
-  //\r
-  if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
-      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
-    return FALSE;    \r
-  }   \r
-  if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
-      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
-    return FALSE;    \r
-  }     \r
-  \r
-  return TRUE;\r
-\r
-}\r
-\r
 /**\r
   Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
   Signal the event if there is key available\r
@@ -408,11 +362,11 @@ KeyboardWaitForKeyEx (
 /**\r
   Reset the input device and optionaly run diagnostics\r
 \r
-  @param This                 - Protocol instance pointer.\r
-  @param ExtendedVerification - Driver may perform diagnostics on reset.\r
+  @param This                     Protocol instance pointer.\r
+  @param ExtendedVerification     Driver may perform diagnostics on reset.\r
 \r
-  @retval EFI_SUCCESS           - The device was reset.\r
-  @retval EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+  @retval EFI_SUCCESS             The device was reset.\r
+  @retval EFI_DEVICE_ERROR        The device is not functioning properly and could \r
                                   not be reset.\r
 \r
 **/\r
@@ -456,15 +410,15 @@ KeyboardEfiResetEx (
     be used to test for existance of a keystroke via WaitForEvent () call.\r
 \r
 \r
-    @param This       - Protocol instance pointer.\r
-    @param KeyData    - A pointer to a buffer that is filled in with the keystroke \r
-                 state data for the key that was pressed.\r
+    @param This         Protocol instance pointer.\r
+    @param KeyData      A pointer to a buffer that is filled in with the keystroke \r
+                        state data for the key that was pressed.\r
 \r
-    @retval EFI_SUCCESS           The keystroke information was returned.\r
-    @retval EFI_NOT_READY         There was no keystroke data availiable.\r
-    @retval EFI_DEVICE_ERROR      The keystroke information was not returned due to \r
-                            hardware errors.\r
-    @retval EFI_INVALID_PARAMETER KeyData is NULL.                        \r
+    @retval EFI_SUCCESS           The keystroke information was returned.\r
+    @retval EFI_NOT_READY         There was no keystroke data availiable.\r
+    @retval EFI_DEVICE_ERROR      The keystroke information was not returned due to \r
+                                  hardware errors.\r
+    @retval EFI_INVALID_PARAMETER KeyData is NULL.                        \r
 \r
 **/\r
 EFI_STATUS\r
@@ -489,15 +443,15 @@ KeyboardReadKeyStrokeEx (
 /**\r
   Set certain state for the input device.\r
 \r
-  @param This              - Protocol instance pointer.\r
-  @param KeyToggleState    - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
-                        state for the input device.\r
+  @param This               Protocol instance pointer.\r
+  @param KeyToggleState     A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
+                            state for the input device.\r
 \r
-  @retval EFI_SUCCESS           The device state was set successfully.\r
-  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could \r
-                            not have the setting adjusted.\r
-  @retval EFI_UNSUPPORTED       The device does not have the ability to set its state.\r
-  @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.                       \r
+  @retval EFI_SUCCESS           The device state was set successfully.\r
+  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could \r
+                                not have the setting adjusted.\r
+  @retval EFI_UNSUPPORTED       The device does not have the ability to set its state.\r
+  @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.                       \r
 \r
 **/   \r
 EFI_STATUS\r
@@ -571,16 +525,16 @@ Exit:
 /**\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 KeyNotificationFunction - Points to the function to be called when the key \r
-                              sequence is typed specified by KeyData.                        \r
-    @param NotifyHandle            - Points to the unique handle assigned to the registered notification.                          \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 KeyNotificationFunction    Points to the function to be called when the key \r
+                                      sequence is typed specified by KeyData.                        \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
-    @retval EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necesssary data structures.\r
-    @retval EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.                       \r
+    @retval EFI_SUCCESS               The notification function was registered successfully.\r
+    @retval EFI_OUT_OF_RESOURCES      Unable to allocate resources for necesssary data structures.\r
+    @retval EFI_INVALID_PARAMETER     KeyData or NotifyHandle or KeyNotificationFunction is NULL.                       \r
                               \r
 **/   \r
 EFI_STATUS\r
@@ -659,12 +613,12 @@ Exit:
 /**\r
     Remove a registered notification function from a particular keystroke.\r
 \r
-    @param This                    - Protocol instance pointer.    \r
-    @param NotificationHandle      - The handle of the notification function being unregistered.\r
+    @param This                       Protocol instance pointer.    \r
+    @param NotificationHandle         The handle of the notification function being unregistered.\r
 \r
   \r
-    @retval EFI_SUCCESS             - The notification function was unregistered successfully.\r
-    @retval EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.\r
+    @retval EFI_SUCCESS               The notification function was unregistered successfully.\r
+    @retval EFI_INVALID_PARAMETER     The NotificationHandle is invalid.\r
                               \r
 **/   \r
 EFI_STATUS\r