]> git.proxmox.com Git - mirror_edk2.git/commitdiff
remove some internal functions and allocate some FIFO data structure instead of decla...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Feb 2009 07:25:00 +0000 (07:25 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Feb 2009 07:25:00 +0000 (07:25 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7416 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c

index 2e8ea670097f25cf448659e0b389cc5e12ca7bd9..92ec98a09fdc0b342729994b265d42ad90bfc0b1 100644 (file)
@@ -69,21 +69,11 @@ TERMINAL_DEV  mTerminalDevTemplate = {
     TRUE                                         // CursorVisible\r
   },\r
   0,  // SerialInTimeOut\r
-  {   // RawFiFo\r
-    0,\r
-    0,\r
-    { 0 }\r
-  },\r
-  {  // UnicodeFiFo\r
-    0,\r
-    0,\r
-    { 0 }\r
-  },\r
-  {  // EfiKeyFiFo\r
-    0,\r
-    0,\r
-    { {0} }\r
-  },\r
+\r
+  NULL, // RawFifo\r
+  NULL, // UnicodeFiFo\r
+  NULL, // EfiKeyFiFo\r
+\r
   NULL, // ControllerNameTable\r
   NULL, // TwoSecondTimeOut\r
   INPUT_STATE_DEFAULT,\r
@@ -424,12 +414,21 @@ TerminalDriverBindingStart (
     goto Error;\r
   }\r
   //\r
-  // initialize the FIFO buffer used for accommodating\r
-  // the pre-read pending characters\r
+  // Allocates and initializes the FIFO buffer to be zero, used for accommodating\r
+  // the pre-read pending characters.\r
   //\r
-  InitializeRawFiFo (TerminalDevice);\r
-  InitializeUnicodeFiFo (TerminalDevice);\r
-  InitializeEfiKeyFiFo (TerminalDevice);\r
+  TerminalDevice->RawFiFo     = AllocateZeroPool (sizeof (RAW_DATA_FIFO));\r
+  if (TerminalDevice->RawFiFo == NULL) {\r
+    goto Error;\r
+  }\r
+  TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));\r
+  if (TerminalDevice->UnicodeFiFo == NULL) {\r
+    goto Error;\r
+  }\r
+  TerminalDevice->EfiKeyFiFo  = AllocateZeroPool (sizeof (EFI_KEY_FIFO));\r
+  if (TerminalDevice->EfiKeyFiFo == NULL) {\r
+    goto Error;\r
+  }\r
 \r
   //\r
   // Set the timeout value of serial buffer for\r
@@ -704,6 +703,16 @@ Error:
 \r
       TerminalFreeNotifyList (&TerminalDevice->NotifyList);\r
 \r
+      if (TerminalDevice->RawFiFo != NULL) {\r
+        FreePool (TerminalDevice->RawFiFo);\r
+      }\r
+      if (TerminalDevice->UnicodeFiFo != NULL) {\r
+        FreePool (TerminalDevice->UnicodeFiFo);\r
+      }\r
+      if (TerminalDevice->EfiKeyFiFo != NULL) {\r
+        FreePool (TerminalDevice->EfiKeyFiFo);\r
+      }\r
+\r
       if (TerminalDevice->ControllerNameTable != NULL) {\r
         FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
       }\r
@@ -1279,58 +1288,6 @@ SetTerminalDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Initialize the Raw Data FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeRawFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-{\r
-  //\r
-  // Make the raw FIFO empty.\r
-  //\r
-  TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;\r
-}\r
-\r
-/**\r
-  Initialize the Unicode FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeUnicodeFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-{\r
-  //\r
-  // Make the unicode FIFO empty\r
-  //\r
-  TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;\r
-}\r
-\r
-/**\r
-  Initialize the EFI Key FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeEfiKeyFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  )\r
-{\r
-  //\r
-  // Make the efi key FIFO empty\r
-  //\r
-  TerminalDevice->EfiKeyFiFo.Head = TerminalDevice->EfiKeyFiFo.Tail;\r
-}\r
-\r
-\r
 /**\r
   The user Entry Point for module Terminal. The user code starts with this function.\r
 \r
index 6d7d4ceddd9d358558a2e0858d297816c9335408..b9f02932c2ccaf5787692cfd74888c8d44218612 100644 (file)
@@ -84,9 +84,9 @@ typedef struct {
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     SimpleTextOutput;\r
   EFI_SIMPLE_TEXT_OUTPUT_MODE         SimpleTextOutputMode;\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                           TwoSecondTimeOut;\r
   UINT32                              InputState;\r
@@ -491,7 +491,7 @@ TerminalConOutQueryMode (
   @param ModeNumber    The text mode to set.\r
 \r
   @retval EFI_SUCCESS       The requested text mode is set.\r
-  @retval EFI_DEVICE_ERROR  The requested text mode cannot be set \r
+  @retval EFI_DEVICE_ERROR  The requested text mode cannot be set\r
                             because of serial device error.\r
   @retval EFI_UNSUPPORTED   The text mode number is not valid.\r
 \r
@@ -581,7 +581,7 @@ TerminalConOutEnableCursor (
   );\r
 \r
 /**\r
-  Test to see if this driver supports Controller. \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
@@ -629,7 +629,7 @@ TerminalDriverBindingStart (
 /**\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
+  Console Device Environment Variables.\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  Controller        Handle of device to stop driver on\r
@@ -847,7 +847,7 @@ TerminalRemoveConsoleDevVariable (
   @param  VariableSize           Returns the size of the EFI variable that was read\r
 \r
   @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-          Caller is repsoncible freeing the buffer. If variable was not read, \r
+          Caller is repsoncible freeing the buffer. If variable was not read,\r
           NULL regturned.\r
 \r
 **/\r
@@ -877,39 +877,6 @@ SetTerminalDevicePath (
   OUT EFI_DEVICE_PATH_PROTOCOL    **TerminalDevicePath\r
   );\r
 \r
-/**\r
-  Initialize the Raw Data FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeRawFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  );\r
-\r
-/**\r
-  Initialize the Unicode FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeUnicodeFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  );\r
-\r
-/**\r
-  Initialize the EFI Key FIFO.\r
-\r
-  @param TerminalDevice          The terminal device.\r
-\r
-**/\r
-VOID\r
-InitializeEfiKeyFiFo (\r
-  IN  TERMINAL_DEV  *TerminalDevice\r
-  );\r
-\r
 /**\r
   Get one key out of serial buffer.\r
 \r
@@ -1125,8 +1092,8 @@ UnicodeFiFoGetKeyCount (
   );\r
 \r
 /**\r
-  Translate raw data into Unicode (according to different encode), and \r
-  translate Unicode into key information. (according to different standard). \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
@@ -1154,8 +1121,8 @@ AnsiRawDataToUnicode (
 \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
+  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
@@ -1206,7 +1173,7 @@ AnsiRawDataToUnicode (
   | F11     | 0x15 |           | ESC !    |          |\r
   | F12     | 0x16 |           | ESC @    |          |\r
   +=========+======+===========+==========+==========+\r
-  \r
+\r
   Special Mappings\r
   ================\r
   ESC R ESC r ESC R = Reset System\r
@@ -1225,8 +1192,8 @@ UnicodeToEfiKey (
   or valid text graphics.\r
 \r
   @param  TerminalDevice          The terminal device.\r
-  @param  WString                 The input string.          \r
\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
@@ -1242,7 +1209,7 @@ AnsiTestString (
 //\r
 \r
 /**\r
-  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, \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
@@ -1257,8 +1224,8 @@ VTUTF8RawDataToUnicode (
   Check if input string is valid VT-UTF8 string.\r
 \r
   @param  TerminalDevice          The terminal device.\r
-  @param  WString                 The input string.          \r
\r
+  @param  WString                 The input string.\r
+\r
   @retval EFI_SUCCESS             If all input characters are valid.\r
 \r
 **/\r
@@ -1268,7 +1235,7 @@ VTUTF8TestString (
   IN  CHAR16          *WString\r
   );\r
 \r
-/** \r
+/**\r
   Translate one Unicode character into VT-UTF8 characters.\r
 \r
   UTF8 Encoding Table\r
@@ -1296,7 +1263,7 @@ UnicodeToUtf8 (
 \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
+  @param  ValidBytes          The count of returned VT-VTF8 characters.\r
                               If ValidBytes is zero, no valid VT-UTF8 returned.\r
 \r
 **/\r
@@ -1307,7 +1274,7 @@ GetOneValidUtf8Char (
   OUT UINT8             *ValidBytes\r
   );\r
 \r
-/** \r
+/**\r
   Translate VT-UTF8 characters into one Unicode character.\r
 \r
   UTF8 Encoding Table\r
@@ -1319,7 +1286,7 @@ GetOneValidUtf8Char (
 \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
+  @param  UnicodeChar      Returned unicode character.\r
 \r
 **/\r
 VOID\r
@@ -1356,7 +1323,7 @@ TerminalIsValidTextGraphics (
   Detects if a valid ASCII char.\r
 \r
   @param  Ascii        An ASCII character.\r
-                       \r
+\r
   @retval TRUE         If it is a valid ASCII character.\r
   @retval FALSE        If it is not a valid ASCII character.\r
 \r
@@ -1370,7 +1337,7 @@ TerminalIsValidAscii (
   Detects if a valid EFI control character.\r
 \r
   @param  CharC        An input EFI Control character.\r
-                       \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
index 4bb2e77d01504efafd8e2b49885e20d6e5ed7cd2..ca2b3ed2a9c8becd12149443ce56f773474ab5bb 100644 (file)
@@ -120,11 +120,11 @@ TerminalConInReset (
   Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);\r
 \r
   //\r
-  // clear all the internal buffer for keys\r
+  // Make all the internal buffer empty for keys\r
   //\r
-  InitializeRawFiFo (TerminalDevice);\r
-  InitializeUnicodeFiFo (TerminalDevice);\r
-  InitializeEfiKeyFiFo (TerminalDevice);\r
+  TerminalDevice->RawFiFo->Head     = TerminalDevice->RawFiFo->Tail;\r
+  TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;\r
+  TerminalDevice->EfiKeyFiFo->Head  = TerminalDevice->EfiKeyFiFo->Tail;\r
 \r
   if (EFI_ERROR (Status)) {\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
@@ -179,7 +179,7 @@ TerminalConInReadKeyStroke (
 \r
 /**\r
   Check if the key already has been registered.\r
-  \r
+\r
   If both RegsiteredData and InputData is NULL, then ASSERT().\r
 \r
   @param  RegsiteredData           A pointer to a buffer that is filled in with the\r
@@ -450,7 +450,7 @@ TerminalConInUnregisterKeyNotify (
   LIST_ENTRY                      *Link;\r
   TERMINAL_CONSOLE_IN_EX_NOTIFY   *CurrentNotify;\r
   LIST_ENTRY                      *NotifyList;\r
-  \r
+\r
   if (NotificationHandle == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -498,8 +498,8 @@ TerminalConInUnregisterKeyNotify (
 }\r
 \r
 /**\r
-  Translate raw data into Unicode (according to different encode), and \r
-  translate Unicode into key information. (according to different standard). \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
@@ -746,7 +746,7 @@ RawFiFoInsertOneKey (
 {\r
   UINT8 Tail;\r
 \r
-  Tail = TerminalDevice->RawFiFo.Tail;\r
+  Tail = TerminalDevice->RawFiFo->Tail;\r
 \r
   if (IsRawFiFoFull (TerminalDevice)) {\r
     //\r
@@ -755,9 +755,9 @@ RawFiFoInsertOneKey (
     return FALSE;\r
   }\r
 \r
-  TerminalDevice->RawFiFo.Data[Tail]  = Input;\r
+  TerminalDevice->RawFiFo->Data[Tail]  = Input;\r
 \r
-  TerminalDevice->RawFiFo.Tail        = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->RawFiFo->Tail        = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -780,7 +780,7 @@ RawFiFoRemoveOneKey (
 {\r
   UINT8 Head;\r
 \r
-  Head = TerminalDevice->RawFiFo.Head;\r
+  Head = TerminalDevice->RawFiFo->Head;\r
 \r
   if (IsRawFiFoEmpty (TerminalDevice)) {\r
     //\r
@@ -790,9 +790,9 @@ RawFiFoRemoveOneKey (
     return FALSE;\r
   }\r
 \r
-  *Output                       = TerminalDevice->RawFiFo.Data[Head];\r
+  *Output                       = TerminalDevice->RawFiFo->Data[Head];\r
 \r
-  TerminalDevice->RawFiFo.Head  = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->RawFiFo->Head  = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -811,7 +811,7 @@ IsRawFiFoEmpty (
   TERMINAL_DEV  *TerminalDevice\r
   )\r
 {\r
-  if (TerminalDevice->RawFiFo.Head == TerminalDevice->RawFiFo.Tail) {\r
+  if (TerminalDevice->RawFiFo->Head == TerminalDevice->RawFiFo->Tail) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r
@@ -835,8 +835,8 @@ IsRawFiFoFull (
   UINT8 Tail;\r
   UINT8 Head;\r
 \r
-  Tail  = TerminalDevice->RawFiFo.Tail;\r
-  Head  = TerminalDevice->RawFiFo.Head;\r
+  Tail  = TerminalDevice->RawFiFo->Tail;\r
+  Head  = TerminalDevice->RawFiFo->Head;\r
 \r
   if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {\r
 \r
@@ -865,7 +865,7 @@ EfiKeyFiFoInsertOneKey (
 {\r
   UINT8 Tail;\r
 \r
-  Tail = TerminalDevice->EfiKeyFiFo.Tail;\r
+  Tail = TerminalDevice->EfiKeyFiFo->Tail;\r
 \r
   if (IsEfiKeyFiFoFull (TerminalDevice)) {\r
     //\r
@@ -874,9 +874,9 @@ EfiKeyFiFoInsertOneKey (
     return FALSE;\r
   }\r
 \r
-  TerminalDevice->EfiKeyFiFo.Data[Tail] = Key;\r
+  TerminalDevice->EfiKeyFiFo->Data[Tail] = Key;\r
 \r
-  TerminalDevice->EfiKeyFiFo.Tail       = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->EfiKeyFiFo->Tail       = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -899,7 +899,7 @@ EfiKeyFiFoRemoveOneKey (
 {\r
   UINT8 Head;\r
 \r
-  Head = TerminalDevice->EfiKeyFiFo.Head;\r
+  Head = TerminalDevice->EfiKeyFiFo->Head;\r
 \r
   if (IsEfiKeyFiFoEmpty (TerminalDevice)) {\r
     //\r
@@ -910,9 +910,9 @@ EfiKeyFiFoRemoveOneKey (
     return FALSE;\r
   }\r
 \r
-  *Output                         = TerminalDevice->EfiKeyFiFo.Data[Head];\r
+  *Output                         = TerminalDevice->EfiKeyFiFo->Data[Head];\r
 \r
-  TerminalDevice->EfiKeyFiFo.Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -931,7 +931,7 @@ IsEfiKeyFiFoEmpty (
   TERMINAL_DEV  *TerminalDevice\r
   )\r
 {\r
-  if (TerminalDevice->EfiKeyFiFo.Head == TerminalDevice->EfiKeyFiFo.Tail) {\r
+  if (TerminalDevice->EfiKeyFiFo->Head == TerminalDevice->EfiKeyFiFo->Tail) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r
@@ -955,8 +955,8 @@ IsEfiKeyFiFoFull (
   UINT8 Tail;\r
   UINT8 Head;\r
 \r
-  Tail  = TerminalDevice->EfiKeyFiFo.Tail;\r
-  Head  = TerminalDevice->EfiKeyFiFo.Head;\r
+  Tail  = TerminalDevice->EfiKeyFiFo->Tail;\r
+  Head  = TerminalDevice->EfiKeyFiFo->Head;\r
 \r
   if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {\r
 \r
@@ -985,7 +985,7 @@ UnicodeFiFoInsertOneKey (
 {\r
   UINT8 Tail;\r
 \r
-  Tail = TerminalDevice->UnicodeFiFo.Tail;\r
+  Tail = TerminalDevice->UnicodeFiFo->Tail;\r
 \r
   if (IsUnicodeFiFoFull (TerminalDevice)) {\r
     //\r
@@ -994,9 +994,9 @@ UnicodeFiFoInsertOneKey (
     return FALSE;\r
   }\r
 \r
-  TerminalDevice->UnicodeFiFo.Data[Tail]  = Input;\r
+  TerminalDevice->UnicodeFiFo->Data[Tail]  = Input;\r
 \r
-  TerminalDevice->UnicodeFiFo.Tail        = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->UnicodeFiFo->Tail        = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -1019,7 +1019,7 @@ UnicodeFiFoRemoveOneKey (
 {\r
   UINT8 Head;\r
 \r
-  Head = TerminalDevice->UnicodeFiFo.Head;\r
+  Head = TerminalDevice->UnicodeFiFo->Head;\r
 \r
   if (IsUnicodeFiFoEmpty (TerminalDevice)) {\r
     //\r
@@ -1029,9 +1029,9 @@ UnicodeFiFoRemoveOneKey (
     return FALSE;\r
   }\r
 \r
-  *Output = TerminalDevice->UnicodeFiFo.Data[Head];\r
+  *Output = TerminalDevice->UnicodeFiFo->Data[Head];\r
 \r
-  TerminalDevice->UnicodeFiFo.Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
+  TerminalDevice->UnicodeFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
 \r
   return TRUE;\r
 }\r
@@ -1050,7 +1050,7 @@ IsUnicodeFiFoEmpty (
   TERMINAL_DEV  *TerminalDevice\r
   )\r
 {\r
-  if (TerminalDevice->UnicodeFiFo.Head == TerminalDevice->UnicodeFiFo.Tail) {\r
+  if (TerminalDevice->UnicodeFiFo->Head == TerminalDevice->UnicodeFiFo->Tail) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r
@@ -1074,8 +1074,8 @@ IsUnicodeFiFoFull (
   UINT8 Tail;\r
   UINT8 Head;\r
 \r
-  Tail  = TerminalDevice->UnicodeFiFo.Tail;\r
-  Head  = TerminalDevice->UnicodeFiFo.Head;\r
+  Tail  = TerminalDevice->UnicodeFiFo->Tail;\r
+  Head  = TerminalDevice->UnicodeFiFo->Head;\r
 \r
   if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {\r
 \r
@@ -1101,8 +1101,8 @@ UnicodeFiFoGetKeyCount (
   UINT8 Tail;\r
   UINT8 Head;\r
 \r
-  Tail  = TerminalDevice->UnicodeFiFo.Tail;\r
-  Head  = TerminalDevice->UnicodeFiFo.Head;\r
+  Tail  = TerminalDevice->UnicodeFiFo->Tail;\r
+  Head  = TerminalDevice->UnicodeFiFo->Head;\r
 \r
   if (Tail >= Head) {\r
     return (UINT8) (Tail - Head);\r
@@ -1113,7 +1113,7 @@ UnicodeFiFoGetKeyCount (
 \r
 /**\r
   Update the Unicode characters from a terminal input device into EFI Keys FIFO.\r
-  \r
+\r
   @param TerminalDevice   The terminal device to use to translate raw input into EFI Keys\r
 \r
 **/\r
@@ -1124,9 +1124,9 @@ UnicodeToEfiKeyFlushState (
 {\r
   EFI_INPUT_KEY Key;\r
   UINT32        InputState;\r
-  \r
+\r
   InputState = TerminalDevice->InputState;\r
-  \r
+\r
   if ((InputState & INPUT_STATE_ESC) != 0) {\r
     Key.ScanCode    = SCAN_ESC;\r
     Key.UnicodeChar = 0;\r
@@ -1172,8 +1172,8 @@ UnicodeToEfiKeyFlushState (
 \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
+  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 corresponding EFI Scan Code.  If a matching sequence is not found, then the raw\r
index 179f718e15d52f48bf8a5266b98c1ebe253f664a..b5ecbe5b823e6644a7374eb2b06b2ef3206cc702 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of translation upon VT-UTF8.\r
 \r
-Copyright (c) 2006, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, 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
@@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Terminal.h"\r
 \r
 /**\r
-  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, \r
+  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
   and insert them into Unicode FIFO.\r
 \r
   @param TerminalDevice          The terminal device.\r
@@ -55,7 +55,7 @@ VTUTF8RawDataToUnicode (
 \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
+  @param  ValidBytes          The count of returned VT-VTF8 characters.\r
                               If ValidBytes is zero, no valid VT-UTF8 returned.\r
 \r
 **/\r
@@ -125,6 +125,9 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 2:\r
+      //\r
+      // two-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
 \r
         Utf8Char->Utf8_2[0] = Temp;\r
@@ -138,15 +141,20 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 3:\r
+      //\r
+      // three-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
 \r
         Utf8Char->Utf8_3[2 - Index] = Temp;\r
         Index++;\r
-        if (Index == 3) {\r
+        if (Index > 2) {\r
           FetchFlag = FALSE;\r
         }\r
       } else {\r
-\r
+        //\r
+        // reset *ValidBytes and Index to zero, let valid utf8 char search restart\r
+        //\r
         *ValidBytes = 0;\r
         Index       = 0;\r
       }\r
@@ -164,7 +172,7 @@ GetOneValidUtf8Char (
   return ;\r
 }\r
 \r
-/** \r
+/**\r
   Translate VT-UTF8 characters into one Unicode character.\r
 \r
   UTF8 Encoding Table\r
@@ -176,7 +184,7 @@ GetOneValidUtf8Char (
 \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
+  @param  UnicodeChar      Returned unicode character.\r
 \r
 **/\r
 VOID\r
@@ -237,7 +245,7 @@ Utf8ToUnicode (
   return ;\r
 }\r
 \r
-/** \r
+/**\r
   Translate one Unicode character into VT-UTF8 characters.\r
 \r
   UTF8 Encoding Table\r
@@ -301,8 +309,8 @@ UnicodeToUtf8 (
   Check if input string is valid VT-UTF8 string.\r
 \r
   @param  TerminalDevice          The terminal device.\r
-  @param  WString                 The input string.          \r
\r
+  @param  WString                 The input string.\r
+\r
   @retval EFI_SUCCESS             If all input characters are valid.\r
 \r
 **/\r