]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
Report the setting variable failure to platform through the status code when core...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.h
index eaa4a74e27134c2385042784e2f00dc9b2426035..d393acbc2073e1b7d9408058dd6676e95595b066 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Header file for Terminal driver.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2014, 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
@@ -16,15 +16,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define _TERMINAL_H_\r
 \r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
+\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/PcAnsi.h>\r
+#include <Guid/StatusCodeDataTypeVariable.h>\r
+\r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/SerialIo.h>\r
-#include <Guid/GlobalVariable.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/SimpleTextIn.h>\r
 #include <Protocol/SimpleTextInEx.h>\r
-#include <Guid/HotPlugDevice.h>\r
-#include <Guid/PcAnsi.h>\r
+\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
@@ -59,13 +62,19 @@ typedef struct {
   EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];\r
 } EFI_KEY_FIFO;\r
 \r
-#define TERMINAL_DEV_SIGNATURE  EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')\r
+typedef struct {\r
+  UINTN   Columns;\r
+  UINTN   Rows;\r
+} TERMINAL_CONSOLE_MODE_DATA;\r
+\r
+#define KEYBOARD_TIMER_INTERVAL         200000  // 0.02s\r
+\r
+#define TERMINAL_DEV_SIGNATURE  SIGNATURE_32 ('t', 'm', 'n', 'l')\r
 \r
-#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'e', 'n')\r
+#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 'e', 'n')\r
 \r
 typedef struct _TERMINAL_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
@@ -79,11 +88,13 @@ typedef struct {
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL      SimpleInput;\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     SimpleTextOutput;\r
   EFI_SIMPLE_TEXT_OUTPUT_MODE         SimpleTextOutputMode;\r
+  TERMINAL_CONSOLE_MODE_DATA          *TerminalConsoleModeData;\r
   UINTN                               SerialInTimeOut;\r
-  RAW_DATA_FIFO                       RawFiFo;\r
-  UNICODE_FIFO                        UnicodeFiFo;\r
-  EFI_KEY_FIFO                        EfiKeyFiFo;\r
+  RAW_DATA_FIFO                       *RawFiFo;\r
+  UNICODE_FIFO                        *UnicodeFiFo;\r
+  EFI_KEY_FIFO                        *EfiKeyFiFo;\r
   EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
+  EFI_EVENT                           TimerEvent;\r
   EFI_EVENT                           TwoSecondTimeOut;\r
   UINT32                              InputState;\r
   UINT32                              ResetState;\r
@@ -109,7 +120,7 @@ typedef struct {
 \r
 #define RESET_STATE_DEFAULT               0x00\r
 #define RESET_STATE_ESC_R                 0x01\r
-#define RESET_STATE_ESC_R_ESC_r           0x02\r
+#define RESET_STATE_ESC_R_ESC_R           0x02\r
 \r
 #define TERMINAL_CON_IN_DEV_FROM_THIS(a)  CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)\r
 #define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)\r
@@ -132,15 +143,6 @@ typedef union {
 #define CCAP                      0x43\r
 #define DCAP                      0x44\r
 \r
-#define MODE0_COLUMN_COUNT        80\r
-#define MODE0_ROW_COUNT           25\r
-\r
-#define MODE1_COLUMN_COUNT        80\r
-#define MODE1_ROW_COUNT           50\r
-\r
-#define MODE2_COLUMN_COUNT        100\r
-#define MODE2_ROW_COUNT           31\r
-\r
 #define BACKSPACE                 8\r
 #define ESC                       27\r
 #define CSI                       0x9B\r
@@ -164,8 +166,6 @@ extern EFI_DRIVER_BINDING_PROTOCOL   gTerminalDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL   gTerminalComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL  gTerminalComponentName2;\r
 \r
-extern EFI_GUID                      gSimpleTextInExNotifyGuid;\r
-\r
 /**\r
   The user Entry Point for module Terminal. The user code starts with this function.\r
 \r
@@ -181,8 +181,7 @@ EFIAPI
 InitializeTerminal (\r
   IN EFI_HANDLE         ImageHandle,\r
   IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().\r
@@ -192,10 +191,8 @@ InitializeTerminal (
   @param  This                     Indicates the calling context.\r
   @param  ExtendedVerification     Skip by this driver.\r
 \r
-  @return EFI_SUCCESS\r
-  @return The reset operation succeeds.\r
-  @return EFI_DEVICE_ERROR\r
-  @return The dependent serial port reset fails.\r
+  @retval EFI_SUCCESS              The reset operation succeeds.\r
+  @retval EFI_DEVICE_ERROR         The dependent serial port reset fails.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -203,24 +200,20 @@ EFIAPI
 TerminalConInReset (\r
   IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    *This,\r
   IN  BOOLEAN                           ExtendedVerification\r
-  )\r
-;\r
+  );\r
 \r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().\r
 \r
-  @param  This                     Indicates the calling context.\r
-  @param  Key                      A pointer to a buffer that is filled in with the\r
-                                   keystroke information for the key that was sent\r
-                                   from terminal.\r
+  @param  This                Indicates the calling context.\r
+  @param  Key                 A pointer to a buffer that is filled in with the\r
+                              keystroke information for the key that was sent\r
+                              from terminal.\r
 \r
-  @return EFI_SUCCESS\r
-  @return The keystroke information is returned successfully.\r
-  @return EFI_NOT_READY\r
-  @return There is no keystroke data available.\r
-  @return EFI_DEVICE_ERROR\r
-  @return The dependent serial device encounters error.\r
+  @retval EFI_SUCCESS         The keystroke information is returned successfully.\r
+  @retval EFI_NOT_READY       There is no keystroke data available.\r
+  @retval EFI_DEVICE_ERROR    The dependent serial device encounters error.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -228,11 +221,10 @@ EFIAPI
 TerminalConInReadKeyStroke (\r
   IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This,\r
   OUT EFI_INPUT_KEY                   *Key\r
-  )\r
-;\r
-\r
+  );\r
 \r
 /**\r
+  Check if the key already has been registered.\r
 \r
   @param  RegsiteredData           A pointer to a buffer that is filled in with the\r
                                    keystroke state data for the key that was\r
@@ -242,15 +234,14 @@ TerminalConInReadKeyStroke (
                                    pressed.\r
 \r
   @retval TRUE                     Key be pressed matches a registered key.\r
-  @retval FLASE                    Match failed.\r
+  @retval FALSE                    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
 /**\r
   Event notification function for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
@@ -259,23 +250,20 @@ IsKeyRegistered (
   @param  Event                    Indicates the event that invoke this function.\r
   @param  Context                  Indicates the calling context.\r
 \r
-  @return none.\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
 TerminalConInWaitForKeyEx (\r
   IN  EFI_EVENT       Event,\r
   IN  VOID            *Context\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // Simple Text Input Ex protocol prototypes\r
 //\r
 \r
 /**\r
-  Reset the input device and optionaly run diagnostics\r
+  Reset the input device and optionally run diagnostics\r
 \r
   @param  This                     Protocol instance pointer.\r
   @param  ExtendedVerification     Driver may perform diagnostics on reset.\r
@@ -290,12 +278,11 @@ EFIAPI
 TerminalConInResetEx (\r
   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
   IN BOOLEAN                            ExtendedVerification\r
-  )\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
+  be used to test for existence of a keystroke via WaitForEvent () call.\r
 \r
   @param  This                     Protocol instance pointer.\r
   @param  KeyData                  A pointer to a buffer that is filled in with the\r
@@ -303,7 +290,7 @@ TerminalConInResetEx (
                                    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_NOT_READY            There was no keystroke data available.\r
   @retval EFI_DEVICE_ERROR         The keystroke information was not returned due\r
                                    to hardware errors.\r
   @retval EFI_INVALID_PARAMETER    KeyData is NULL.\r
@@ -314,8 +301,7 @@ EFIAPI
 TerminalConInReadKeyStrokeEx (\r
   IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
   OUT EFI_KEY_DATA                      *KeyData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Set certain state for the input device.\r
@@ -337,8 +323,7 @@ EFIAPI
 TerminalConInSetState (\r
   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
   IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Register a notification function for a particular keystroke for the input device.\r
@@ -365,9 +350,8 @@ TerminalConInRegisterKeyNotify (
   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
+  OUT VOID                              **NotifyHandle\r
+  );\r
 \r
 /**\r
   Remove a registered notification function from a particular keystroke.\r
@@ -386,9 +370,8 @@ EFI_STATUS
 EFIAPI\r
 TerminalConInUnregisterKeyNotify (\r
   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_HANDLE                         NotificationHandle\r
-  )\r
-;\r
+  IN VOID                               *NotificationHandle\r
+  );\r
 \r
 /**\r
   Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event\r
@@ -397,16 +380,13 @@ TerminalConInUnregisterKeyNotify (
   @param  Event                    Indicates the event that invoke this function.\r
   @param  Context                  Indicates the calling context.\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
 TerminalConInWaitForKey (\r
   IN  EFI_EVENT     Event,\r
   IN  VOID          *Context\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
@@ -419,10 +399,8 @@ TerminalConInWaitForKey (
                                 exhaustive verification operation of the device\r
                                 during reset.\r
 \r
-  @return EFI_SUCCESS\r
-  @return The reset operation succeeds.\r
-  @return EFI_DEVICE_ERROR\r
-  @return The terminal is not functioning correctly or the serial port reset fails.\r
+  @retval EFI_SUCCESS           The reset operation succeeds.\r
+  @retval EFI_DEVICE_ERROR      The terminal is not functioning correctly or the serial port reset fails.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -430,8 +408,7 @@ EFIAPI
 TerminalConOutReset (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *This,\r
   IN  BOOLEAN                            ExtendedVerification\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
@@ -442,11 +419,11 @@ TerminalConOutReset (
   @param  WString                 The Null-terminated Unicode string to be displayed\r
                                   on the terminal screen.\r
 \r
-  @return EFI_SUCCESS             The string is output successfully.\r
-  @return EFI_DEVICE_ERROR        The serial port fails to send the string out.\r
-  @return EFI_WARN_UNKNOWN_GLYPH  Indicates that some of the characters in the Unicode string could not\r
+  @retval EFI_SUCCESS             The string is output successfully.\r
+  @retval EFI_DEVICE_ERROR        The serial port fails to send the string out.\r
+  @retval EFI_WARN_UNKNOWN_GLYPH  Indicates that some of the characters in the Unicode string could not\r
                                   be rendered and are skipped.\r
-  @return EFI_UNSUPPORTED\r
+  @retval EFI_UNSUPPORTED         If current display mode is out of range.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -454,8 +431,7 @@ EFIAPI
 TerminalConOutOutputString (\r
   IN   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  CHAR16                            *WString\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
@@ -467,8 +443,8 @@ TerminalConOutOutputString (
   @param  This              Indicates the calling context.\r
   @param  WString           The Null-terminated Unicode string to be tested.\r
 \r
-  @return EFI_SUCCESS       The terminal is capable of rendering the output string.\r
-  @return EFI_UNSUPPORTED   Some of the characters in the Unicode string cannot be rendered.\r
+  @retval EFI_SUCCESS       The terminal is capable of rendering the output string.\r
+  @retval EFI_UNSUPPORTED   Some of the characters in the Unicode string cannot be rendered.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -476,8 +452,7 @@ EFIAPI
 TerminalConOutTestString (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  CHAR16                           *WString\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
@@ -491,9 +466,9 @@ TerminalConOutTestString (
   @param Columns     The returned columns of the requested mode.\r
   @param Rows        The returned rows of the requested mode.\r
 \r
-  @return EFI_SUCCESS       The requested mode information is returned.\r
-  @return EFI_UNSUPPORTED   The mode number is not valid.\r
-  @return EFI_DEVICE_ERROR\r
+  @retval EFI_SUCCESS       The requested mode information is returned.\r
+  @retval EFI_UNSUPPORTED   The mode number is not valid.\r
+  @retval EFI_DEVICE_ERROR\r
 \r
 **/\r
 EFI_STATUS\r
@@ -503,8 +478,7 @@ TerminalConOutQueryMode (
   IN  UINTN                            ModeNumber,\r
   OUT UINTN                            *Columns,\r
   OUT UINTN                            *Rows\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUT.SetMode().\r
@@ -514,10 +488,10 @@ TerminalConOutQueryMode (
   @param This          Indicates the calling context.\r
   @param ModeNumber    The text mode to set.\r
 \r
-  @return EFI_SUCCESS       The requested text mode is set.\r
-  @return EFI_DEVICE_ERROR  The requested text mode cannot be set \r
+  @retval EFI_SUCCESS       The requested text mode is set.\r
+  @retval EFI_DEVICE_ERROR  The requested text mode cannot be set\r
                             because of serial device error.\r
-  @return EFI_UNSUPPORTED   The text mode number is not valid.\r
+  @retval EFI_UNSUPPORTED   The text mode number is not valid.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -525,8 +499,7 @@ EFIAPI
 TerminalConOutSetMode (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  UINTN                            ModeNumber\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
@@ -535,9 +508,9 @@ TerminalConOutSetMode (
   @param Attribute   The attribute to set. Only bit0..6 are valid, all other bits\r
                      are undefined and must be zero.\r
 \r
-  @return EFI_SUCCESS        The requested attribute is set.\r
-  @return EFI_DEVICE_ERROR   The requested attribute cannot be set due to serial port error.\r
-  @return EFI_UNSUPPORTED    The attribute requested is not defined by EFI spec.\r
+  @retval EFI_SUCCESS        The requested attribute is set.\r
+  @retval EFI_DEVICE_ERROR   The requested attribute cannot be set due to serial port error.\r
+  @retval EFI_UNSUPPORTED    The attribute requested is not defined by EFI spec.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -545,8 +518,7 @@ EFIAPI
 TerminalConOutSetAttribute (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  UINTN                            Attribute\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
@@ -555,17 +527,16 @@ TerminalConOutSetAttribute (
 \r
   @param This     Indicates the calling context.\r
 \r
-  @return EFI_SUCCESS       The operation completed successfully.\r
-  @return EFI_DEVICE_ERROR  The terminal screen cannot be cleared due to serial port error.\r
-  @return EFI_UNSUPPORTED   The terminal is not in a valid display mode.\r
+  @retval EFI_SUCCESS       The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR  The terminal screen cannot be cleared due to serial port error.\r
+  @retval EFI_UNSUPPORTED   The terminal is not in a valid display mode.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 TerminalConOutClearScreen (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
@@ -574,9 +545,9 @@ TerminalConOutClearScreen (
   @param Column    The row to set cursor to.\r
   @param Row       The column to set cursor to.\r
 \r
-  @return EFI_SUCCESS       The operation completed successfully.\r
-  @return EFI_DEVICE_ERROR  The request fails due to serial port error.\r
-  @return EFI_UNSUPPORTED   The terminal is not in a valid text mode, or the cursor position\r
+  @retval EFI_SUCCESS       The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR  The request fails due to serial port error.\r
+  @retval EFI_UNSUPPORTED   The terminal is not in a valid text mode, or the cursor position\r
                             is invalid for current mode.\r
 \r
 **/\r
@@ -586,8 +557,7 @@ TerminalConOutSetCursorPosition (
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  UINTN                            Column,\r
   IN  UINTN                            Row\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
@@ -597,8 +567,8 @@ TerminalConOutSetCursorPosition (
   @param Visible   If TRUE, the cursor is set to be visible,\r
                    If FALSE, the cursor is set to be invisible.\r
 \r
-  @return EFI_SUCCESS      The request is valid.\r
-  @return EFI_UNSUPPORTED  The terminal does not support cursor hidden.\r
+  @retval EFI_SUCCESS      The request is valid.\r
+  @retval EFI_UNSUPPORTED  The terminal does not support cursor hidden.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -606,17 +576,45 @@ EFIAPI
 TerminalConOutEnableCursor (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
   IN  BOOLEAN                          Visible\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Test to see if this driver supports Controller.\r
 \r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+  @retval other               This driver does not support this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 TerminalDriverBindingSupported (\r
   IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
+  IN EFI_HANDLE                     ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   );\r
 \r
+/**\r
+  Start this driver on Controller by opening a Serial IO protocol,\r
+  reading Device Path, and creating a child handle with a Simple Text In,\r
+  Simple Text In Ex and Simple Text Out protocol, and device path protocol.\r
+  And store Console Device Environment Variables.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          This driver is added to Controller.\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on Controller.\r
+  @retval other                This driver does not support this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 TerminalDriverBindingStart (\r
@@ -625,6 +623,22 @@ TerminalDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   );\r
 \r
+\r
+/**\r
+  Stop this driver on Controller by closing Simple Text In, Simple Text\r
+  In Ex, Simple Text Out protocol, and removing parent device path from\r
+  Console Device Environment Variables.\r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  Controller        Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       This driver is removed Controller.\r
+  @retval other             This driver could not be removed from this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 TerminalDriverBindingStop (\r
@@ -634,6 +648,20 @@ TerminalDriverBindingStop (
   IN  EFI_HANDLE                     *ChildHandleBuffer\r
   );\r
 \r
+/**\r
+  Free notify functions list.\r
+\r
+  @param  ListHead               The list head\r
+\r
+  @retval EFI_SUCCESS            Free the notify list successfully.\r
+  @retval EFI_INVALID_PARAMETER  ListHead is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+TerminalFreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  );\r
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the driver.\r
 \r
@@ -654,7 +682,7 @@ TerminalDriverBindingStop (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
-                                in RFC 3066 or ISO 639-2 language code format.\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
 \r
   @param  DriverName[out]       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
@@ -719,7 +747,7 @@ TerminalComponentNameGetDriverName (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
-                                RFC 3066 or ISO 639-2 language code format.\r
+                                RFC 4646 or ISO 639-2 language code format.\r
 \r
   @param  ControllerName[out]   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
@@ -733,7 +761,7 @@ TerminalComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -770,25 +798,30 @@ TerminalComponentNameGetControllerName (
 \r
   @param  This                     Indicates the calling context.\r
 \r
-  @return EFI_SUCCESS\r
-  @return There is key pending.\r
-  @return EFI_NOT_READY\r
-  @return There is no key pending.\r
-  @return EFI_DEVICE_ERROR\r
+  @retval EFI_SUCCESS              There is key pending.\r
+  @retval EFI_NOT_READY            There is no key pending.\r
+  @retval EFI_DEVICE_ERROR         If Serial IO is not attached to serial device.\r
 \r
 **/\r
 EFI_STATUS\r
 TerminalConInCheckForKey (\r
   IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *This\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Update terminal device path in Console Device Environment Variables.\r
+\r
+  @param  VariableName           The Console Device Environment Variable.\r
+  @param  ParentDevicePath       The terminal device path to be updated.\r
 \r
+  @return None.\r
+\r
+**/\r
 VOID\r
 TerminalUpdateConsoleDevVariable (\r
   IN CHAR16                    *VariableName,\r
   IN EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Remove console device variable.\r
@@ -796,62 +829,31 @@ TerminalUpdateConsoleDevVariable (
   @param  VariableName           A pointer to the variable name.\r
   @param  ParentDevicePath       A pointer to the parent device path.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 TerminalRemoveConsoleDevVariable (\r
   IN CHAR16                    *VariableName,\r
   IN EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
-  Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
-  buffer, and the size of the buffer. On failure return NULL.\r
+  Build termial device path according to terminal type.\r
 \r
-  @param  Name                   String part of EFI variable name\r
-  @param  VendorGuid             GUID part of EFI variable name\r
-  @param  VariableSize           Returns the size of the EFI variable that was read\r
+  @param  TerminalType           The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.\r
+  @param  ParentDevicePath       Parent device path.\r
+  @param  TerminalDevicePath     Returned terminal device path, if building successfully.\r
 \r
-  @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-  @return Caller is repsoncible freeing the buffer.\r
-  @retval NULL                   Variable was not read\r
+  @retval EFI_UNSUPPORTED        Terminal does not belong to the supported type.\r
+  @retval EFI_OUT_OF_RESOURCES   Generate terminal device path failed.\r
+  @retval EFI_SUCCESS            Build terminal device path successfully.\r
 \r
 **/\r
-VOID                                *\r
-TerminalGetVariableAndSize (\r
-  IN  CHAR16              *Name,\r
-  IN  EFI_GUID            *VendorGuid,\r
-  OUT UINTN               *VariableSize\r
-  )\r
-;\r
-\r
 EFI_STATUS\r
 SetTerminalDevicePath (\r
   IN  UINT8                       TerminalType,\r
   IN  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL    **TerminalDevicePath\r
-  )\r
-;\r
-\r
-VOID\r
-InitializeRawFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
-\r
-VOID\r
-InitializeUnicodeFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
-\r
-VOID\r
-InitializeEfiKeyFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Get one key out of serial buffer.\r
@@ -859,9 +861,9 @@ InitializeEfiKeyFiFo (
   @param  SerialIo           Serial I/O protocl attached to the serial device.\r
   @param  Input              The fetched key.\r
 \r
-  @return EFI_NOT_READY      If serial buffer is empty.\r
-  @return EFI_DEVICE_ERROR   If reading serial buffer encounter error.\r
-  @return EFI_SUCCESS        If reading serial buffer successfully, put\r
+  @retval EFI_NOT_READY      If serial buffer is empty.\r
+  @retval EFI_DEVICE_ERROR   If reading serial buffer encounter error.\r
+  @retval EFI_SUCCESS        If reading serial buffer successfully, put\r
                              the fetched key to the parameter output.\r
 \r
 **/\r
@@ -869,8 +871,7 @@ EFI_STATUS
 GetOneKeyFromSerial (\r
   EFI_SERIAL_IO_PROTOCOL  *SerialIo,\r
   UINT8                   *Input\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Insert one byte raw data into the Raw Data FIFO.\r
@@ -878,8 +879,8 @@ GetOneKeyFromSerial (
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Input                The key will be input.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If Raw Data buffer is full before key insertion,\r
+  @retval TRUE                 If insert successfully.\r
+  @retval FALSE                If Raw Data buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
@@ -887,8 +888,7 @@ BOOLEAN
 RawFiFoInsertOneKey (\r
   TERMINAL_DEV  *TerminalDevice,\r
   UINT8         Input\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Remove one pre-fetched key out of the Raw Data FIFO.\r
@@ -896,46 +896,43 @@ RawFiFoInsertOneKey (
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Output               The key will be removed.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If Raw Data FIFO buffer is empty before remove operation.\r
+  @retval TRUE                 If insert successfully.\r
+  @retval FALSE                If Raw Data FIFO buffer is empty before remove operation.\r
 \r
 **/\r
 BOOLEAN\r
 RawFiFoRemoveOneKey (\r
   TERMINAL_DEV  *TerminalDevice,\r
   UINT8         *Output\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether Raw Data FIFO buffer is empty.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If Raw Data FIFO buffer is empty.\r
-  @return FLASE                If Raw Data FIFO buffer is not empty.\r
+  @retval TRUE                 If Raw Data FIFO buffer is empty.\r
+  @retval FALSE                If Raw Data FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
 IsRawFiFoEmpty (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether Raw Data FIFO buffer is full.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If Raw Data FIFO buffer is full.\r
-  @return FLASE                If Raw Data FIFO buffer is not full.\r
+  @retval TRUE                 If Raw Data FIFO buffer is full.\r
+  @retval FALSE                If Raw Data FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
 IsRawFiFoFull (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Insert one pre-fetched key into the FIFO buffer.\r
@@ -943,17 +940,16 @@ IsRawFiFoFull (
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Key                  The key will be input.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If FIFO buffer is full before key insertion,\r
+  @retval TRUE                 If insert successfully.\r
+  @retval FALSE                If FIFO buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
 BOOLEAN\r
 EfiKeyFiFoInsertOneKey (\r
   TERMINAL_DEV      *TerminalDevice,\r
-  EFI_INPUT_KEY     Key\r
-  )\r
-;\r
+  EFI_INPUT_KEY     *Key\r
+  );\r
 \r
 /**\r
   Remove one pre-fetched key out of the FIFO buffer.\r
@@ -961,46 +957,43 @@ EfiKeyFiFoInsertOneKey (
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Output               The key will be removed.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If FIFO buffer is empty before remove operation.\r
+  @retval TRUE                 If insert successfully.\r
+  @retval FALSE                If FIFO buffer is empty before remove operation.\r
 \r
 **/\r
 BOOLEAN\r
 EfiKeyFiFoRemoveOneKey (\r
   TERMINAL_DEV  *TerminalDevice,\r
   EFI_INPUT_KEY *Output\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether FIFO buffer is empty.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If FIFO buffer is empty.\r
-  @return FLASE                If FIFO buffer is not empty.\r
+  @retval TRUE                 If FIFO buffer is empty.\r
+  @retval FALSE                If FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
 IsEfiKeyFiFoEmpty (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether FIFO buffer is full.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If FIFO buffer is full.\r
-  @return FLASE                If FIFO buffer is not full.\r
+  @retval TRUE                 If FIFO buffer is full.\r
+  @retval FALSE                If FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
 IsEfiKeyFiFoFull (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Insert one pre-fetched key into the Unicode FIFO buffer.\r
@@ -1008,8 +1001,8 @@ IsEfiKeyFiFoFull (
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Input                The key will be input.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If Unicode FIFO buffer is full before key insertion,\r
+  @retval TRUE                 If insert successfully.\r
+  @retval FALSE                If Unicode FIFO buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
@@ -1017,151 +1010,347 @@ BOOLEAN
 UnicodeFiFoInsertOneKey (\r
   TERMINAL_DEV      *TerminalDevice,\r
   UINT16            Input\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Remove one pre-fetched key out of the Unicode FIFO buffer.\r
+  The caller should guarantee that Unicode FIFO buffer is not empty \r
+  by IsUnicodeFiFoEmpty ().\r
 \r
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Output               The key will be removed.\r
 \r
-  @return TRUE                 If insert successfully.\r
-  @return FLASE                If Unicode FIFO buffer is empty before remove operation.\r
-\r
 **/\r
-BOOLEAN\r
+VOID\r
 UnicodeFiFoRemoveOneKey (\r
   TERMINAL_DEV  *TerminalDevice,\r
   UINT16        *Output\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether Unicode FIFO buffer is empty.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If Unicode FIFO buffer is empty.\r
-  @return FLASE                If Unicode FIFO buffer is not empty.\r
+  @retval TRUE                 If Unicode FIFO buffer is empty.\r
+  @retval FALSE                If Unicode FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
 IsUnicodeFiFoEmpty (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Clarify whether Unicode FIFO buffer is full.\r
 \r
   @param  TerminalDevice       Terminal driver private structure\r
 \r
-  @return TRUE                 If Unicode FIFO buffer is full.\r
-  @return FLASE                If Unicode FIFO buffer is not full.\r
+  @retval TRUE                 If Unicode FIFO buffer is full.\r
+  @retval FALSE                If Unicode FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
 IsUnicodeFiFoFull (\r
   TERMINAL_DEV  *TerminalDevice\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Count Unicode FIFO buffer.\r
 \r
+  @param  TerminalDevice       Terminal driver private structure\r
+\r
+  @return The count in bytes of Unicode FIFO.\r
+\r
+**/\r
 UINT8\r
 UnicodeFiFoGetKeyCount (\r
   TERMINAL_DEV    *TerminalDevice\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Translate raw data into Unicode (according to different encode), and\r
+  translate Unicode into key information. (according to different standard).\r
 \r
+  @param  TerminalDevice       Terminal driver private structure.\r
+\r
+**/\r
 VOID\r
 TranslateRawDataToEfiKey (\r
   IN  TERMINAL_DEV      *TerminalDevice\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // internal functions for PC ANSI\r
 //\r
+\r
+/**\r
+  Translate all raw data in the Raw FIFI into unicode, and insert\r
+  them into Unicode FIFO.\r
+\r
+  @param TerminalDevice          The terminal device.\r
+\r
+**/\r
 VOID\r
 AnsiRawDataToUnicode (\r
-  IN  TERMINAL_DEV    *PcAnsiDevice\r
-  )\r
-;\r
+  IN  TERMINAL_DEV    *TerminalDevice\r
+  );\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.\r
+\r
+  The table below shows the keyboard input mappings that this function supports.\r
+  If the ESC sequence listed in one of the columns is presented, then it is translated\r
+  into the coorespoding EFI Scan Code.  If a matching sequence is not found, then the raw\r
+  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
+  converted into EFI Keys.\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
+  Symbols used in table below\r
+  ===========================\r
+    ESC = 0x1B\r
+    CSI = 0x9B\r
+    DEL = 0x7f\r
+    ^   = CTRL\r
+  +=========+======+===========+==========+==========+\r
+  |         | EFI  | UEFI 2.0  |          |          |\r
+  |         | Scan |           |  VT100+  |          |\r
+  |   KEY   | Code |  PC ANSI  |  VTUTF8  |   VT100  |\r
+  +=========+======+===========+==========+==========+\r
+  | 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
+  | 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
+  | INSERT  | 0x07 | ESC [ @   | ESC +    | ESC [ @  |\r
+  |         |      | ESC [ L   |          | ESC [ L  |\r
+  | DELETE  | 0x08 | ESC [ X   | ESC -    | ESC [ P  |\r
+  | PG UP   | 0x09 | ESC [ I   | ESC ?    | ESC [ V  |\r
+  |         |      |           |          | ESC [ ?  |\r
+  | PG DOWN | 0x0A | ESC [ G   | ESC /    | ESC [ U  |\r
+  |         |      |           |          | ESC [ /  |\r
+  | F1      | 0x0B | ESC [ M   | ESC 1    | ESC O P  |\r
+  | F2      | 0x0C | ESC [ N   | ESC 2    | ESC O Q  |\r
+  | F3      | 0x0D | ESC [ O   | ESC 3    | ESC O w  |\r
+  | F4      | 0x0E | ESC [ P   | ESC 4    | ESC O x  |\r
+  | F5      | 0x0F | ESC [ Q   | ESC 5    | ESC O t  |\r
+  | F6      | 0x10 | ESC [ R   | ESC 6    | ESC O u  |\r
+  | F7      | 0x11 | ESC [ S   | ESC 7    | ESC O q  |\r
+  | F8      | 0x12 | ESC [ T   | ESC 8    | ESC O r  |\r
+  | F9      | 0x13 | ESC [ U   | ESC 9    | ESC O p  |\r
+  | F10     | 0x14 | ESC [ V   | ESC 0    | ESC O M  |\r
+  | Escape  | 0x17 | ESC       | ESC      | ESC      |\r
+  | F11     | 0x15 |           | ESC !    |          |\r
+  | F12     | 0x16 |           | ESC @    |          |\r
+  +=========+======+===========+==========+==========+\r
+\r
+  Special Mappings\r
+  ================\r
+  ESC R ESC r ESC R = Reset System\r
+\r
+\r
+  @param TerminalDevice   The terminal device to use to translate raw input into EFI Keys\r
 \r
+**/\r
 VOID\r
 UnicodeToEfiKey (\r
-  IN  TERMINAL_DEV    *PcAnsiDevice\r
-  )\r
-;\r
+  IN  TERMINAL_DEV    *TerminalDevice\r
+  );\r
 \r
+/**\r
+  Check if input string is valid Ascii string, valid EFI control characters\r
+  or valid text graphics.\r
+\r
+  @param  TerminalDevice          The terminal device.\r
+  @param  WString                 The input string.\r
+\r
+  @retval EFI_UNSUPPORTED         If not all input characters are valid.\r
+  @retval EFI_SUCCESS             If all input characters are valid.\r
+\r
+**/\r
 EFI_STATUS\r
 AnsiTestString (\r
   IN  TERMINAL_DEV    *TerminalDevice,\r
   IN  CHAR16          *WString\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // internal functions for VTUTF8\r
 //\r
+\r
+/**\r
+  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
+  and insert them into Unicode FIFO.\r
+\r
+  @param VtUtf8Device          The terminal device.\r
+\r
+**/\r
 VOID\r
 VTUTF8RawDataToUnicode (\r
   IN  TERMINAL_DEV    *VtUtf8Device\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Check if input string is valid VT-UTF8 string.\r
+\r
+  @param  TerminalDevice          The terminal device.\r
+  @param  WString                 The input string.\r
+\r
+  @retval EFI_SUCCESS             If all input characters are valid.\r
 \r
+**/\r
 EFI_STATUS\r
 VTUTF8TestString (\r
   IN  TERMINAL_DEV    *TerminalDevice,\r
   IN  CHAR16          *WString\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Translate one Unicode character into VT-UTF8 characters.\r
+\r
+  UTF8 Encoding Table\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
+        0-7             |     0x0000 - 0x007F      |     00000000 0xxxxxxx        |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF        |     00000xxx xxxxxxxx       |   110xxxxx 10xxxxxx\r
+       12-16           |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+\r
 \r
+  @param  Unicode          Unicode character need translating.\r
+  @param  Utf8Char         Return VT-UTF8 character set.\r
+  @param  ValidBytes       The count of valid VT-UTF8 characters. If\r
+                           ValidBytes is zero, no valid VT-UTF8 returned.\r
+\r
+**/\r
 VOID\r
 UnicodeToUtf8 (\r
   IN  CHAR16      Unicode,\r
   OUT UTF8_CHAR   *Utf8Char,\r
   OUT UINT8       *ValidBytes\r
-  )\r
-;\r
+  );\r
 \r
+/**\r
+  Get one valid VT-UTF8 characters set from Raw Data FIFO.\r
+\r
+  @param  Utf8Device          The terminal device.\r
+  @param  Utf8Char            Returned valid VT-UTF8 characters set.\r
+  @param  ValidBytes          The count of returned VT-VTF8 characters.\r
+                              If ValidBytes is zero, no valid VT-UTF8 returned.\r
+\r
+**/\r
 VOID\r
 GetOneValidUtf8Char (\r
   IN  TERMINAL_DEV      *Utf8Device,\r
   OUT UTF8_CHAR         *Utf8Char,\r
   OUT UINT8             *ValidBytes\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Translate VT-UTF8 characters into one Unicode character.\r
+\r
+  UTF8 Encoding Table\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
+        0-7             |     0x0000 - 0x007F      |     00000000 0xxxxxxx        |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF        |     00000xxx xxxxxxxx       |   110xxxxx 10xxxxxx\r
+       12-16           |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+\r
 \r
+  @param  Utf8Char         VT-UTF8 character set needs translating.\r
+  @param  ValidBytes       The count of valid VT-UTF8 characters.\r
+  @param  UnicodeChar      Returned unicode character.\r
+\r
+**/\r
 VOID\r
 Utf8ToUnicode (\r
   IN  UTF8_CHAR       Utf8Char,\r
   IN  UINT8           ValidBytes,\r
   OUT CHAR16          *UnicodeChar\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // functions for boxdraw unicode\r
 //\r
+\r
+/**\r
+  Detects if a Unicode char is for Box Drawing text graphics.\r
+\r
+  @param  Graphic      Unicode char to test.\r
+  @param  PcAnsi       Optional pointer to return PCANSI equivalent of\r
+                       Graphic.\r
+  @param  Ascii        Optional pointer to return ASCII equivalent of\r
+                       Graphic.\r
+\r
+  @retval TRUE         If Graphic is a supported Unicode Box Drawing character.\r
+\r
+**/\r
 BOOLEAN\r
 TerminalIsValidTextGraphics (\r
   IN  CHAR16  Graphic,\r
   OUT CHAR8   *PcAnsi, OPTIONAL\r
   OUT CHAR8   *Ascii OPTIONAL\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Detects if a valid ASCII char.\r
 \r
+  @param  Ascii        An ASCII character.\r
+\r
+  @retval TRUE         If it is a valid ASCII character.\r
+  @retval FALSE        If it is not a valid ASCII character.\r
+\r
+**/\r
 BOOLEAN\r
 TerminalIsValidAscii (\r
   IN  CHAR16  Ascii\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Detects if a valid EFI control character.\r
 \r
+  @param  CharC        An input EFI Control character.\r
+\r
+  @retval TRUE         If it is a valid EFI control character.\r
+  @retval FALSE        If it is not a valid EFI control character.\r
+\r
+**/\r
 BOOLEAN\r
 TerminalIsValidEfiCntlChar (\r
   IN  CHAR16  CharC\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Check if the device supports hot-plug through its device path.\r
+\r
+  This function could be updated to check more types of Hot Plug devices.\r
+  Currently, it checks USB and PCCard device.\r
+\r
+  @param  DevicePath            Pointer to device's device path.\r
+\r
+  @retval TRUE                  The devcie is a hot-plug device\r
+  @retval FALSE                 The devcie is not a hot-plug device.\r
 \r
+**/\r
+BOOLEAN\r
+IsHotPlugDevice (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  );\r
+\r
+/**\r
+  Timer handler to poll the key from serial.\r
+\r
+  @param  Event                    Indicates the event that invoke this function.\r
+  @param  Context                  Indicates the calling context.\r
+**/\r
+VOID\r
+EFIAPI\r
+TerminalConInTimerHandler (\r
+  IN EFI_EVENT            Event,\r
+  IN VOID                 *Context\r
+  );\r
 #endif\r