]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
apply for doxgen format.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / TerminalConIn.c
index a4ad034989ceaa13906bd941ffb89ec82f2a510b..404e46e0e73d38a07372cfeb46c114df2244a7e0 100644 (file)
@@ -1,14 +1,14 @@
 /**@file\r
   Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.\r
-  \r
-Copyright (c) 2006 - 2007 Intel Corporation. <BR>\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
+Copyright (c) 2006 - 2007, Intel Corporation. <BR>\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
 **/\r
 \r
@@ -24,20 +24,20 @@ ReadKeyStrokeWorker (
 /*++\r
 \r
   Routine Description:\r
-    Reads the next keystroke from the input device. The WaitForKey Event can \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
     TerminalDevice        - Terminal driver private structure\r
-    KeyData               - A pointer to a buffer that is filled in with the keystroke \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
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to\r
                             hardware errors.\r
-    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+    EFI_INVALID_PARAMETER - KeyData is NULL.\r
 \r
 --*/\r
 {\r
@@ -47,7 +47,7 @@ ReadKeyStrokeWorker (
 \r
   if (KeyData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  }  \r
+  }\r
 \r
   //\r
   // Initialize *Key to nonsense value.\r
@@ -72,12 +72,12 @@ ReadKeyStrokeWorker (
   //\r
   for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {\r
     CurrentNotify = CR (\r
-                      Link, \r
-                      TERMINAL_CONSOLE_IN_EX_NOTIFY, \r
-                      NotifyEntry, \r
+                      Link,\r
+                      TERMINAL_CONSOLE_IN_EX_NOTIFY,\r
+                      NotifyEntry,\r
                       TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
                       );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { \r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
       CurrentNotify->KeyNotificationFn (KeyData);\r
     }\r
   }\r
@@ -95,25 +95,25 @@ TerminalConInReset (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().\r
-    This driver only perform dependent serial device reset regardless of \r
+    This driver only perform dependent serial device reset regardless of\r
     the value of ExtendeVerification\r
-  \r
+\r
   Arguments:\r
-  \r
+\r
     This - Indicates the calling context.\r
-    \r
+\r
     ExtendedVerification - Skip by this driver.\r
-        \r
+\r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS\r
-       The reset operation succeeds.   \r
-    \r
+       The reset operation succeeds.\r
+\r
     EFI_DEVICE_ERROR\r
       The dependent serial port reset fails.\r
-                \r
+\r
 --*/\r
 {\r
   EFI_STATUS    Status;\r
@@ -158,27 +158,27 @@ TerminalConInReadKeyStroke (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().\r
-      \r
+\r
   Arguments:\r
-  \r
+\r
     This - Indicates the calling context.\r
-    \r
+\r
     Key  - A pointer to a buffer that is filled in with the keystroke\r
-        information for the key that was sent from terminal.        \r
-        \r
+        information for the key that was sent from terminal.\r
+\r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS\r
       The keystroke information is returned successfully.\r
-       \r
+\r
     EFI_NOT_READY\r
       There is no keystroke data available.\r
\r
+\r
     EFI_DEVICE_ERROR\r
       The dependent serial device encounters error.\r
-                \r
+\r
 --*/\r
 {\r
   TERMINAL_DEV  *TerminalDevice;\r
@@ -213,24 +213,24 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke \r
+  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke\r
                       state data for the key that was registered.\r
-  InputData         - A pointer to a buffer that is filled in with the keystroke \r
+  InputData         - 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
   TRUE              - Key be pressed matches a registered key.\r
-  FLASE             - Match failed. \r
-  \r
+  FLASE             - Match failed.\r
+\r
 --*/\r
 {\r
   ASSERT (RegsiteredData != NULL && InputData != NULL);\r
-  \r
+\r
   if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
       (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
-    return FALSE;  \r
-  }      \r
-  \r
+    return FALSE;\r
+  }\r
+\r
   return TRUE;\r
 }\r
 \r
@@ -243,24 +243,24 @@ TerminalConInWaitForKeyEx (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Event notification function for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
-    Signal the event if there is key available     \r
-  \r
+    Signal the event if there is key available\r
+\r
   Arguments:\r
-  \r
+\r
     Event - Indicates the event that invoke this function.\r
-    \r
+\r
     Context - Indicates the calling context.\r
-        \r
+\r
   Returns:\r
-  \r
+\r
     N/A\r
-                \r
+\r
 --*/\r
 {\r
   TERMINAL_DEV            *TerminalDevice;\r
-  \r
+\r
   TerminalDevice  = TERMINAL_CON_IN_EX_DEV_FROM_THIS (Context);\r
 \r
   TerminalConInWaitForKey (Event, &TerminalDevice->SimpleInput);\r
@@ -288,7 +288,7 @@ TerminalConInResetEx (
 \r
   Returns:\r
     EFI_SUCCESS           - The device was reset.\r
-    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could\r
                             not be reset.\r
 \r
 --*/\r
@@ -304,7 +304,7 @@ TerminalConInResetEx (
   }\r
 \r
   return EFI_SUCCESS;\r
-  \r
+\r
 }\r
 \r
 EFI_STATUS\r
@@ -316,20 +316,20 @@ TerminalConInReadKeyStrokeEx (
 /*++\r
 \r
   Routine Description:\r
-    Reads the next keystroke from the input device. The WaitForKey Event can \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
+    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
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to\r
                             hardware errors.\r
-    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+    EFI_INVALID_PARAMETER - KeyData is NULL.\r
 \r
 --*/\r
 {\r
@@ -337,7 +337,7 @@ TerminalConInReadKeyStrokeEx (
 \r
   if (KeyData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  }  \r
+  }\r
 \r
   TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);\r
 \r
@@ -358,17 +358,17 @@ TerminalConInSetState (
 \r
   Arguments:\r
     This                  - Protocol instance pointer.\r
-    KeyToggleState        - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
+    KeyToggleState        - A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
                             state for the input device.\r
-                          \r
-  Returns:                \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
+    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
+    EFI_INVALID_PARAMETER - KeyToggleState is NULL.\r
 \r
---*/   \r
+--*/\r
 {\r
   if (KeyToggleState == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -392,24 +392,24 @@ TerminalConInRegisterKeyNotify (
 \r
   Arguments:\r
     This                    - Protocol instance pointer.\r
-    KeyData                 - A pointer to a buffer that is filled in with the keystroke \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
+    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
+    EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.\r
+\r
+--*/\r
 {\r
   EFI_STATUS                      Status;\r
   TERMINAL_DEV                    *TerminalDevice;\r
   TERMINAL_CONSOLE_IN_EX_NOTIFY   *NewNotify;\r
   LIST_ENTRY                      *Link;\r
-  TERMINAL_CONSOLE_IN_EX_NOTIFY   *CurrentNotify;  \r
+  TERMINAL_CONSOLE_IN_EX_NOTIFY   *CurrentNotify;\r
 \r
   if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -422,14 +422,14 @@ TerminalConInRegisterKeyNotify (
   //\r
   for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {\r
     CurrentNotify = CR (\r
-                      Link, \r
-                      TERMINAL_CONSOLE_IN_EX_NOTIFY, \r
-                      NotifyEntry, \r
+                      Link,\r
+                      TERMINAL_CONSOLE_IN_EX_NOTIFY,\r
+                      NotifyEntry,\r
                       TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
                       );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { \r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
       if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r
-        *NotifyHandle = CurrentNotify->NotifyHandle;        \r
+        *NotifyHandle = CurrentNotify->NotifyHandle;\r
         return EFI_SUCCESS;\r
       }\r
     }\r
@@ -437,19 +437,19 @@ TerminalConInRegisterKeyNotify (
 \r
   //\r
   // Allocate resource to save the notification function\r
-  //  \r
+  //\r
   NewNotify = (TERMINAL_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (TERMINAL_CONSOLE_IN_EX_NOTIFY));\r
   if (NewNotify == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
 \r
-  NewNotify->Signature         = TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE;     \r
+  NewNotify->Signature         = TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE;\r
   NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
   CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));\r
   InsertTailList (&TerminalDevice->NotifyList, &NewNotify->NotifyEntry);\r
   //\r
   // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE\r
-  //  \r
+  //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &NewNotify->NotifyHandle,\r
                   &gSimpleTextInExNotifyGuid,\r
@@ -457,7 +457,7 @@ TerminalConInRegisterKeyNotify (
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
-  *NotifyHandle                = NewNotify->NotifyHandle;  \r
+  *NotifyHandle                = NewNotify->NotifyHandle;\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -474,15 +474,15 @@ TerminalConInUnregisterKeyNotify (
     Remove a registered notification function from a particular keystroke.\r
 \r
   Arguments:\r
-    This                    - Protocol instance pointer.    \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
+    EFI_NOT_FOUND           - Can not find the matching entry in database.\r
+\r
+--*/\r
 {\r
   EFI_STATUS                      Status;\r
   TERMINAL_DEV                    *TerminalDevice;\r
@@ -491,8 +491,8 @@ TerminalConInUnregisterKeyNotify (
 \r
   if (NotificationHandle == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  } \r
-  \r
+  }\r
+\r
   Status = gBS->OpenProtocol (\r
                   NotificationHandle,\r
                   &gSimpleTextInExNotifyGuid,\r
@@ -509,16 +509,16 @@ TerminalConInUnregisterKeyNotify (
 \r
   for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {\r
     CurrentNotify = CR (\r
-                      Link, \r
-                      TERMINAL_CONSOLE_IN_EX_NOTIFY, \r
-                      NotifyEntry, \r
+                      Link,\r
+                      TERMINAL_CONSOLE_IN_EX_NOTIFY,\r
+                      NotifyEntry,\r
                       TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
                       );\r
     if (CurrentNotify->NotifyHandle == NotificationHandle) {\r
       //\r
       // Remove the notification function from NotifyList and free resources\r
       //\r
-      RemoveEntryList (&CurrentNotify->NotifyEntry);      \r
+      RemoveEntryList (&CurrentNotify->NotifyEntry);\r
       Status = gBS->UninstallMultipleProtocolInterfaces (\r
                       CurrentNotify->NotifyHandle,\r
                       &gSimpleTextInExNotifyGuid,\r
@@ -526,12 +526,12 @@ TerminalConInUnregisterKeyNotify (
                       NULL\r
                       );\r
       ASSERT_EFI_ERROR (Status);\r
-      gBS->FreePool (CurrentNotify);            \r
+      gBS->FreePool (CurrentNotify);\r
       return EFI_SUCCESS;\r
     }\r
   }\r
-  \r
-  return EFI_NOT_FOUND;  \r
+\r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 \r
@@ -541,7 +541,7 @@ TranslateRawDataToEfiKey (
   )\r
 /*++\r
     Step1: Turn raw data into Unicode (according to different encode).\r
-    Step2: Translate Unicode into key information. \r
+    Step2: Translate Unicode into key information.\r
     (according to different terminal standard).\r
 --*/\r
 {\r
@@ -579,20 +579,20 @@ TerminalConInWaitForKey (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event\r
-    Signal the event if there is key available     \r
-  \r
+    Signal the event if there is key available\r
+\r
   Arguments:\r
-  \r
+\r
     Event - Indicates the event that invoke this function.\r
-    \r
+\r
     Context - Indicates the calling context.\r
-        \r
+\r
   Returns:\r
-  \r
+\r
     N/A\r
-                \r
+\r
 --*/\r
 {\r
   //\r
@@ -613,23 +613,23 @@ TerminalConInCheckForKey (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Check for a pending key in the Efi Key FIFO or Serial device buffer.\r
-  \r
+\r
   Arguments:\r
-  \r
+\r
     This - Indicates the calling context.\r
-        \r
+\r
   Returns:\r
-  \r
+\r
     EFI_SUCCESS\r
-       There is key pending.   \r
-    \r
+       There is key pending.\r
+\r
     EFI_NOT_READY\r
       There is no key pending.\r
-      \r
+\r
     EFI_DEVICE_ERROR\r
-                \r
+\r
 --*/\r
 {\r
   EFI_STATUS              Status;\r
@@ -741,7 +741,7 @@ GetOneKeyFromSerial (
     Get one key out of serial buffer.\r
     If serial buffer is empty, return EFI_NOT_READY;\r
     if reading serial buffer encounter error, returns EFI_DEVICE_ERROR;\r
-    if reading serial buffer successfully, put the fetched key to \r
+    if reading serial buffer successfully, put the fetched key to\r
     the parameter "Input", and return EFI_SUCCESS.\r
 --*/\r
 {\r
@@ -1130,33 +1130,33 @@ UnicodeToEfiKey (
   )\r
 /*++\r
   Routine Description:\r
-  \r
+\r
     Converts a stream of Unicode characters from a terminal input device into EFI Keys that\r
     can be read through the Simple Input Protocol.  The table below shows the keyboard\r
-    input mappings that this function supports.  If the ESC sequence listed in one of the \r
+    input mappings that this function supports.  If the ESC sequence listed in one of the\r
     columns is presented, then it is translated into the coorespoding EFI Scan Code.  If a\r
     matching sequence is not found, then the raw key strokes are converted into EFI Keys.\r
-    \r
-    2 seconds are allowed for an ESC sequence to be completed.  If the ESC sequence is not \r
-    completed in 2 seconds, then the raw key strokes of the partial ESC sequence are \r
+\r
+    2 seconds are allowed for an ESC sequence to be completed.  If the ESC sequence is not\r
+    completed in 2 seconds, then the raw key strokes of the partial ESC sequence are\r
     converted into EFI Keys.\r
-    \r
-    There is one special input sequence that will force the system to reset.  \r
+\r
+    There is one special input sequence that will force the system to reset.\r
     This is ESC R ESC r ESC R.\r
-  \r
+\r
   Arguments:\r
 \r
     TerminaDevice : The terminal device to use to translate raw input into EFI Keys\r
-        \r
+\r
   Returns:\r
 \r
     None\r
 \r
 Symbols used in table below\r
 ===========================\r
-  ESC = 0x1B  \r
-  CSI = 0x9B  \r
-  DEL = 0x7f  \r
+  ESC = 0x1B\r
+  CSI = 0x9B\r
+  DEL = 0x7f\r
   ^   = CTRL\r
 \r
 +=========+======+===========+==========+==========+\r
@@ -1167,7 +1167,7 @@ Symbols used in table below
 | NULL    | 0x00 |           |          |          |\r
 | UP      | 0x01 | ESC [ A   | ESC [ A  | ESC [ A  |\r
 | DOWN    | 0x02 | ESC [ B   | ESC [ B  | ESC [ B  |\r
-| RIGHT   | 0x03 | ESC [ C   | ESC [ C  | ESC [ C  | \r
+| RIGHT   | 0x03 | ESC [ C   | ESC [ C  | ESC [ C  |\r
 | LEFT    | 0x04 | ESC [ D   | ESC [ D  | ESC [ D  |\r
 | HOME    | 0x05 | ESC [ H   | ESC h    | ESC [ H  |\r
 | END     | 0x06 | ESC [ F   | ESC k    | ESC [ K  |\r
@@ -1204,7 +1204,7 @@ ESC R ESC r ESC R = Reset System
   UINT16              UnicodeChar;\r
   EFI_INPUT_KEY       Key;\r
   BOOLEAN             SetDefaultResetState;\r
-  \r
+\r
   TimerStatus = gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);\r
 \r
   if (!EFI_ERROR (TimerStatus)) {\r
@@ -1213,7 +1213,7 @@ ESC R ESC r ESC R = Reset System
   }\r
 \r
   while (!IsUnicodeFiFoEmpty(TerminalDevice)) {\r
-    \r
+\r
     if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {\r
       //\r
       // Check to see if the 2 second timer has expired\r
@@ -1252,71 +1252,71 @@ ESC R ESC r ESC R = Reset System
       }\r
 \r
       Key.ScanCode = SCAN_NULL;\r
-      \r
-      if (TerminalDevice->TerminalType == VT100PlusType || \r
+\r
+      if (TerminalDevice->TerminalType == VT100PlusType ||\r
           TerminalDevice->TerminalType == VTUTF8Type) {\r
         switch (UnicodeChar) {\r
-        case '1': \r
-          Key.ScanCode = SCAN_F1;         \r
+        case '1':\r
+          Key.ScanCode = SCAN_F1;\r
           break;\r
-        case '2': \r
-          Key.ScanCode = SCAN_F2;         \r
+        case '2':\r
+          Key.ScanCode = SCAN_F2;\r
           break;\r
-        case '3': \r
-          Key.ScanCode = SCAN_F3;         \r
+        case '3':\r
+          Key.ScanCode = SCAN_F3;\r
           break;\r
-        case '4': \r
-          Key.ScanCode = SCAN_F4;         \r
+        case '4':\r
+          Key.ScanCode = SCAN_F4;\r
           break;\r
-        case '5': \r
-          Key.ScanCode = SCAN_F5;         \r
+        case '5':\r
+          Key.ScanCode = SCAN_F5;\r
           break;\r
-        case '6': \r
-          Key.ScanCode = SCAN_F6;         \r
+        case '6':\r
+          Key.ScanCode = SCAN_F6;\r
           break;\r
-        case '7': \r
-          Key.ScanCode = SCAN_F7;         \r
+        case '7':\r
+          Key.ScanCode = SCAN_F7;\r
           break;\r
-        case '8': \r
-          Key.ScanCode = SCAN_F8;         \r
+        case '8':\r
+          Key.ScanCode = SCAN_F8;\r
           break;\r
-        case '9': \r
-          Key.ScanCode = SCAN_F9;         \r
+        case '9':\r
+          Key.ScanCode = SCAN_F9;\r
           break;\r
-        case '0': \r
-          Key.ScanCode = SCAN_F10;        \r
+        case '0':\r
+          Key.ScanCode = SCAN_F10;\r
           break;\r
         case '!':\r
           Key.ScanCode = SCAN_F11;\r
           break;\r
         case '@':\r
           Key.ScanCode = SCAN_F12;\r
-          break;          \r
-        case 'h': \r
-          Key.ScanCode = SCAN_HOME;       \r
           break;\r
-        case 'k': \r
-          Key.ScanCode = SCAN_END;        \r
+        case 'h':\r
+          Key.ScanCode = SCAN_HOME;\r
           break;\r
-        case '+': \r
-          Key.ScanCode = SCAN_INSERT;     \r
+        case 'k':\r
+          Key.ScanCode = SCAN_END;\r
           break;\r
-        case '-': \r
-          Key.ScanCode = SCAN_DELETE;     \r
+        case '+':\r
+          Key.ScanCode = SCAN_INSERT;\r
           break;\r
-        case '/': \r
-          Key.ScanCode = SCAN_PAGE_DOWN;  \r
+        case '-':\r
+          Key.ScanCode = SCAN_DELETE;\r
           break;\r
-        case '?': \r
-          Key.ScanCode = SCAN_PAGE_UP;    \r
-          break;        \r
-        default :                                 \r
+        case '/':\r
+          Key.ScanCode = SCAN_PAGE_DOWN;\r
+          break;\r
+        case '?':\r
+          Key.ScanCode = SCAN_PAGE_UP;\r
+          break;\r
+        default :\r
           break;\r
         }\r
       }\r
-      \r
+\r
       switch (UnicodeChar) {\r
-      case 'R': \r
+      case 'R':\r
         if (TerminalDevice->ResetState == RESET_STATE_DEFAULT) {\r
           TerminalDevice->ResetState = RESET_STATE_ESC_R;\r
           SetDefaultResetState = FALSE;\r
@@ -1325,14 +1325,14 @@ ESC R ESC r ESC R = Reset System
         }\r
         Key.ScanCode = SCAN_NULL;\r
         break;\r
-      case 'r': \r
+      case 'r':\r
         if (TerminalDevice->ResetState == RESET_STATE_ESC_R) {\r
           TerminalDevice->ResetState = RESET_STATE_ESC_R_ESC_r;\r
           SetDefaultResetState = FALSE;\r
         }\r
         Key.ScanCode = SCAN_NULL;\r
         break;\r
-      default : \r
+      default :\r
         break;\r
       }\r
 \r
@@ -1357,40 +1357,40 @@ ESC R ESC r ESC R = Reset System
       TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
 \r
       Key.ScanCode = SCAN_NULL;\r
-      \r
+\r
       if (TerminalDevice->TerminalType == VT100Type) {\r
         switch (UnicodeChar) {\r
-        case 'P': \r
-          Key.ScanCode = SCAN_F1;         \r
+        case 'P':\r
+          Key.ScanCode = SCAN_F1;\r
           break;\r
-        case 'Q': \r
-          Key.ScanCode = SCAN_F2;         \r
+        case 'Q':\r
+          Key.ScanCode = SCAN_F2;\r
           break;\r
-        case 'w': \r
-          Key.ScanCode = SCAN_F3;         \r
+        case 'w':\r
+          Key.ScanCode = SCAN_F3;\r
           break;\r
-        case 'x': \r
-          Key.ScanCode = SCAN_F4;         \r
+        case 'x':\r
+          Key.ScanCode = SCAN_F4;\r
           break;\r
-        case 't': \r
-          Key.ScanCode = SCAN_F5;         \r
+        case 't':\r
+          Key.ScanCode = SCAN_F5;\r
           break;\r
-        case 'u': \r
-          Key.ScanCode = SCAN_F6;         \r
+        case 'u':\r
+          Key.ScanCode = SCAN_F6;\r
           break;\r
-        case 'q': \r
-          Key.ScanCode = SCAN_F7;         \r
+        case 'q':\r
+          Key.ScanCode = SCAN_F7;\r
           break;\r
-        case 'r': \r
-          Key.ScanCode = SCAN_F8;         \r
+        case 'r':\r
+          Key.ScanCode = SCAN_F8;\r
           break;\r
-        case 'p': \r
-          Key.ScanCode = SCAN_F9;         \r
+        case 'p':\r
+          Key.ScanCode = SCAN_F9;\r
           break;\r
-        case 'M': \r
-          Key.ScanCode = SCAN_F10;        \r
+        case 'M':\r
+          Key.ScanCode = SCAN_F10;\r
           break;\r
-        default :                                 \r
+        default :\r
           break;\r
         }\r
       }\r
@@ -1408,127 +1408,127 @@ ESC R ESC r ESC R = Reset System
       break;\r
 \r
     case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:\r
-    \r
+\r
       TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
-      \r
+\r
       Key.ScanCode = SCAN_NULL;\r
-      \r
+\r
       if (TerminalDevice->TerminalType == PcAnsiType    ||\r
           TerminalDevice->TerminalType == VT100Type     ||\r
-          TerminalDevice->TerminalType == VT100PlusType || \r
+          TerminalDevice->TerminalType == VT100PlusType ||\r
           TerminalDevice->TerminalType == VTUTF8Type) {\r
         switch (UnicodeChar) {\r
-        case 'A': \r
-          Key.ScanCode = SCAN_UP;         \r
+        case 'A':\r
+          Key.ScanCode = SCAN_UP;\r
           break;\r
-        case 'B': \r
-          Key.ScanCode = SCAN_DOWN;       \r
+        case 'B':\r
+          Key.ScanCode = SCAN_DOWN;\r
           break;\r
-        case 'C': \r
-          Key.ScanCode = SCAN_RIGHT;      \r
+        case 'C':\r
+          Key.ScanCode = SCAN_RIGHT;\r
           break;\r
-        case 'D': \r
-          Key.ScanCode = SCAN_LEFT;       \r
+        case 'D':\r
+          Key.ScanCode = SCAN_LEFT;\r
           break;\r
-        case 'H': \r
+        case 'H':\r
           if (TerminalDevice->TerminalType == PcAnsiType ||\r
               TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_HOME;       \r
+            Key.ScanCode = SCAN_HOME;\r
           }\r
           break;\r
-        case 'F': \r
+        case 'F':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_END;\r
           }\r
           break;\r
-        case 'K': \r
+        case 'K':\r
           if (TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_END;        \r
+            Key.ScanCode = SCAN_END;\r
           }\r
           break;\r
-        case 'L':   \r
-        case '@': \r
+        case 'L':\r
+        case '@':\r
           if (TerminalDevice->TerminalType == PcAnsiType ||\r
               TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_INSERT;     \r
+            Key.ScanCode = SCAN_INSERT;\r
           }\r
           break;\r
-        case 'X': \r
+        case 'X':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_DELETE;\r
           }\r
           break;\r
-        case 'P': \r
+        case 'P':\r
           if (TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_DELETE;        \r
+            Key.ScanCode = SCAN_DELETE;\r
           } else if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F4;\r
           }\r
           break;\r
-        case 'I': \r
+        case 'I':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_PAGE_UP;\r
           }\r
-          break;        \r
-        case 'V': \r
+          break;\r
+        case 'V':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F10;\r
-          }  \r
-        case '?': \r
+          }\r
+        case '?':\r
           if (TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_PAGE_UP;        \r
+            Key.ScanCode = SCAN_PAGE_UP;\r
           }\r
           break;\r
-        case 'G': \r
+        case 'G':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_PAGE_DOWN;\r
           }\r
-          break;        \r
-        case 'U': \r
+          break;\r
+        case 'U':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F9;\r
           }\r
-        case '/': \r
+        case '/':\r
           if (TerminalDevice->TerminalType == VT100Type) {\r
-            Key.ScanCode = SCAN_PAGE_DOWN;        \r
+            Key.ScanCode = SCAN_PAGE_DOWN;\r
           }\r
           break;\r
-        case 'M': \r
+        case 'M':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F1;\r
           }\r
-          break;        \r
-        case 'N': \r
+          break;\r
+        case 'N':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F2;\r
           }\r
-          break;        \r
-        case 'O': \r
+          break;\r
+        case 'O':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F3;\r
           }\r
-          break;        \r
-        case 'Q': \r
+          break;\r
+        case 'Q':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F5;\r
           }\r
-          break;        \r
-        case 'R': \r
+          break;\r
+        case 'R':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F6;\r
           }\r
-          break;        \r
-        case 'S': \r
+          break;\r
+        case 'S':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F7;\r
           }\r
-          break;        \r
-        case 'T': \r
+          break;\r
+        case 'T':\r
           if (TerminalDevice->TerminalType == PcAnsiType) {\r
             Key.ScanCode = SCAN_F8;\r
           }\r
-          break;        \r
-        default : \r
+          break;\r
+        default :\r
           break;\r
         }\r
       }\r
@@ -1545,7 +1545,7 @@ ESC R ESC r ESC R = Reset System
 \r
       break;\r
 \r
-    \r
+\r
     default:\r
       //\r
       // Invalid state. This should never happen.\r
@@ -1564,7 +1564,7 @@ ESC R ESC r ESC R = Reset System
     if (UnicodeChar == CSI) {\r
       TerminalDevice->InputState = INPUT_STATE_CSI;\r
     }\r
-    \r
+\r
     if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {\r
       Status = gBS->SetTimer(\r
                       TerminalDevice->TwoSecondTimeOut,\r