public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/8] Fix TerminalDxe driver model bug
@ 2017-01-10  8:38 Ruiyu Ni
  2017-01-10  8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:38 UTC (permalink / raw)
  To: edk2-devel

Patches 1~7 cleans up the TerminalDxe driver without functionality impact.
Patch 8 fixes the driver model bug.

Ruiyu Ni (8):
  MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types
  MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function
  MdeModulePkg/TerminalDxe: Separate controller name init logic
  MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode
  MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath
  MdeModulePkg/TerminalDxe: Separate state machine start/stop logic
  MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check
  MdeModulePkg/TerminalDxe: Fix driver model bug

 .../Universal/Console/TerminalDxe/Terminal.c       | 1363 +++++++-------------
 .../Universal/Console/TerminalDxe/Terminal.h       |   14 +-
 .../Universal/Console/TerminalDxe/TerminalConIn.c  |   88 +-
 .../Universal/Console/TerminalDxe/TerminalConOut.c |   28 +-
 4 files changed, 509 insertions(+), 984 deletions(-)

-- 
2.9.0.windows.1



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
@ 2017-01-10  8:38 ` Ruiyu Ni
  2017-01-11  7:32   ` Tian, Feng
  2017-01-10  8:38 ` [PATCH 2/8] MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function Ruiyu Ni
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:38 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 50 ++++++------
 .../Universal/Console/TerminalDxe/Terminal.h       | 14 ++--
 .../Universal/Console/TerminalDxe/TerminalConIn.c  | 88 +++++++++++-----------
 .../Universal/Console/TerminalDxe/TerminalConOut.c | 28 +++----
 4 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index a209bf3..1c1f5e1 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
   Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
   Simple Text Output Protocol upon Serial IO Protocol.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -270,23 +270,23 @@ BuildTerminalDevpath  (
 
   } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
 
-    TerminalType = PCANSITYPE;
+    TerminalType = TerminalTypePcAnsi;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
 
-    TerminalType = VT100TYPE;
+    TerminalType = TerminalTypeVt100;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
 
-    TerminalType = VT100PLUSTYPE;
+    TerminalType = TerminalTypeVt100Plus;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
 
-    TerminalType = VTUTF8TYPE;
+    TerminalType = TerminalTypeVtUtf8;
 
   } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
 
-    TerminalType = TTYTERMTYPE;
+    TerminalType = TerminalTypeTtyTerm;
 
   } else {
     return NULL;
@@ -713,9 +713,9 @@ TerminalDriverBindingStart (
     if (RemainingDevicePath == NULL) {
       TerminalType = PcdGet8 (PcdDefaultTerminalType);
       //
-      // Must be between PCANSITYPE (0) and TTYTERMTYPE (4)
+      // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm (4)
       //
-      ASSERT (TerminalType <= TTYTERMTYPE);
+      ASSERT (TerminalType <= TerminalTypeTtyTerm);
     } else if (!IsDevicePathEnd (RemainingDevicePath)) {
       //
       // If RemainingDevicePath isn't the End of Device Path Node,
@@ -723,15 +723,15 @@ TerminalDriverBindingStart (
       //
       Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
       if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
-        TerminalType = PCANSITYPE;
+        TerminalType = TerminalTypePcAnsi;
       } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
-        TerminalType = VT100TYPE;
+        TerminalType = TerminalTypeVt100;
       } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
-        TerminalType = VT100PLUSTYPE;
+        TerminalType = TerminalTypeVt100Plus;
       } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
-        TerminalType = VTUTF8TYPE;
+        TerminalType = TerminalTypeVtUtf8;
       } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
-        TerminalType = TTYTERMTYPE;
+        TerminalType = TerminalTypeTtyTerm;
       } else {
         goto Error;
       }
@@ -863,7 +863,7 @@ TerminalDriverBindingStart (
     //
     TerminalDevice->ControllerNameTable = NULL;
     switch (TerminalDevice->TerminalType) {
-    case PCANSITYPE:
+    case TerminalTypePcAnsi:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -881,7 +881,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VT100TYPE:
+    case TerminalTypeVt100:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -899,7 +899,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VT100PLUSTYPE:
+    case TerminalTypeVt100Plus:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -917,7 +917,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VTUTF8TYPE:
+    case TerminalTypeVtUtf8:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -935,7 +935,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case TTYTERMTYPE:
+    case TerminalTypeTtyTerm:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -1473,7 +1473,7 @@ TerminalUpdateConsoleDevVariable (
   //
   // Append terminal device path onto the variable.
   //
-  for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {
+  for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {
     SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
     NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
     ASSERT (NewVariable != NULL);
@@ -1586,7 +1586,7 @@ TerminalRemoveConsoleDevVariable (
     // Loop through all the terminal types that this driver supports
     //
     Match = FALSE;
-    for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {
+    for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {
 
       SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
 
@@ -1674,23 +1674,23 @@ SetTerminalDevicePath (
   //
   switch (TerminalType) {
 
-  case PCANSITYPE:
+  case TerminalTypePcAnsi:
     CopyGuid (&Node.Guid, &gEfiPcAnsiGuid);
     break;
 
-  case VT100TYPE:
+  case TerminalTypeVt100:
     CopyGuid (&Node.Guid, &gEfiVT100Guid);
     break;
 
-  case VT100PLUSTYPE:
+  case TerminalTypeVt100Plus:
     CopyGuid (&Node.Guid, &gEfiVT100PlusGuid);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);
     break;
 
-  case TTYTERMTYPE:
+  case TerminalTypeTtyTerm:
     CopyGuid (&Node.Guid, &gEfiTtyTermGuid);
     break;
 
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index e16b89c..fff3281 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for Terminal driver.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -139,11 +139,13 @@ typedef union {
   UINT8 Utf8_3[3];
 } UTF8_CHAR;
 
-#define PCANSITYPE                0
-#define VT100TYPE                 1
-#define VT100PLUSTYPE             2
-#define VTUTF8TYPE                3
-#define TTYTERMTYPE               4
+typedef enum {
+  TerminalTypePcAnsi,
+  TerminalTypeVt100,
+  TerminalTypeVt100Plus,
+  TerminalTypeVtUtf8,
+  TerminalTypeTtyTerm
+} TERMINAL_TYPE;
 
 #define LEFTOPENBRACKET           0x5b  // '['
 #define ACAP                      0x41
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 0162410..1392f16 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -2,7 +2,7 @@
   Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.
 
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -453,15 +453,15 @@ TranslateRawDataToEfiKey (
 {
   switch (TerminalDevice->TerminalType) {
 
-  case PCANSITYPE:
-  case VT100TYPE:
-  case VT100PLUSTYPE:
-  case TTYTERMTYPE:
+  case TerminalTypePcAnsi:
+  case TerminalTypeVt100:
+  case TerminalTypeVt100Plus:
+  case TerminalTypeTtyTerm:
     AnsiRawDataToUnicode (TerminalDevice);
     UnicodeToEfiKey (TerminalDevice);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     //
     // Process all the raw data in the RawFIFO,
     // put the processed key into UnicodeFIFO.
@@ -1405,8 +1405,8 @@ UnicodeToEfiKey (
         continue;
       }
 
-      if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == VT100TYPE ||
-                                 TerminalDevice->TerminalType == TTYTERMTYPE)) {
+      if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
+                                 TerminalDevice->TerminalType == TerminalTypeTtyTerm)) {
         TerminalDevice->InputState |= INPUT_STATE_O;
         TerminalDevice->ResetState = RESET_STATE_DEFAULT;
         continue;
@@ -1414,8 +1414,8 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == VT100PLUSTYPE ||
-          TerminalDevice->TerminalType == VTUTF8TYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8) {
         switch (UnicodeChar) {
         case '1':
           Key.ScanCode = SCAN_F1;
@@ -1519,7 +1519,7 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == VT100TYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeVt100) {
         switch (UnicodeChar) {
         case 'P':
           Key.ScanCode = SCAN_F1;
@@ -1554,7 +1554,7 @@ UnicodeToEfiKey (
         default :
           break;
         }
-      } else if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      } else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         /* Also accept VT100 escape codes for F1-F4, HOME and END for TTY term */
         switch (UnicodeChar) {
         case 'P':
@@ -1596,11 +1596,11 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == PCANSITYPE    ||
-          TerminalDevice->TerminalType == VT100TYPE     ||
-          TerminalDevice->TerminalType == VT100PLUSTYPE ||
-          TerminalDevice->TerminalType == VTUTF8TYPE    ||
-          TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypePcAnsi    ||
+          TerminalDevice->TerminalType == TerminalTypeVt100     ||
+          TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8    ||
+          TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         switch (UnicodeChar) {
         case 'A':
           Key.ScanCode = SCAN_UP;
@@ -1615,104 +1615,104 @@ UnicodeToEfiKey (
           Key.ScanCode = SCAN_LEFT;
           break;
         case 'H':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == VT100TYPE  ||
-              TerminalDevice->TerminalType == TTYTERMTYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeVt100  ||
+              TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
             Key.ScanCode = SCAN_HOME;
           }
           break;
         case 'F':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == TTYTERMTYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
             Key.ScanCode = SCAN_END;
           }
           break;
         case 'K':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_END;
           }
           break;
         case 'L':
         case '@':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_INSERT;
           }
           break;
         case 'X':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_DELETE;
           }
           break;
         case 'P':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_DELETE;
-          } else if (TerminalDevice->TerminalType == PCANSITYPE) {
+          } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F4;
           }
           break;
         case 'I':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_PAGE_UP;
           }
           break;
         case 'V':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F10;
           }
           break;
         case '?':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_PAGE_UP;
           }
           break;
         case 'G':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_PAGE_DOWN;
           }
           break;
         case 'U':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F9;
           }
           break;
         case '/':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_PAGE_DOWN;
           }
           break;
         case 'M':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F1;
           }
           break;
         case 'N':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F2;
           }
           break;
         case 'O':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F3;
           }
           break;
         case 'Q':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F5;
           }
           break;
         case 'R':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F6;
           }
           break;
         case 'S':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F7;
           }
           break;
         case 'T':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F8;
           }
           break;
@@ -1726,7 +1726,7 @@ UnicodeToEfiKey (
        * numeric codes, and there are no ambiguous prefixes shared with
        * other terminal types.
        */
-      if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
           Key.ScanCode == SCAN_NULL &&
           UnicodeChar >= '0' &&
           UnicodeChar <= '9') {
@@ -1755,7 +1755,7 @@ UnicodeToEfiKey (
        * state is only used by the TTY terminal type.
        */
       Key.ScanCode = SCAN_NULL;
-      if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
 
         if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) {
           UINT16 EscCode;
@@ -1851,7 +1851,7 @@ UnicodeToEfiKey (
     }
 
     if (UnicodeChar == DEL) {
-      if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         Key.ScanCode    = SCAN_NULL;
         Key.UnicodeChar = CHAR_BACKSPACE;
       }
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index c9b4ffc..e677a76 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
 
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -224,10 +224,10 @@ TerminalConOutOutputString (
 
     switch (TerminalDevice->TerminalType) {
 
-    case PCANSITYPE:
-    case VT100TYPE:
-    case VT100PLUSTYPE:
-    case TTYTERMTYPE:
+    case TerminalTypePcAnsi:
+    case TerminalTypeVt100:
+    case TerminalTypeVt100Plus:
+    case TerminalTypeTtyTerm:
 
       if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
         //
@@ -253,7 +253,7 @@ TerminalConOutOutputString (
 
       }
 
-      if (TerminalDevice->TerminalType != PCANSITYPE) {
+      if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
         GraphicChar = AsciiChar;
       }
 
@@ -271,7 +271,7 @@ TerminalConOutOutputString (
 
       break;
 
-    case VTUTF8TYPE:
+    case TerminalTypeVtUtf8:
       UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
       Length = ValidBytes;
       Status = TerminalDevice->SerialIo->Write (
@@ -317,7 +317,7 @@ TerminalConOutOutputString (
           Mode->CursorRow++;
         }
 
-        if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+        if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
             !TerminalDevice->OutputEscChar) {
           //
           // We've written the last character on the line.  The
@@ -398,14 +398,14 @@ TerminalConOutTestString (
 
   switch (TerminalDevice->TerminalType) {
 
-  case PCANSITYPE:
-  case VT100TYPE:
-  case VT100PLUSTYPE:
-  case TTYTERMTYPE:
+  case TerminalTypePcAnsi:
+  case TerminalTypeVt100:
+  case TerminalTypeVt100Plus:
+  case TerminalTypeTtyTerm:
     Status = AnsiTestString (TerminalDevice, WString);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     Status = VTUTF8TestString (TerminalDevice, WString);
     break;
 
@@ -791,7 +791,7 @@ TerminalConOutSetCursorPosition (
   // within the current line if possible, and don't output anyting if
   // it isn't necessary.
   //
-  if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+  if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
       (UINTN)Mode->CursorRow == Row) {
     if ((UINTN)Mode->CursorColumn > Column) {
       mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10));
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/8] MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
  2017-01-10  8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
@ 2017-01-10  8:38 ` Ruiyu Ni
  2017-01-10  8:38 ` [PATCH 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic Ruiyu Ni
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:38 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 55 ++++++++++++----------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 1c1f5e1..992d58e 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -29,7 +29,7 @@ EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding = {
 };
 
 
-EFI_GUID  *gTerminalType[] = {
+EFI_GUID  *mTerminalType[] = {
   &gEfiPcAnsiGuid,
   &gEfiVT100Guid,
   &gEfiVT100PlusGuid,
@@ -112,6 +112,28 @@ TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
 };
 
 /**
+  Convert the GUID representation of terminal type to enum type.
+
+  @param Guid  The GUID representation of terminal type.
+
+  @return  The terminal type in enum type.
+**/
+TERMINAL_TYPE
+TerminalTypeFromGuid (
+  IN EFI_GUID                     *Guid
+)
+{
+  TERMINAL_TYPE                   Type;
+
+  for (Type = 0; Type < ARRAY_SIZE (mTerminalType); Type++) {
+    if (CompareGuid (Guid, mTerminalType[Type])) {
+      break;
+    }
+  }
+  return Type;
+}
+
+/**
   Test to see if this driver supports Controller.
 
   @param  This                Protocol instance pointer.
@@ -163,12 +185,7 @@ TerminalDriverBindingSupported (
       //
       // only supports PC ANSI, VT100, VT100+, VT-UTF8, and TtyTerm terminal types
       //
-      if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&
-          !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&
-          !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&
-          !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid) &&
-          !CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
-
+      if (TerminalTypeFromGuid (&Node->Guid) == ARRAY_SIZE (mTerminalType)) {
         return EFI_UNSUPPORTED;
       }
     }
@@ -712,29 +729,13 @@ TerminalDriverBindingStart (
     //
     if (RemainingDevicePath == NULL) {
       TerminalType = PcdGet8 (PcdDefaultTerminalType);
-      //
-      // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm (4)
-      //
-      ASSERT (TerminalType <= TerminalTypeTtyTerm);
     } else if (!IsDevicePathEnd (RemainingDevicePath)) {
       //
       // If RemainingDevicePath isn't the End of Device Path Node,
       // Use the RemainingDevicePath to determine the terminal type
       //
       Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
-      if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
-        TerminalType = TerminalTypePcAnsi;
-      } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
-        TerminalType = TerminalTypeVt100;
-      } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
-        TerminalType = TerminalTypeVt100Plus;
-      } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
-        TerminalType = TerminalTypeVtUtf8;
-      } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
-        TerminalType = TerminalTypeTtyTerm;
-      } else {
-        goto Error;
-      }
+      TerminalType = TerminalTypeFromGuid (&Node->Guid);
     } else {
       //
       // If RemainingDevicePath is the End of Device Path Node,
@@ -743,6 +744,8 @@ TerminalDriverBindingStart (
       return EFI_SUCCESS;
     }
 
+    ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
+
     //
     // Initialize the Terminal Dev
     //
@@ -1473,7 +1476,7 @@ TerminalUpdateConsoleDevVariable (
   //
   // Append terminal device path onto the variable.
   //
-  for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {
+  for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {
     SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
     NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
     ASSERT (NewVariable != NULL);
@@ -1586,7 +1589,7 @@ TerminalRemoveConsoleDevVariable (
     // Loop through all the terminal types that this driver supports
     //
     Match = FALSE;
-    for (TerminalType = TerminalTypePcAnsi; TerminalType <= TerminalTypeTtyTerm; TerminalType++) {
+    for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {
 
       SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
 
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
  2017-01-10  8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
  2017-01-10  8:38 ` [PATCH 2/8] MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function Ruiyu Ni
@ 2017-01-10  8:38 ` Ruiyu Ni
  2017-01-10  8:39 ` [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode Ruiyu Ni
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:38 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 147 ++++++++-------------
 1 file changed, 56 insertions(+), 91 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 992d58e..f1ce12d 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -38,6 +38,14 @@ EFI_GUID  *mTerminalType[] = {
 };
 
 
+CHAR16 *mSerialConsoleNames[] = {
+  L"PC-ANSI Serial Console",
+  L"VT-100 Serial Console",
+  L"VT-100+ Serial Console",
+  L"VT-UTF8 Serial Console",
+  L"Tty Terminal Serial Console"
+};
+
 TERMINAL_DEV  mTerminalDevTemplate = {
   TERMINAL_DEV_SIGNATURE,
   NULL,
@@ -536,6 +544,51 @@ InitializeTerminalConsoleTextMode (
 }
 
 /**
+  Initialize the controller name table.
+
+  @param TerminalType        The terminal type.
+  @param ControllerNameTable The controller name table.
+
+  @retval EFI_SUCCESS  The controller name table is initialized successfully.
+  @retval others       Return status of AddUnicodeString2 ().
+**/
+EFI_STATUS
+InitializeControllerNameTable (
+  TERMINAL_TYPE             TerminalType,
+  EFI_UNICODE_STRING_TABLE  **ControllerNameTable
+)
+{
+  EFI_STATUS                Status;
+  EFI_UNICODE_STRING_TABLE  *Table;
+
+  ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
+  Table = NULL;
+  Status = AddUnicodeString2 (
+             "eng",
+             gTerminalComponentName.SupportedLanguages,
+             &Table,
+             mSerialConsoleNames[TerminalType],
+             TRUE
+             );
+  if (!EFI_ERROR (Status)) {
+    Status = AddUnicodeString2 (
+               "en",
+               gTerminalComponentName2.SupportedLanguages,
+               &Table,
+               mSerialConsoleNames[TerminalType],
+               FALSE
+               );
+    if (EFI_ERROR (Status)) {
+      FreeUnicodeStringTable (Table);
+    }
+  }
+  if (!EFI_ERROR (Status)) {
+    *ControllerNameTable = Table;
+  }
+  return Status;
+}
+
+/**
   Start this driver on Controller by opening a Serial IO protocol,
   reading Device Path, and creating a child handle with a Simple Text In,
   Simple Text In Ex and Simple Text Out protocol, and device path protocol.
@@ -864,97 +917,9 @@ TerminalDriverBindingStart (
     //
     // Build the component name for the child device
     //
-    TerminalDevice->ControllerNameTable = NULL;
-    switch (TerminalDevice->TerminalType) {
-    case TerminalTypePcAnsi:
-      AddUnicodeString2 (
-        "eng",
-        gTerminalComponentName.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"PC-ANSI Serial Console",
-        TRUE
-        );
-      AddUnicodeString2 (
-        "en",
-        gTerminalComponentName2.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"PC-ANSI Serial Console",
-        FALSE
-        );
-
-      break;
-
-    case TerminalTypeVt100:
-      AddUnicodeString2 (
-        "eng",
-        gTerminalComponentName.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-100 Serial Console",
-        TRUE
-        );
-      AddUnicodeString2 (
-        "en",
-        gTerminalComponentName2.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-100 Serial Console",
-        FALSE
-        );
-
-      break;
-
-    case TerminalTypeVt100Plus:
-      AddUnicodeString2 (
-        "eng",
-        gTerminalComponentName.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-100+ Serial Console",
-        TRUE
-        );
-      AddUnicodeString2 (
-        "en",
-        gTerminalComponentName2.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-100+ Serial Console",
-        FALSE
-        );
-
-      break;
-
-    case TerminalTypeVtUtf8:
-      AddUnicodeString2 (
-        "eng",
-        gTerminalComponentName.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-UTF8 Serial Console",
-        TRUE
-        );
-      AddUnicodeString2 (
-        "en",
-        gTerminalComponentName2.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"VT-UTF8 Serial Console",
-        FALSE
-        );
-
-      break;
-
-    case TerminalTypeTtyTerm:
-      AddUnicodeString2 (
-        "eng",
-        gTerminalComponentName.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"Tty Terminal Serial Console",
-        TRUE
-        );
-      AddUnicodeString2 (
-        "en",
-        gTerminalComponentName2.SupportedLanguages,
-        &TerminalDevice->ControllerNameTable,
-        (CHAR16 *)L"Tty Terminal Serial Console",
-        FALSE
-        );
-
-      break;
+    Status = InitializeControllerNameTable (TerminalDevice->TerminalType, &TerminalDevice->ControllerNameTable);
+    if (EFI_ERROR (Status)) {
+      goto Error;
     }
 
     //
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
                   ` (2 preceding siblings ...)
  2017-01-10  8:38 ` [PATCH 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic Ruiyu Ni
@ 2017-01-10  8:39 ` Ruiyu Ni
  2017-01-12 10:41   ` Laszlo Ersek
  2017-01-10  8:39 ` [PATCH 5/8] MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath Ruiyu Ni
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 108 +++++----------------
 1 file changed, 26 insertions(+), 82 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index f1ce12d..4b0c00d 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -113,6 +113,8 @@ TERMINAL_DEV  mTerminalDevTemplate = {
 };
 
 TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
+  {80,  25},
+  {80,  50},
   {100, 31},
   //
   // New modes can be added here.
@@ -450,97 +452,39 @@ TerminalFreeNotifyList (
   It returns information for available text modes that the terminal can support.
 
   @param[out] TextModeCount      The total number of text modes that terminal console supports.
-  @param[out] TextModeData       The buffer to the text modes column and row information.
-                                 Caller is responsible to free it when it's non-NULL.
 
-  @retval EFI_SUCCESS            The supporting mode information is returned.
-  @retval EFI_INVALID_PARAMETER  The parameters are invalid.
+  @return   The buffer to the text modes column and row information.
+            Caller is responsible to free it when it's non-NULL.
 
 **/
-EFI_STATUS
+TERMINAL_CONSOLE_MODE_DATA *
 InitializeTerminalConsoleTextMode (
-  OUT UINTN                         *TextModeCount,
-  OUT TERMINAL_CONSOLE_MODE_DATA    **TextModeData
-  )
+  OUT INT32                         *TextModeCount
+)
 {
-  UINTN                       Index;
-  UINTN                       Count;
-  TERMINAL_CONSOLE_MODE_DATA  *ModeBuffer;
-  TERMINAL_CONSOLE_MODE_DATA  *NewModeBuffer;
-  UINTN                       ValidCount;
-  UINTN                       ValidIndex;
-  
-  if ((TextModeCount == NULL) || (TextModeData == NULL)) {
-    return EFI_INVALID_PARAMETER;
-  }
-  
-  Count = sizeof (mTerminalConsoleModeData) / sizeof (TERMINAL_CONSOLE_MODE_DATA);
-  
-  //
-  // Get defined mode buffer pointer.
-  //
-  ModeBuffer = mTerminalConsoleModeData;
-    
+  TERMINAL_CONSOLE_MODE_DATA  *TextModeData;
+
+  ASSERT (TextModeCount != NULL);
+
   //
   // Here we make sure that the final mode exposed does not include the duplicated modes,
   // and does not include the invalid modes which exceed the max column and row.
   // Reserve 2 modes for 80x25, 80x50 of terminal console.
   //
-  NewModeBuffer = AllocateZeroPool (sizeof (TERMINAL_CONSOLE_MODE_DATA) * (Count + 2));
-  ASSERT (NewModeBuffer != NULL);
-
-  //
-  // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
-  //
-  ValidCount = 0;  
-
-  NewModeBuffer[ValidCount].Columns = 80;
-  NewModeBuffer[ValidCount].Rows    = 25;
-  ValidCount++;
-
-  NewModeBuffer[ValidCount].Columns = 80;
-  NewModeBuffer[ValidCount].Rows    = 50;
-  ValidCount++;
-  
-  //
-  // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
-  //
-  for (Index = 0; Index < Count; Index++) {
-    if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0)) {
-      //
-      // Skip the pre-defined mode which is invalid.
-      //
-      continue;
-    }
-    for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
-      if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
-          (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
-        //
-        // Skip the duplicated mode.
-        //
-        break;
-      }
-    }
-    if (ValidIndex == ValidCount) {
-      NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
-      NewModeBuffer[ValidCount].Rows    = ModeBuffer[Index].Rows;
-      ValidCount++;
-    }
+  TextModeData = AllocateCopyPool (sizeof (mTerminalConsoleModeData), mTerminalConsoleModeData);
+  if (TextModeData == NULL) {
+    return NULL;
   }
- 
+  *TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData);
+
   DEBUG_CODE (
-    for (Index = 0; Index < ValidCount; Index++) {
-      DEBUG ((EFI_D_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n", 
-                           Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));  
+    INT32 Index;
+    for (Index = 0; Index < *TextModeCount; Index++) {
+      DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
+              Index, TextModeData[Index].Columns, TextModeData[Index].Rows));
     }
   );
-  
-  //
-  // Return valid mode count and mode information buffer.
-  //
-  *TextModeCount = ValidCount;
-  *TextModeData  = NewModeBuffer;
-  return EFI_SUCCESS;
+  return TextModeData;
 }
 
 /**
@@ -632,7 +576,6 @@ TerminalDriverBindingStart (
   BOOLEAN                             SimTxtInInstalled;
   BOOLEAN                             SimTxtOutInstalled;
   BOOLEAN                             FirstEnter;
-  UINTN                               ModeCount;
 
   TerminalDevice     = NULL;
   ConInSelected      = FALSE;
@@ -896,12 +839,13 @@ TerminalDriverBindingStart (
                          );
     SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
     
-    Status = InitializeTerminalConsoleTextMode (&ModeCount, &TerminalDevice->TerminalConsoleModeData);
-    if (EFI_ERROR (Status)) {
+    TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
+                                                &SimpleTextOutput->Mode->MaxMode
+                                                );
+    if (TerminalDevice->TerminalConsoleModeData == NULL) {
       goto ReportError;
     }
-    TerminalDevice->SimpleTextOutputMode.MaxMode = (INT32) ModeCount;
-    
+
     //
     // For terminal devices, cursor is always visible
     //
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/8] MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
                   ` (3 preceding siblings ...)
  2017-01-10  8:39 ` [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode Ruiyu Ni
@ 2017-01-10  8:39 ` Ruiyu Ni
  2017-01-10  8:39 ` [PATCH 6/8] MdeModulePkg/TerminalDxe: Separate state machine start/stop logic Ruiyu Ni
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 41 ++--------------------
 1 file changed, 3 insertions(+), 38 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 4b0c00d..7197f59 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -1577,46 +1577,11 @@ SetTerminalDevicePath (
 {
   VENDOR_DEVICE_PATH  Node;
 
-  *TerminalDevicePath = NULL;
+  ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
   Node.Header.Type    = MESSAGING_DEVICE_PATH;
   Node.Header.SubType = MSG_VENDOR_DP;
-
-  //
-  // Generate terminal device path node according to terminal type.
-  //
-  switch (TerminalType) {
-
-  case TerminalTypePcAnsi:
-    CopyGuid (&Node.Guid, &gEfiPcAnsiGuid);
-    break;
-
-  case TerminalTypeVt100:
-    CopyGuid (&Node.Guid, &gEfiVT100Guid);
-    break;
-
-  case TerminalTypeVt100Plus:
-    CopyGuid (&Node.Guid, &gEfiVT100PlusGuid);
-    break;
-
-  case TerminalTypeVtUtf8:
-    CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);
-    break;
-
-  case TerminalTypeTtyTerm:
-    CopyGuid (&Node.Guid, &gEfiTtyTermGuid);
-    break;
-
-  default:
-    return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Get VENDOR_DEVCIE_PATH size and put into Node.Header
-  //
-  SetDevicePathNodeLength (
-    &Node.Header,
-    sizeof (VENDOR_DEVICE_PATH)
-    );
+  SetDevicePathNodeLength (&Node, sizeof (VENDOR_DEVICE_PATH));
+  CopyGuid (&Node.Guid, mTerminalType[TerminalType]);
 
   //
   // Append the terminal node onto parent device path
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/8] MdeModulePkg/TerminalDxe: Separate state machine start/stop logic
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
                   ` (4 preceding siblings ...)
  2017-01-10  8:39 ` [PATCH 5/8] MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath Ruiyu Ni
@ 2017-01-10  8:39 ` Ruiyu Ni
  2017-01-10  8:39 ` [PATCH 7/8] MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check Ruiyu Ni
  2017-01-10  8:39 ` [PATCH 8/8] MdeModulePkg/TerminalDxe: Fix driver model bug Ruiyu Ni
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 85 +++++++++++++++-------
 1 file changed, 59 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 7197f59..33b4113 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -488,6 +488,63 @@ InitializeTerminalConsoleTextMode (
 }
 
 /**
+  Stop the terminal state machine.
+
+  @param TerminalDevice    The terminal device.
+**/
+VOID
+StopTerminalStateMachine (
+  TERMINAL_DEV             *TerminalDevice
+  )
+{
+  EFI_TPL                  OriginalTpl;
+
+  OriginalTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+  gBS->CloseEvent (TerminalDevice->TimerEvent);
+  gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
+
+  gBS->RestoreTPL (OriginalTpl);
+}
+
+/**
+  Start the terminal state machine.
+
+  @param TerminalDevice    The terminal device.
+**/
+VOID
+StartTerminalStateMachine (
+  TERMINAL_DEV             *TerminalDevice
+  )
+{
+  EFI_STATUS               Status;
+  Status = gBS->CreateEvent (
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,
+                  TPL_NOTIFY,
+                  TerminalConInTimerHandler,
+                  TerminalDevice,
+                  &TerminalDevice->TimerEvent
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = gBS->SetTimer (
+                  TerminalDevice->TimerEvent,
+                  TimerPeriodic,
+                  KEYBOARD_TIMER_INTERVAL
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = gBS->CreateEvent (
+                  EVT_TIMER,
+                  TPL_CALLBACK,
+                  NULL,
+                  NULL,
+                  &TerminalDevice->TwoSecondTimeOut
+                  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
   Initialize the controller name table.
 
   @param TerminalType        The terminal type.
@@ -893,30 +950,7 @@ TerminalDriverBindingStart (
       goto ReportError;
     }
 
-    Status = gBS->CreateEvent (
-                    EVT_TIMER | EVT_NOTIFY_SIGNAL,
-                    TPL_NOTIFY,
-                    TerminalConInTimerHandler,
-                    TerminalDevice,
-                    &TerminalDevice->TimerEvent
-                    );
-    ASSERT_EFI_ERROR (Status);
-
-    Status = gBS->SetTimer (
-                    TerminalDevice->TimerEvent,
-                    TimerPeriodic,
-                    KEYBOARD_TIMER_INTERVAL
-                    );
-    ASSERT_EFI_ERROR (Status);
-
-    Status = gBS->CreateEvent (
-                    EVT_TIMER,
-                    TPL_CALLBACK,
-                    NULL,
-                    NULL,
-                    &TerminalDevice->TwoSecondTimeOut
-                    );
-    ASSERT_EFI_ERROR (Status);
+    StartTerminalStateMachine (TerminalDevice);
 
     Status = gBS->CreateEvent (
                     EVT_NOTIFY_SIGNAL,
@@ -1326,8 +1360,7 @@ TerminalDriverBindingStop (
           FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
         }
 
-        gBS->CloseEvent (TerminalDevice->TimerEvent);
-        gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
+        StopTerminalStateMachine (TerminalDevice);
         gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
         gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
         gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/8] MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
                   ` (5 preceding siblings ...)
  2017-01-10  8:39 ` [PATCH 6/8] MdeModulePkg/TerminalDxe: Separate state machine start/stop logic Ruiyu Ni
@ 2017-01-10  8:39 ` Ruiyu Ni
  2017-01-10  8:39 ` [PATCH 8/8] MdeModulePkg/TerminalDxe: Fix driver model bug Ruiyu Ni
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 33b4113..7f9ce02 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -1356,19 +1356,14 @@ TerminalDriverBindingStop (
               );
       } else {
 
-        if (TerminalDevice->ControllerNameTable != NULL) {
-          FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
-        }
-
+        FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
         StopTerminalStateMachine (TerminalDevice);
         gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
         gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
         gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);
         TerminalFreeNotifyList (&TerminalDevice->NotifyList);
         FreePool (TerminalDevice->DevicePath);
-        if (TerminalDevice->TerminalConsoleModeData != NULL) {
-          FreePool (TerminalDevice->TerminalConsoleModeData);
-        }
+        FreePool (TerminalDevice->TerminalConsoleModeData);
         FreePool (TerminalDevice);
       }
     }
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/8] MdeModulePkg/TerminalDxe: Fix driver model bug
  2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
                   ` (6 preceding siblings ...)
  2017-01-10  8:39 ` [PATCH 7/8] MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check Ruiyu Ni
@ 2017-01-10  8:39 ` Ruiyu Ni
  7 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-10  8:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Feng Tian

TerminalDxe driver contains bugs in its DriverBindingStart():
1. It cannot be started AGAIN using a different terminal type;
2. It doesn't install SimpleTextInput/SimpleTextOut when
   ConIn/ConOut doesn't contain its device path. The check is
   duplicated of the same logic in ConPlatform driver and can
   be removed.

The patch optimized the code to remove the unnecessary
gEfiCallerIdGuid protocol installation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 942 ++++++---------------
 1 file changed, 280 insertions(+), 662 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 7f9ce02..f891ca7 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -264,154 +264,6 @@ TerminalDriverBindingSupported (
   return Status;
 }
 
-/**
-  Build the terminal device path for the child device according to the
-  terminal type.
-
-  @param  ParentDevicePath         Parent device path.
-  @param  RemainingDevicePath      A specific child device.
-
-  @return The child device path built.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL*
-EFIAPI
-BuildTerminalDevpath  (
-  IN EFI_DEVICE_PATH_PROTOCOL       *ParentDevicePath,
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL          *TerminalDevicePath;
-  UINT8                             TerminalType;
-  VENDOR_DEVICE_PATH                *Node;
-  EFI_STATUS                        Status;
-
-  TerminalDevicePath = NULL;
-
-  //
-  // Use the RemainingDevicePath to determine the terminal type
-  //
-  Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
-  if (Node == NULL) {
-    TerminalType = PcdGet8 (PcdDefaultTerminalType);
-
-  } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
-
-    TerminalType = TerminalTypePcAnsi;
-
-  } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
-
-    TerminalType = TerminalTypeVt100;
-
-  } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
-
-    TerminalType = TerminalTypeVt100Plus;
-
-  } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
-
-    TerminalType = TerminalTypeVtUtf8;
-
-  } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
-
-    TerminalType = TerminalTypeTtyTerm;
-
-  } else {
-    return NULL;
-  }
-
-  //
-  // Build the device path for the child device
-  //
-  Status = SetTerminalDevicePath (
-            TerminalType,
-            ParentDevicePath,
-            &TerminalDevicePath
-            );
-  if (EFI_ERROR (Status)) {
-    return NULL;
-  }
-  return TerminalDevicePath;
-}
-
-/**
-  Compare a device path data structure to that of all the nodes of a
-  second device path instance.
-
-  @param  Multi          A pointer to a multi-instance device path data structure.
-  @param  Single         A pointer to a single-instance device path data structure.
-
-  @retval TRUE           If the Single is contained within Multi.
-  @retval FALSE          The Single is not match within Multi.
-
-**/
-BOOLEAN
-MatchDevicePaths (
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Single
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;
-  UINTN                     Size;
-
-  DevicePath      = Multi;
-  DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);
-  //
-  // Search for the match of 'Single' in 'Multi'
-  //
-  while (DevicePathInst != NULL) {
-    //
-    // If the single device path is found in multiple device paths,
-    // return success
-    //
-    if (CompareMem (Single, DevicePathInst, Size) == 0) {
-      FreePool (DevicePathInst);
-      return TRUE;
-    }
-
-    FreePool (DevicePathInst);
-    DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
-  }
-
-  return FALSE;
-}
-
-/**
-  Check whether the terminal device path is in the global variable.
-
-  @param  VariableName          Pointer to one global variable.
-  @param  TerminalDevicePath    Pointer to the terminal device's device path.
-
-  @retval TRUE                  The devcie is in the global variable.
-  @retval FALSE                 The devcie is not in the global variable.
-
-**/
-BOOLEAN
-IsTerminalInConsoleVariable (
-  IN CHAR16                    *VariableName,
-  IN EFI_DEVICE_PATH_PROTOCOL  *TerminalDevicePath
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL  *Variable;
-  BOOLEAN                   ReturnFlag;
-
-  //
-  // Get global variable and its size according to the name given.
-  //
-  GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);
-  if (Variable == NULL) {
-    return FALSE;
-  }
-
-  //
-  // Check whether the terminal device path is one of the variable instances.
-  //
-  ReturnFlag = MatchDevicePaths (Variable, TerminalDevicePath);
-
-  FreePool (Variable);
-
-  return ReturnFlag;
-}
 
 /**
   Free notify functions list.
@@ -616,7 +468,8 @@ TerminalDriverBindingStart (
   EFI_STATUS                          Status;
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;
   EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;
-  VENDOR_DEVICE_PATH                  *Node;
+  EFI_DEVICE_PATH_PROTOCOL            *Vendor;
+  EFI_HANDLE                          SerialIoHandle;
   EFI_SERIAL_IO_MODE                  *Mode;
   UINTN                               SerialInTimeOut;
   TERMINAL_DEV                        *TerminalDevice;
@@ -624,23 +477,10 @@ TerminalDriverBindingStart (
   EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
   UINTN                               EntryCount;
   UINTN                               Index;
-  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL     *SimpleTextOutput;
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL      *SimpleTextInput;
-  BOOLEAN                             ConInSelected;
-  BOOLEAN                             ConOutSelected;
-  BOOLEAN                             NullRemaining;
-  BOOLEAN                             SimTxtInInstalled;
-  BOOLEAN                             SimTxtOutInstalled;
-  BOOLEAN                             FirstEnter;
-
-  TerminalDevice     = NULL;
-  ConInSelected      = FALSE;
-  ConOutSelected     = FALSE;
-  NullRemaining      = FALSE;
-  SimTxtInInstalled  = FALSE;
-  SimTxtOutInstalled = FALSE;
-  FirstEnter         = FALSE;
+  EFI_UNICODE_STRING_TABLE            *ControllerNameTable;
+
   //
   // Get the Device Path Protocol to build the device path of the child device
   //
@@ -652,9 +492,7 @@ TerminalDriverBindingStart (
                   Controller,
                   EFI_OPEN_PROTOCOL_BY_DRIVER
                   );
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
-    return Status;
-  }
+  ASSERT ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED));
 
   //
   // Open the Serial I/O Protocol BY_DRIVER.  It might already be started.
@@ -667,95 +505,37 @@ TerminalDriverBindingStart (
                   Controller,
                   EFI_OPEN_PROTOCOL_BY_DRIVER
                   );
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
-    return Status;
-  }
+  ASSERT ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED));
 
-  if (Status != EFI_ALREADY_STARTED) {
+  if (!IsHotPlugDevice (ParentDevicePath)) {
     //
-    // the serial I/O protocol never be opened before, it is the first
-    // time to start the serial Io controller
+    // if the serial device is a hot plug device, do not update the
+    // ConInDev, ConOutDev, and StdErrDev variables.
     //
-    FirstEnter = TRUE;
+    TerminalUpdateConsoleDevVariable (EFI_CON_IN_DEV_VARIABLE_NAME, ParentDevicePath);
+    TerminalUpdateConsoleDevVariable (EFI_CON_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
+    TerminalUpdateConsoleDevVariable (EFI_ERR_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
   }
 
   //
-  // Serial I/O is not already open by this driver, then tag the handle
-  // with the Terminal Driver GUID and update the ConInDev, ConOutDev, and
-  // StdErrDev variables with the list of possible terminal types on this
-  // serial port.
+  // Do not create any child for END remaining device path.
   //
-  Status = gBS->OpenProtocol (
-                  Controller,
-                  &gEfiCallerIdGuid,
-                  NULL,
-                  This->DriverBindingHandle,
-                  Controller,
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
-                  );
-  if (EFI_ERROR (Status)) {
-    Status = gBS->InstallMultipleProtocolInterfaces (
-                    &Controller,
-                    &gEfiCallerIdGuid,
-                    DuplicateDevicePath (ParentDevicePath),
-                    NULL
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
+  if ((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
+    return EFI_SUCCESS;
+  }
+
+  if (Status == EFI_ALREADY_STARTED) {
 
-    if (!IsHotPlugDevice (ParentDevicePath)) {
+    if (RemainingDevicePath == NULL) {
       //
-      // if the serial device is a hot plug device, do not update the
-      // ConInDev, ConOutDev, and StdErrDev variables.
+      // If RemainingDevicePath is NULL or is the End of Device Path Node
       //
-      TerminalUpdateConsoleDevVariable (L"ConInDev", ParentDevicePath);
-      TerminalUpdateConsoleDevVariable (L"ConOutDev", ParentDevicePath);
-      TerminalUpdateConsoleDevVariable (L"ErrOutDev", ParentDevicePath);
+      return EFI_SUCCESS;
     }
-  }
-
-  //
-  // Check the requirement for the SimpleTxtIn and SimpleTxtOut protocols
-  //
-  // Simple In/Out Protocol will not be installed onto the handle if the
-  // device path to the handle is not present in the ConIn/ConOut
-  // environment variable. But If RemainingDevicePath is NULL, then always
-  // produce both Simple In and Simple Text Output Protocols. This is required
-  // for the connect all sequences to make sure all possible consoles are
-  // produced no matter what the current values of ConIn, ConOut, or StdErr are.
-  //
-  if (RemainingDevicePath == NULL) {
-    NullRemaining = TRUE;
-  }
-
-  DevicePath = BuildTerminalDevpath (ParentDevicePath, RemainingDevicePath);
-  if (DevicePath != NULL) {
-    ConInSelected  = IsTerminalInConsoleVariable (L"ConIn", DevicePath);
-    ConOutSelected = IsTerminalInConsoleVariable (L"ConOut", DevicePath);
-    FreePool (DevicePath);
-  } else {
-    goto Error;
-  }
-  //
-  // Not create the child terminal handle if both Simple In/In Ex and
-  // Simple text Out protocols are not required to be published
-  //
-  if ((!ConInSelected)&&(!ConOutSelected)&&(!NullRemaining)) {
-    goto Error;
-  }
 
-  //
-  // create the child terminal handle during first entry
-  //
-  if (FirstEnter) {
     //
-    // First enther the start function
-    //
-    FirstEnter = FALSE;
-    //
-    // Make sure a child handle does not already exist.  This driver can only
-    // produce one child per serial port.
+    // This driver can only produce one child per serial port.
+    // Change its terminal type as remaining device path requests.
     //
     Status = gBS->OpenProtocolInformation (
                     Controller,
@@ -764,447 +544,312 @@ TerminalDriverBindingStart (
                     &EntryCount
                     );
     if (!EFI_ERROR (Status)) {
-      Status = EFI_SUCCESS;
+      Status = EFI_NOT_FOUND;
       for (Index = 0; Index < EntryCount; Index++) {
         if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
-          Status = EFI_ALREADY_STARTED;
+          Status = gBS->OpenProtocol (
+                          OpenInfoBuffer[Index].ControllerHandle,
+                          &gEfiSimpleTextInProtocolGuid,
+                          (VOID **) &SimpleTextInput,
+                          This->DriverBindingHandle,
+                          Controller,
+                          EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                          );
+          if (!EFI_ERROR (Status)) {
+            TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (SimpleTextInput);
+            TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid);
+            ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
+            if (TerminalDevice->TerminalType != TerminalType) {
+              Status = InitializeControllerNameTable (TerminalType, &ControllerNameTable);
+              if (!EFI_ERROR (Status)) {
+                StopTerminalStateMachine (TerminalDevice);
+                //
+                // Update the device path
+                //
+                Vendor = TerminalDevice->DevicePath;
+                Status = gBS->LocateDevicePath (&gEfiSerialIoProtocolGuid, &Vendor, &SerialIoHandle);
+                ASSERT_EFI_ERROR (Status);
+                CopyGuid (&((VENDOR_DEVICE_PATH *) Vendor)->Guid, mTerminalType[TerminalType]);
+                Status = gBS->ReinstallProtocolInterface (
+                                TerminalDevice->Handle,
+                                &gEfiDevicePathProtocolGuid,
+                                TerminalDevice->DevicePath,
+                                TerminalDevice->DevicePath
+                                );
+                if (!EFI_ERROR (Status)) {
+                  TerminalDevice->TerminalType = TerminalType;
+                  StartTerminalStateMachine (TerminalDevice);
+                  FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
+                  TerminalDevice->ControllerNameTable = ControllerNameTable;
+                } else {
+                  //
+                  // Restore the device path on failure
+                  //
+                  CopyGuid (&((VENDOR_DEVICE_PATH *) Vendor)->Guid, mTerminalType[TerminalDevice->TerminalType]);
+                  FreeUnicodeStringTable (ControllerNameTable);
+                }
+              }
+            }
+          }
+          break;
         }
       }
-
       FreePool (OpenInfoBuffer);
-      if (EFI_ERROR (Status)) {
-          goto Error;
-      }
-    }
-
-    //
-    // If RemainingDevicePath is NULL, use default terminal type
-    //
-    if (RemainingDevicePath == NULL) {
-      TerminalType = PcdGet8 (PcdDefaultTerminalType);
-    } else if (!IsDevicePathEnd (RemainingDevicePath)) {
-      //
-      // If RemainingDevicePath isn't the End of Device Path Node,
-      // Use the RemainingDevicePath to determine the terminal type
-      //
-      Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
-      TerminalType = TerminalTypeFromGuid (&Node->Guid);
-    } else {
-      //
-      // If RemainingDevicePath is the End of Device Path Node,
-      // skip enumerate any device and return EFI_SUCESSS
-      //
-      return EFI_SUCCESS;
-    }
-
-    ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
-
-    //
-    // Initialize the Terminal Dev
-    //
-    TerminalDevice = AllocateCopyPool (sizeof (TERMINAL_DEV), &mTerminalDevTemplate);
-    if (TerminalDevice == NULL) {
-      Status = EFI_OUT_OF_RESOURCES;
-      goto Error;
-    }
-
-    TerminalDevice->TerminalType  = TerminalType;
-    TerminalDevice->SerialIo      = SerialIo;
-
-    InitializeListHead (&TerminalDevice->NotifyList);
-    Status = gBS->CreateEvent (
-                    EVT_NOTIFY_WAIT,
-                    TPL_NOTIFY,
-                    TerminalConInWaitForKeyEx,
-                    TerminalDevice,
-                    &TerminalDevice->SimpleInputEx.WaitForKeyEx
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
-
-    Status = gBS->CreateEvent (
-                    EVT_NOTIFY_WAIT,
-                    TPL_NOTIFY,
-                    TerminalConInWaitForKey,
-                    TerminalDevice,
-                    &TerminalDevice->SimpleInput.WaitForKey
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
-    //
-    // Allocates and initializes the FIFO buffer to be zero, used for accommodating
-    // the pre-read pending characters.
-    //
-    TerminalDevice->RawFiFo     = AllocateZeroPool (sizeof (RAW_DATA_FIFO));
-    if (TerminalDevice->RawFiFo == NULL) {
-      goto Error;
-    }
-    TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));
-    if (TerminalDevice->UnicodeFiFo == NULL) {
-      goto Error;
-    }
-    TerminalDevice->EfiKeyFiFo  = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
-    if (TerminalDevice->EfiKeyFiFo == NULL) {
-      goto Error;
-    }
-    TerminalDevice->EfiKeyFiFoForNotify = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
-    if (TerminalDevice->EfiKeyFiFoForNotify == NULL) {
-      goto Error;
-    }
-
-    //
-    // Set the timeout value of serial buffer for
-    // keystroke response performance issue
-    //
-    Mode            = TerminalDevice->SerialIo->Mode;
-
-    SerialInTimeOut = 0;
-    if (Mode->BaudRate != 0) {
-      SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;
     }
+    return Status;
+  }
 
-    Status = TerminalDevice->SerialIo->SetAttributes (
-                                        TerminalDevice->SerialIo,
-                                        Mode->BaudRate,
-                                        Mode->ReceiveFifoDepth,
-                                        (UINT32) SerialInTimeOut,
-                                        (EFI_PARITY_TYPE) (Mode->Parity),
-                                        (UINT8) Mode->DataBits,
-                                        (EFI_STOP_BITS_TYPE) (Mode->StopBits)
-                                        );
-    if (EFI_ERROR (Status)) {
-      //
-      // if set attributes operation fails, invalidate
-      // the value of SerialInTimeOut,thus make it
-      // inconsistent with the default timeout value
-      // of serial buffer. This will invoke the recalculation
-      // in the readkeystroke routine.
-      //
-      TerminalDevice->SerialInTimeOut = 0;
-    } else {
-      TerminalDevice->SerialInTimeOut = SerialInTimeOut;
-    }
-    //
-    // Set Simple Text Output Protocol from template.
-    //
-    SimpleTextOutput = CopyMem (
-                         &TerminalDevice->SimpleTextOutput,
-                         &mTerminalDevTemplate.SimpleTextOutput,
-                         sizeof (mTerminalDevTemplate.SimpleTextOutput)
-                         );
-    SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
-    
-    TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
-                                                &SimpleTextOutput->Mode->MaxMode
-                                                );
-    if (TerminalDevice->TerminalConsoleModeData == NULL) {
-      goto ReportError;
-    }
+  //
+  // Initialize the Terminal Dev
+  //
+  TerminalDevice = AllocateCopyPool (sizeof (TERMINAL_DEV), &mTerminalDevTemplate);
+  if (TerminalDevice == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto CloseProtocols;
+  }
 
+  if (RemainingDevicePath == NULL) {
     //
-    // For terminal devices, cursor is always visible
+    // If RemainingDevicePath is NULL, use default terminal type
     //
-    TerminalDevice->SimpleTextOutputMode.CursorVisible = TRUE;
-    Status = TerminalConOutSetAttribute (
-               SimpleTextOutput,
-               EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)
-               );
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
-
+    TerminalDevice->TerminalType = PcdGet8 (PcdDefaultTerminalType);
+  } else {
     //
-    // Build the component name for the child device
+    // End of Device Path Node is handled in above.
     //
-    Status = InitializeControllerNameTable (TerminalDevice->TerminalType, &TerminalDevice->ControllerNameTable);
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
-
+    ASSERT (!IsDevicePathEnd (RemainingDevicePath));
     //
-    // Build the device path for the child device
+    // If RemainingDevicePath isn't the End of Device Path Node,
+    // Use the RemainingDevicePath to determine the terminal type
     //
-    Status = SetTerminalDevicePath (
-              TerminalDevice->TerminalType,
-              ParentDevicePath,
-              &TerminalDevice->DevicePath
-              );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
-
-    Status = TerminalConOutReset (SimpleTextOutput, FALSE);
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
-
-    Status = TerminalConOutSetMode (SimpleTextOutput, 0);
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
+    TerminalDevice->TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid);
+  }
+  ASSERT (TerminalDevice->TerminalType < ARRAY_SIZE (mTerminalType));
+  TerminalDevice->SerialIo = SerialIo;
 
-    Status = TerminalConOutEnableCursor (SimpleTextOutput, TRUE);
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
+  //
+  // Build the component name for the child device
+  //
+  Status = InitializeControllerNameTable (TerminalDevice->TerminalType, &TerminalDevice->ControllerNameTable);
+  if (EFI_ERROR (Status)) {
+    goto FreeResources;
+  }
 
-    StartTerminalStateMachine (TerminalDevice);
+  //
+  // Build the device path for the child device
+  //
+  Status = SetTerminalDevicePath (TerminalDevice->TerminalType, ParentDevicePath, &TerminalDevice->DevicePath);
+  if (EFI_ERROR (Status)) {
+    goto FreeResources;
+  }
 
-    Status = gBS->CreateEvent (
-                    EVT_NOTIFY_SIGNAL,
-                    TPL_CALLBACK,
-                    KeyNotifyProcessHandler,
-                    TerminalDevice,
-                    &TerminalDevice->KeyNotifyProcessEvent
-                    );
-    ASSERT_EFI_ERROR (Status);
+  InitializeListHead (&TerminalDevice->NotifyList);
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_WAIT,
+                  TPL_NOTIFY,
+                  TerminalConInWaitForKeyEx,
+                  TerminalDevice,
+                  &TerminalDevice->SimpleInputEx.WaitForKeyEx
+                  );
+  ASSERT_EFI_ERROR (Status);
 
-    Status = gBS->InstallProtocolInterface (
-                    &TerminalDevice->Handle,
-                    &gEfiDevicePathProtocolGuid,
-                    EFI_NATIVE_INTERFACE,
-                    TerminalDevice->DevicePath
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_WAIT,
+                  TPL_NOTIFY,
+                  TerminalConInWaitForKey,
+                  TerminalDevice,
+                  &TerminalDevice->SimpleInput.WaitForKey
+                  );
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_CALLBACK,
+                  KeyNotifyProcessHandler,
+                  TerminalDevice,
+                  &TerminalDevice->KeyNotifyProcessEvent
+                  );
+  ASSERT_EFI_ERROR (Status);
 
-    //
-    // Register the Parent-Child relationship via
-    // EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
-    //
-    Status = gBS->OpenProtocol (
-                    Controller,
-                    &gEfiSerialIoProtocolGuid,
-                    (VOID **) &TerminalDevice->SerialIo,
-                    This->DriverBindingHandle,
-                    TerminalDevice->Handle,
-                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
+  //
+  // Allocates and initializes the FIFO buffer to be zero, used for accommodating
+  // the pre-read pending characters.
+  //
+  TerminalDevice->RawFiFo = AllocateZeroPool (sizeof (RAW_DATA_FIFO));
+  if (TerminalDevice->RawFiFo == NULL) {
+    goto FreeResources;
+  }
+  TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));
+  if (TerminalDevice->UnicodeFiFo == NULL) {
+    goto FreeResources;
+  }
+  TerminalDevice->EfiKeyFiFo = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
+  if (TerminalDevice->EfiKeyFiFo == NULL) {
+    goto FreeResources;
+  }
+  TerminalDevice->EfiKeyFiFoForNotify = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
+  if (TerminalDevice->EfiKeyFiFoForNotify == NULL) {
+    goto FreeResources;
   }
 
   //
-  // Find the child handle, and get its TerminalDevice private data
+  // Set the timeout value of serial buffer for keystroke response performance issue
   //
-  Status = gBS->OpenProtocolInformation (
-                  Controller,
-                  &gEfiSerialIoProtocolGuid,
-                  &OpenInfoBuffer,
-                  &EntryCount
-                  );
-  if (!EFI_ERROR (Status)) {
-    Status = EFI_NOT_FOUND;
-    ASSERT (OpenInfoBuffer != NULL);
-    for (Index = 0; Index < EntryCount; Index++) {
-      if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
-        //
-        // Find the child terminal handle.
-        // Test whether the SimpleTxtIn and SimpleTxtOut have been published
-        //
-        Status = gBS->OpenProtocol (
-                        OpenInfoBuffer[Index].ControllerHandle,
-                        &gEfiSimpleTextInProtocolGuid,
-                        (VOID **) &SimpleTextInput,
-                        This->DriverBindingHandle,
-                        OpenInfoBuffer[Index].ControllerHandle,
-                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
-                        );
-        if (!EFI_ERROR (Status)) {
-          SimTxtInInstalled = TRUE;
-          TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (SimpleTextInput);
-        }
+  Mode = TerminalDevice->SerialIo->Mode;
 
-        Status = gBS->OpenProtocol (
-                        OpenInfoBuffer[Index].ControllerHandle,
-                        &gEfiSimpleTextOutProtocolGuid,
-                        (VOID **) &SimpleTextOutput,
-                        This->DriverBindingHandle,
-                        OpenInfoBuffer[Index].ControllerHandle,
-                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
-                        );
-        if (!EFI_ERROR (Status)) {
-          SimTxtOutInstalled = TRUE;
-          TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
-        }
-        Status = EFI_SUCCESS;
-        break;
-      }
-    }
+  SerialInTimeOut = 0;
+  if (Mode->BaudRate != 0) {
+    SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;
+  }
 
-    FreePool (OpenInfoBuffer);
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
+  Status = TerminalDevice->SerialIo->SetAttributes (
+                                       TerminalDevice->SerialIo,
+                                       Mode->BaudRate,
+                                       Mode->ReceiveFifoDepth,
+                                       (UINT32) SerialInTimeOut,
+                                       (EFI_PARITY_TYPE) (Mode->Parity),
+                                       (UINT8) Mode->DataBits,
+                                       (EFI_STOP_BITS_TYPE) (Mode->StopBits)
+                                       );
+  if (EFI_ERROR (Status)) {
+    //
+    // if set attributes operation fails, invalidate
+    // the value of SerialInTimeOut,thus make it
+    // inconsistent with the default timeout value
+    // of serial buffer. This will invoke the recalculation
+    // in the readkeystroke routine.
+    //
+    TerminalDevice->SerialInTimeOut = 0;
   } else {
-    goto ReportError;
+    TerminalDevice->SerialInTimeOut = SerialInTimeOut;
   }
 
-  ASSERT (TerminalDevice != NULL);
+  SimpleTextOutput = &TerminalDevice->SimpleTextOutput;
+  SimpleTextInput = &TerminalDevice->SimpleInput;
+
   //
-  // Only do the reset if the device path is in the Conout variable
+  // Initialize SimpleTextOut instance
   //
-  if (ConInSelected && !SimTxtInInstalled) {
-    Status = TerminalDevice->SimpleInput.Reset (
-                                          &TerminalDevice->SimpleInput,
-                                          FALSE
-                                          );
-    if (EFI_ERROR (Status)) {
-      //
-      // Need to report Error Code first
-      //
-      goto ReportError;
-    }
+  SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
+  TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
+    &SimpleTextOutput->Mode->MaxMode
+  );
+  if (TerminalDevice->TerminalConsoleModeData == NULL) {
+    goto FreeResources;
   }
-
   //
-  // Only output the configure string to remote terminal if the device path
-  // is in the Conout variable
+  // For terminal devices, cursor is always visible
   //
-  if (ConOutSelected && !SimTxtOutInstalled) {
-    Status = TerminalDevice->SimpleTextOutput.SetAttribute (
-                                                        &TerminalDevice->SimpleTextOutput,
-                                                        EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)
-                                                        );
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
-
-    Status = TerminalDevice->SimpleTextOutput.Reset (
-                                                &TerminalDevice->SimpleTextOutput,
-                                                FALSE
-                                                );
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
-
-    Status = TerminalDevice->SimpleTextOutput.SetMode (
-                                                &TerminalDevice->SimpleTextOutput,
-                                                0
-                                                );
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
-
-    Status = TerminalDevice->SimpleTextOutput.EnableCursor (
-                                                &TerminalDevice->SimpleTextOutput,
-                                                TRUE
-                                                );
-    if (EFI_ERROR (Status)) {
-      goto ReportError;
-    }
+  SimpleTextOutput->Mode->CursorVisible = TRUE;
+  Status = SimpleTextOutput->SetAttribute (SimpleTextOutput, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
+  if (!EFI_ERROR (Status)) {
+    Status = SimpleTextOutput->Reset (SimpleTextOutput, FALSE);
+  }
+  if (EFI_ERROR (Status)) {
+    goto ReportError;
   }
 
   //
-  // Simple In/Out Protocol will not be installed onto the handle if the
-  // device path to the handle is not present in the ConIn/ConOut
-  // environment variable. But If RemainingDevicePath is NULL, then always
-  // produce both Simple In and Simple Text Output Protocols. This is required
-  // for the connect all sequences to make sure all possible consoles are
-  // produced no matter what the current values of ConIn, ConOut, or StdErr are.
+  // Initialize SimpleTextInput instance
   //
-  if (!SimTxtInInstalled && (ConInSelected || NullRemaining)) {
-    Status = gBS->InstallMultipleProtocolInterfaces (
-                    &TerminalDevice->Handle,
-                    &gEfiSimpleTextInProtocolGuid,
-                    &TerminalDevice->SimpleInput,
-                    &gEfiSimpleTextInputExProtocolGuid,
-                    &TerminalDevice->SimpleInputEx,
-                    NULL
-                    );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
+  Status = SimpleTextInput->Reset (SimpleTextInput, FALSE);
+  if (EFI_ERROR (Status)) {
+    goto ReportError;
   }
 
-  if (!SimTxtOutInstalled && (ConOutSelected || NullRemaining)) {
-    Status = gBS->InstallProtocolInterface (
-                    &TerminalDevice->Handle,
-                    &gEfiSimpleTextOutProtocolGuid,
-                    EFI_NATIVE_INTERFACE,
-                    &TerminalDevice->SimpleTextOutput
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &TerminalDevice->Handle,
+                  &gEfiSimpleTextInProtocolGuid,      &TerminalDevice->SimpleInput,
+                  &gEfiSimpleTextInputExProtocolGuid, &TerminalDevice->SimpleInputEx,
+                  &gEfiSimpleTextOutProtocolGuid,     &TerminalDevice->SimpleTextOutput,
+                  &gEfiDevicePathProtocolGuid,        TerminalDevice->DevicePath,
+                  NULL
+                  );
+  if (!EFI_ERROR (Status)) {
+    Status = gBS->OpenProtocol (
+                    Controller,
+                    &gEfiSerialIoProtocolGuid,
+                    (VOID **) &TerminalDevice->SerialIo,
+                    This->DriverBindingHandle,
+                    TerminalDevice->Handle,
+                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
                     );
-    if (EFI_ERROR (Status)) {
-      goto Error;
-    }
+    ASSERT_EFI_ERROR (Status);
+    StartTerminalStateMachine (TerminalDevice);
+    return Status;
   }
 
-  return EFI_SUCCESS;
-
 ReportError:
-  //
-  // Report error code before exiting
-  //
-  DevicePath = ParentDevicePath;
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (
     EFI_ERROR_CODE | EFI_ERROR_MINOR,
     (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_CONTROLLER_ERROR),
-    DevicePath
+    ParentDevicePath
     );
 
-Error:
-  //
-  // Use the Stop() function to free all resources allocated in Start()
-  //
-  if (TerminalDevice != NULL) {
-
-    if (TerminalDevice->Handle != NULL) {
-      This->Stop (This, Controller, 1, &TerminalDevice->Handle);
-    } else {
-
-      if (TerminalDevice->TwoSecondTimeOut != NULL) {
-        gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
-      }
+FreeResources:
+  ASSERT (TerminalDevice != NULL);
 
-      if (TerminalDevice->TimerEvent != NULL) {
-        gBS->CloseEvent (TerminalDevice->TimerEvent);
-      }
+  if (TerminalDevice->SimpleInput.WaitForKey != NULL) {
+    gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
+  }
+  if (TerminalDevice->SimpleInputEx.WaitForKeyEx != NULL) {
+    gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
+  }
+  if (TerminalDevice->KeyNotifyProcessEvent != NULL) {
+    gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);
+  }
 
-      if (TerminalDevice->SimpleInput.WaitForKey != NULL) {
-        gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
-      }
+  if (TerminalDevice->RawFiFo != NULL) {
+    FreePool (TerminalDevice->RawFiFo);
+  }
+  if (TerminalDevice->UnicodeFiFo != NULL) {
+    FreePool (TerminalDevice->UnicodeFiFo);
+  }
+  if (TerminalDevice->EfiKeyFiFo != NULL) {
+    FreePool (TerminalDevice->EfiKeyFiFo);
+  }
+  if (TerminalDevice->EfiKeyFiFoForNotify != NULL) {
+    FreePool (TerminalDevice->EfiKeyFiFoForNotify);
+  }
 
-      if (TerminalDevice->SimpleInputEx.WaitForKeyEx != NULL) {
-        gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
-      }
+  if (TerminalDevice->ControllerNameTable != NULL) {
+    FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
+  }
 
-      TerminalFreeNotifyList (&TerminalDevice->NotifyList);
+  if (TerminalDevice->DevicePath != NULL) {
+    FreePool (TerminalDevice->DevicePath);
+  }
 
-      if (TerminalDevice->RawFiFo != NULL) {
-        FreePool (TerminalDevice->RawFiFo);
-      }
-      if (TerminalDevice->UnicodeFiFo != NULL) {
-        FreePool (TerminalDevice->UnicodeFiFo);
-      }
-      if (TerminalDevice->EfiKeyFiFo != NULL) {
-        FreePool (TerminalDevice->EfiKeyFiFo);
-      }
-      if (TerminalDevice->EfiKeyFiFoForNotify != NULL) {
-        FreePool (TerminalDevice->EfiKeyFiFoForNotify);
-      }
-  
-      if (TerminalDevice->ControllerNameTable != NULL) {
-        FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
-      }
+  if (TerminalDevice->TerminalConsoleModeData != NULL) {
+    FreePool (TerminalDevice->TerminalConsoleModeData);
+  }
 
-      if (TerminalDevice->DevicePath != NULL) {
-        FreePool (TerminalDevice->DevicePath);
-      }
+  FreePool (TerminalDevice);
 
-      if (TerminalDevice->TerminalConsoleModeData != NULL) {
-        FreePool (TerminalDevice->TerminalConsoleModeData);
-      }
+CloseProtocols:
 
-      FreePool (TerminalDevice);
-    }
-  }
+  //
+  // Remove Parent Device Path from
+  // the Console Device Environment Variables
+  //
+  TerminalRemoveConsoleDevVariable (EFI_CON_IN_DEV_VARIABLE_NAME, ParentDevicePath);
+  TerminalRemoveConsoleDevVariable (EFI_CON_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
+  TerminalRemoveConsoleDevVariable (EFI_ERR_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
 
-  This->Stop (This, Controller, 0, NULL);
+  Status = gBS->CloseProtocol (
+                  Controller,
+                  &gEfiSerialIoProtocolGuid,
+                  This->DriverBindingHandle,
+                  Controller
+                  );
+  ASSERT_EFI_ERROR (Status);
 
+  Status = gBS->CloseProtocol (
+                  Controller,
+                  &gEfiDevicePathProtocolGuid,
+                  This->DriverBindingHandle,
+                  Controller
+                  );
+  ASSERT_EFI_ERROR (Status);
   return Status;
 }
 
@@ -1239,16 +884,6 @@ TerminalDriverBindingStop (
   TERMINAL_DEV                     *TerminalDevice;
   EFI_DEVICE_PATH_PROTOCOL         *ParentDevicePath;
   EFI_SERIAL_IO_PROTOCOL           *SerialIo;
-  EFI_DEVICE_PATH_PROTOCOL         *DevicePath;
-
-  Status = gBS->HandleProtocol (
-                  Controller,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID **) &DevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
 
   //
   // Complete all outstanding transactions to Controller.
@@ -1260,38 +895,21 @@ TerminalDriverBindingStop (
     //
     Status = gBS->OpenProtocol (
                     Controller,
-                    &gEfiCallerIdGuid,
+                    &gEfiDevicePathProtocolGuid,
                     (VOID **) &ParentDevicePath,
                     This->DriverBindingHandle,
                     Controller,
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL
                     );
-    if (!EFI_ERROR (Status)) {
-      //
-      // Remove Parent Device Path from
-      // the Console Device Environment Variables
-      //
-      TerminalRemoveConsoleDevVariable (L"ConInDev", ParentDevicePath);
-      TerminalRemoveConsoleDevVariable (L"ConOutDev", ParentDevicePath);
-      TerminalRemoveConsoleDevVariable (L"ErrOutDev", ParentDevicePath);
-
-      //
-      // Uninstall the Terminal Driver's GUID Tag from the Serial controller
-      //
-      Status = gBS->UninstallMultipleProtocolInterfaces (
-                      Controller,
-                      &gEfiCallerIdGuid,
-                      ParentDevicePath,
-                      NULL
-                      );
+    ASSERT_EFI_ERROR (Status);
 
-      //
-      // Free the ParentDevicePath that was duplicated in Start()
-      //
-      if (!EFI_ERROR (Status)) {
-        FreePool (ParentDevicePath);
-      }
-    }
+    //
+    // Remove Parent Device Path from
+    // the Console Device Environment Variables
+    //
+    TerminalRemoveConsoleDevVariable (EFI_CON_IN_DEV_VARIABLE_NAME, ParentDevicePath);
+    TerminalRemoveConsoleDevVariable (EFI_CON_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
+    TerminalRemoveConsoleDevVariable (EFI_ERR_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
 
     gBS->CloseProtocol (
           Controller,
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types
  2017-01-10  8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
@ 2017-01-11  7:32   ` Tian, Feng
  0 siblings, 0 replies; 12+ messages in thread
From: Tian, Feng @ 2017-01-11  7:32 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zeng, Star, Tian, Feng

Series reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: Ni, Ruiyu 
Sent: Tuesday, January 10, 2017 4:39 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Tian, Feng <feng.tian@intel.com>
Subject: [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
 .../Universal/Console/TerminalDxe/Terminal.c       | 50 ++++++------
 .../Universal/Console/TerminalDxe/Terminal.h       | 14 ++--
 .../Universal/Console/TerminalDxe/TerminalConIn.c  | 88 +++++++++++-----------  .../Universal/Console/TerminalDxe/TerminalConOut.c | 28 +++----
 4 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index a209bf3..1c1f5e1 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
   Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
   Simple Text Output Protocol upon Serial IO Protocol.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License  which accompanies this distribution.  The full text of the license may be found at @@ -270,23 +270,23 @@ BuildTerminalDevpath  (
 
   } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
 
-    TerminalType = PCANSITYPE;
+    TerminalType = TerminalTypePcAnsi;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
 
-    TerminalType = VT100TYPE;
+    TerminalType = TerminalTypeVt100;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
 
-    TerminalType = VT100PLUSTYPE;
+    TerminalType = TerminalTypeVt100Plus;
 
   } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
 
-    TerminalType = VTUTF8TYPE;
+    TerminalType = TerminalTypeVtUtf8;
 
   } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
 
-    TerminalType = TTYTERMTYPE;
+    TerminalType = TerminalTypeTtyTerm;
 
   } else {
     return NULL;
@@ -713,9 +713,9 @@ TerminalDriverBindingStart (
     if (RemainingDevicePath == NULL) {
       TerminalType = PcdGet8 (PcdDefaultTerminalType);
       //
-      // Must be between PCANSITYPE (0) and TTYTERMTYPE (4)
+      // Must be between TerminalTypePcAnsi (0) and TerminalTypeTtyTerm 
+ (4)
       //
-      ASSERT (TerminalType <= TTYTERMTYPE);
+      ASSERT (TerminalType <= TerminalTypeTtyTerm);
     } else if (!IsDevicePathEnd (RemainingDevicePath)) {
       //
       // If RemainingDevicePath isn't the End of Device Path Node, @@ -723,15 +723,15 @@ TerminalDriverBindingStart (
       //
       Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
       if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {
-        TerminalType = PCANSITYPE;
+        TerminalType = TerminalTypePcAnsi;
       } else if (CompareGuid (&Node->Guid, &gEfiVT100Guid)) {
-        TerminalType = VT100TYPE;
+        TerminalType = TerminalTypeVt100;
       } else if (CompareGuid (&Node->Guid, &gEfiVT100PlusGuid)) {
-        TerminalType = VT100PLUSTYPE;
+        TerminalType = TerminalTypeVt100Plus;
       } else if (CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {
-        TerminalType = VTUTF8TYPE;
+        TerminalType = TerminalTypeVtUtf8;
       } else if (CompareGuid (&Node->Guid, &gEfiTtyTermGuid)) {
-        TerminalType = TTYTERMTYPE;
+        TerminalType = TerminalTypeTtyTerm;
       } else {
         goto Error;
       }
@@ -863,7 +863,7 @@ TerminalDriverBindingStart (
     //
     TerminalDevice->ControllerNameTable = NULL;
     switch (TerminalDevice->TerminalType) {
-    case PCANSITYPE:
+    case TerminalTypePcAnsi:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -881,7 +881,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VT100TYPE:
+    case TerminalTypeVt100:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -899,7 +899,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VT100PLUSTYPE:
+    case TerminalTypeVt100Plus:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -917,7 +917,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case VTUTF8TYPE:
+    case TerminalTypeVtUtf8:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -935,7 +935,7 @@ TerminalDriverBindingStart (
 
       break;
 
-    case TTYTERMTYPE:
+    case TerminalTypeTtyTerm:
       AddUnicodeString2 (
         "eng",
         gTerminalComponentName.SupportedLanguages,
@@ -1473,7 +1473,7 @@ TerminalUpdateConsoleDevVariable (
   //
   // Append terminal device path onto the variable.
   //
-  for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {
+  for (TerminalType = TerminalTypePcAnsi; TerminalType <= 
+ TerminalTypeTtyTerm; TerminalType++) {
     SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
     NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
     ASSERT (NewVariable != NULL);
@@ -1586,7 +1586,7 @@ TerminalRemoveConsoleDevVariable (
     // Loop through all the terminal types that this driver supports
     //
     Match = FALSE;
-    for (TerminalType = PCANSITYPE; TerminalType <= TTYTERMTYPE; TerminalType++) {
+    for (TerminalType = TerminalTypePcAnsi; TerminalType <= 
+ TerminalTypeTtyTerm; TerminalType++) {
 
       SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
 
@@ -1674,23 +1674,23 @@ SetTerminalDevicePath (
   //
   switch (TerminalType) {
 
-  case PCANSITYPE:
+  case TerminalTypePcAnsi:
     CopyGuid (&Node.Guid, &gEfiPcAnsiGuid);
     break;
 
-  case VT100TYPE:
+  case TerminalTypeVt100:
     CopyGuid (&Node.Guid, &gEfiVT100Guid);
     break;
 
-  case VT100PLUSTYPE:
+  case TerminalTypeVt100Plus:
     CopyGuid (&Node.Guid, &gEfiVT100PlusGuid);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);
     break;
 
-  case TTYTERMTYPE:
+  case TerminalTypeTtyTerm:
     CopyGuid (&Node.Guid, &gEfiTtyTermGuid);
     break;
 
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index e16b89c..fff3281 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for Terminal driver.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>  This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License @@ -139,11 +139,13 @@ typedef union {
   UINT8 Utf8_3[3];
 } UTF8_CHAR;
 
-#define PCANSITYPE                0
-#define VT100TYPE                 1
-#define VT100PLUSTYPE             2
-#define VTUTF8TYPE                3
-#define TTYTERMTYPE               4
+typedef enum {
+  TerminalTypePcAnsi,
+  TerminalTypeVt100,
+  TerminalTypeVt100Plus,
+  TerminalTypeVtUtf8,
+  TerminalTypeTtyTerm
+} TERMINAL_TYPE;
 
 #define LEFTOPENBRACKET           0x5b  // '['
 #define ACAP                      0x41
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 0162410..1392f16 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -2,7 +2,7 @@
   Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.
 
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>  This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License @@ -453,15 +453,15 @@ TranslateRawDataToEfiKey (  {
   switch (TerminalDevice->TerminalType) {
 
-  case PCANSITYPE:
-  case VT100TYPE:
-  case VT100PLUSTYPE:
-  case TTYTERMTYPE:
+  case TerminalTypePcAnsi:
+  case TerminalTypeVt100:
+  case TerminalTypeVt100Plus:
+  case TerminalTypeTtyTerm:
     AnsiRawDataToUnicode (TerminalDevice);
     UnicodeToEfiKey (TerminalDevice);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     //
     // Process all the raw data in the RawFIFO,
     // put the processed key into UnicodeFIFO.
@@ -1405,8 +1405,8 @@ UnicodeToEfiKey (
         continue;
       }
 
-      if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == VT100TYPE ||
-                                 TerminalDevice->TerminalType == TTYTERMTYPE)) {
+      if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
+                                 TerminalDevice->TerminalType == 
+ TerminalTypeTtyTerm)) {
         TerminalDevice->InputState |= INPUT_STATE_O;
         TerminalDevice->ResetState = RESET_STATE_DEFAULT;
         continue;
@@ -1414,8 +1414,8 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == VT100PLUSTYPE ||
-          TerminalDevice->TerminalType == VTUTF8TYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8) {
         switch (UnicodeChar) {
         case '1':
           Key.ScanCode = SCAN_F1;
@@ -1519,7 +1519,7 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == VT100TYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeVt100) {
         switch (UnicodeChar) {
         case 'P':
           Key.ScanCode = SCAN_F1;
@@ -1554,7 +1554,7 @@ UnicodeToEfiKey (
         default :
           break;
         }
-      } else if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      } else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         /* Also accept VT100 escape codes for F1-F4, HOME and END for TTY term */
         switch (UnicodeChar) {
         case 'P':
@@ -1596,11 +1596,11 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
-      if (TerminalDevice->TerminalType == PCANSITYPE    ||
-          TerminalDevice->TerminalType == VT100TYPE     ||
-          TerminalDevice->TerminalType == VT100PLUSTYPE ||
-          TerminalDevice->TerminalType == VTUTF8TYPE    ||
-          TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypePcAnsi    ||
+          TerminalDevice->TerminalType == TerminalTypeVt100     ||
+          TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8    ||
+          TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         switch (UnicodeChar) {
         case 'A':
           Key.ScanCode = SCAN_UP;
@@ -1615,104 +1615,104 @@ UnicodeToEfiKey (
           Key.ScanCode = SCAN_LEFT;
           break;
         case 'H':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == VT100TYPE  ||
-              TerminalDevice->TerminalType == TTYTERMTYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeVt100  ||
+              TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
             Key.ScanCode = SCAN_HOME;
           }
           break;
         case 'F':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == TTYTERMTYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
             Key.ScanCode = SCAN_END;
           }
           break;
         case 'K':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_END;
           }
           break;
         case 'L':
         case '@':
-          if (TerminalDevice->TerminalType == PCANSITYPE ||
-              TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+              TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_INSERT;
           }
           break;
         case 'X':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_DELETE;
           }
           break;
         case 'P':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_DELETE;
-          } else if (TerminalDevice->TerminalType == PCANSITYPE) {
+          } else if (TerminalDevice->TerminalType == 
+ TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F4;
           }
           break;
         case 'I':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_PAGE_UP;
           }
           break;
         case 'V':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F10;
           }
           break;
         case '?':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_PAGE_UP;
           }
           break;
         case 'G':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_PAGE_DOWN;
           }
           break;
         case 'U':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F9;
           }
           break;
         case '/':
-          if (TerminalDevice->TerminalType == VT100TYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypeVt100) {
             Key.ScanCode = SCAN_PAGE_DOWN;
           }
           break;
         case 'M':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F1;
           }
           break;
         case 'N':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F2;
           }
           break;
         case 'O':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F3;
           }
           break;
         case 'Q':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F5;
           }
           break;
         case 'R':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F6;
           }
           break;
         case 'S':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F7;
           }
           break;
         case 'T':
-          if (TerminalDevice->TerminalType == PCANSITYPE) {
+          if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
             Key.ScanCode = SCAN_F8;
           }
           break;
@@ -1726,7 +1726,7 @@ UnicodeToEfiKey (
        * numeric codes, and there are no ambiguous prefixes shared with
        * other terminal types.
        */
-      if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
           Key.ScanCode == SCAN_NULL &&
           UnicodeChar >= '0' &&
           UnicodeChar <= '9') {
@@ -1755,7 +1755,7 @@ UnicodeToEfiKey (
        * state is only used by the TTY terminal type.
        */
       Key.ScanCode = SCAN_NULL;
-      if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
 
         if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) {
           UINT16 EscCode;
@@ -1851,7 +1851,7 @@ UnicodeToEfiKey (
     }
 
     if (UnicodeChar == DEL) {
-      if (TerminalDevice->TerminalType == TTYTERMTYPE) {
+      if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
         Key.ScanCode    = SCAN_NULL;
         Key.UnicodeChar = CHAR_BACKSPACE;
       }
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index c9b4ffc..e677a76 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
 
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>  This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License @@ -224,10 +224,10 @@ TerminalConOutOutputString (
 
     switch (TerminalDevice->TerminalType) {
 
-    case PCANSITYPE:
-    case VT100TYPE:
-    case VT100PLUSTYPE:
-    case TTYTERMTYPE:
+    case TerminalTypePcAnsi:
+    case TerminalTypeVt100:
+    case TerminalTypeVt100Plus:
+    case TerminalTypeTtyTerm:
 
       if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
         //
@@ -253,7 +253,7 @@ TerminalConOutOutputString (
 
       }
 
-      if (TerminalDevice->TerminalType != PCANSITYPE) {
+      if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
         GraphicChar = AsciiChar;
       }
 
@@ -271,7 +271,7 @@ TerminalConOutOutputString (
 
       break;
 
-    case VTUTF8TYPE:
+    case TerminalTypeVtUtf8:
       UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
       Length = ValidBytes;
       Status = TerminalDevice->SerialIo->Write ( @@ -317,7 +317,7 @@ TerminalConOutOutputString (
           Mode->CursorRow++;
         }
 
-        if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+        if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
             !TerminalDevice->OutputEscChar) {
           //
           // We've written the last character on the line.  The @@ -398,14 +398,14 @@ TerminalConOutTestString (
 
   switch (TerminalDevice->TerminalType) {
 
-  case PCANSITYPE:
-  case VT100TYPE:
-  case VT100PLUSTYPE:
-  case TTYTERMTYPE:
+  case TerminalTypePcAnsi:
+  case TerminalTypeVt100:
+  case TerminalTypeVt100Plus:
+  case TerminalTypeTtyTerm:
     Status = AnsiTestString (TerminalDevice, WString);
     break;
 
-  case VTUTF8TYPE:
+  case TerminalTypeVtUtf8:
     Status = VTUTF8TestString (TerminalDevice, WString);
     break;
 
@@ -791,7 +791,7 @@ TerminalConOutSetCursorPosition (
   // within the current line if possible, and don't output anyting if
   // it isn't necessary.
   //
-  if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+  if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
       (UINTN)Mode->CursorRow == Row) {
     if ((UINTN)Mode->CursorColumn > Column) {
       mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10));
--
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode
  2017-01-10  8:39 ` [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode Ruiyu Ni
@ 2017-01-12 10:41   ` Laszlo Ersek
  2017-01-12 15:39     ` Ni, Ruiyu
  0 siblings, 1 reply; 12+ messages in thread
From: Laszlo Ersek @ 2017-01-12 10:41 UTC (permalink / raw)
  To: Ruiyu Ni, edk2-devel; +Cc: Feng Tian, Star Zeng

Ray,

sorry for the late followup, I just noticed a (trivial) omission in the
patch:

On 01/10/17 09:39, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> ---
>  .../Universal/Console/TerminalDxe/Terminal.c       | 108 +++++----------------
>  1 file changed, 26 insertions(+), 82 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> index f1ce12d..4b0c00d 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> @@ -113,6 +113,8 @@ TERMINAL_DEV  mTerminalDevTemplate = {
>  };
>  
>  TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
> +  {80,  25},
> +  {80,  50},
>    {100, 31},
>    //
>    // New modes can be added here.
> @@ -450,97 +452,39 @@ TerminalFreeNotifyList (
>    It returns information for available text modes that the terminal can support.
>  
>    @param[out] TextModeCount      The total number of text modes that terminal console supports.
> -  @param[out] TextModeData       The buffer to the text modes column and row information.
> -                                 Caller is responsible to free it when it's non-NULL.
>  
> -  @retval EFI_SUCCESS            The supporting mode information is returned.
> -  @retval EFI_INVALID_PARAMETER  The parameters are invalid.
> +  @return   The buffer to the text modes column and row information.
> +            Caller is responsible to free it when it's non-NULL.
>  
>  **/
> -EFI_STATUS
> +TERMINAL_CONSOLE_MODE_DATA *
>  InitializeTerminalConsoleTextMode (
> -  OUT UINTN                         *TextModeCount,
> -  OUT TERMINAL_CONSOLE_MODE_DATA    **TextModeData
> -  )
> +  OUT INT32                         *TextModeCount
> +)
>  {
> -  UINTN                       Index;
> -  UINTN                       Count;
> -  TERMINAL_CONSOLE_MODE_DATA  *ModeBuffer;
> -  TERMINAL_CONSOLE_MODE_DATA  *NewModeBuffer;
> -  UINTN                       ValidCount;
> -  UINTN                       ValidIndex;
> -  
> -  if ((TextModeCount == NULL) || (TextModeData == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -  
> -  Count = sizeof (mTerminalConsoleModeData) / sizeof (TERMINAL_CONSOLE_MODE_DATA);
> -  
> -  //
> -  // Get defined mode buffer pointer.
> -  //
> -  ModeBuffer = mTerminalConsoleModeData;
> -    
> +  TERMINAL_CONSOLE_MODE_DATA  *TextModeData;
> +
> +  ASSERT (TextModeCount != NULL);
> +
>    //
>    // Here we make sure that the final mode exposed does not include the duplicated modes,
>    // and does not include the invalid modes which exceed the max column and row.
>    // Reserve 2 modes for 80x25, 80x50 of terminal console.
>    //

This comment too should have been removed, given that no reservation
occurs any longer; the 80x25 and 80x50 modes have been moved to
"mTerminalConsoleModeData", and are copied like all the other modes in
that array, with AllocateCopyPool().

Thanks
Laszlo


> -  NewModeBuffer = AllocateZeroPool (sizeof (TERMINAL_CONSOLE_MODE_DATA) * (Count + 2));
> -  ASSERT (NewModeBuffer != NULL);
> -
> -  //
> -  // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
> -  //
> -  ValidCount = 0;  
> -
> -  NewModeBuffer[ValidCount].Columns = 80;
> -  NewModeBuffer[ValidCount].Rows    = 25;
> -  ValidCount++;
> -
> -  NewModeBuffer[ValidCount].Columns = 80;
> -  NewModeBuffer[ValidCount].Rows    = 50;
> -  ValidCount++;
> -  
> -  //
> -  // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
> -  //
> -  for (Index = 0; Index < Count; Index++) {
> -    if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0)) {
> -      //
> -      // Skip the pre-defined mode which is invalid.
> -      //
> -      continue;
> -    }
> -    for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
> -      if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
> -          (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
> -        //
> -        // Skip the duplicated mode.
> -        //
> -        break;
> -      }
> -    }
> -    if (ValidIndex == ValidCount) {
> -      NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
> -      NewModeBuffer[ValidCount].Rows    = ModeBuffer[Index].Rows;
> -      ValidCount++;
> -    }
> +  TextModeData = AllocateCopyPool (sizeof (mTerminalConsoleModeData), mTerminalConsoleModeData);
> +  if (TextModeData == NULL) {
> +    return NULL;
>    }
> - 
> +  *TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData);
> +
>    DEBUG_CODE (
> -    for (Index = 0; Index < ValidCount; Index++) {
> -      DEBUG ((EFI_D_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n", 
> -                           Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));  
> +    INT32 Index;
> +    for (Index = 0; Index < *TextModeCount; Index++) {
> +      DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
> +              Index, TextModeData[Index].Columns, TextModeData[Index].Rows));
>      }
>    );
> -  
> -  //
> -  // Return valid mode count and mode information buffer.
> -  //
> -  *TextModeCount = ValidCount;
> -  *TextModeData  = NewModeBuffer;
> -  return EFI_SUCCESS;
> +  return TextModeData;
>  }
>  
>  /**
> @@ -632,7 +576,6 @@ TerminalDriverBindingStart (
>    BOOLEAN                             SimTxtInInstalled;
>    BOOLEAN                             SimTxtOutInstalled;
>    BOOLEAN                             FirstEnter;
> -  UINTN                               ModeCount;
>  
>    TerminalDevice     = NULL;
>    ConInSelected      = FALSE;
> @@ -896,12 +839,13 @@ TerminalDriverBindingStart (
>                           );
>      SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
>      
> -    Status = InitializeTerminalConsoleTextMode (&ModeCount, &TerminalDevice->TerminalConsoleModeData);
> -    if (EFI_ERROR (Status)) {
> +    TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
> +                                                &SimpleTextOutput->Mode->MaxMode
> +                                                );
> +    if (TerminalDevice->TerminalConsoleModeData == NULL) {
>        goto ReportError;
>      }
> -    TerminalDevice->SimpleTextOutputMode.MaxMode = (INT32) ModeCount;
> -    
> +
>      //
>      // For terminal devices, cursor is always visible
>      //
> 



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode
  2017-01-12 10:41   ` Laszlo Ersek
@ 2017-01-12 15:39     ` Ni, Ruiyu
  0 siblings, 0 replies; 12+ messages in thread
From: Ni, Ruiyu @ 2017-01-12 15:39 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel@ml01.01.org; +Cc: Tian, Feng, Zeng, Star

Laszlo,
Thanks for your reply.
I will remove the comments in C function.

Regards,
Ray

From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Thursday, January 12, 2017 6:42 PM
To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@ml01.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: Re: [edk2] [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode

Ray,

sorry for the late followup, I just noticed a (trivial) omission in the
patch:

On 01/10/17 09:39, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
> Cc: Star Zeng <star.zeng@intel.com<mailto:star.zeng@intel.com>>
> Cc: Feng Tian <feng.tian@intel.com<mailto:feng.tian@intel.com>>
> ---
>  .../Universal/Console/TerminalDxe/Terminal.c       | 108 +++++----------------
>  1 file changed, 26 insertions(+), 82 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> index f1ce12d..4b0c00d 100644
> --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
> @@ -113,6 +113,8 @@ TERMINAL_DEV  mTerminalDevTemplate = {
>  };
>
>  TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
> +  {80,  25},
> +  {80,  50},
>    {100, 31},
>    //
>    // New modes can be added here.
> @@ -450,97 +452,39 @@ TerminalFreeNotifyList (
>    It returns information for available text modes that the terminal can support.
>
>    @param[out] TextModeCount      The total number of text modes that terminal console supports.
> -  @param[out] TextModeData       The buffer to the text modes column and row information.
> -                                 Caller is responsible to free it when it's non-NULL.
>
> -  @retval EFI_SUCCESS            The supporting mode information is returned.
> -  @retval EFI_INVALID_PARAMETER  The parameters are invalid.
> +  @return   The buffer to the text modes column and row information.
> +            Caller is responsible to free it when it's non-NULL.
>
>  **/
> -EFI_STATUS
> +TERMINAL_CONSOLE_MODE_DATA *
>  InitializeTerminalConsoleTextMode (
> -  OUT UINTN                         *TextModeCount,
> -  OUT TERMINAL_CONSOLE_MODE_DATA    **TextModeData
> -  )
> +  OUT INT32                         *TextModeCount
> +)
>  {
> -  UINTN                       Index;
> -  UINTN                       Count;
> -  TERMINAL_CONSOLE_MODE_DATA  *ModeBuffer;
> -  TERMINAL_CONSOLE_MODE_DATA  *NewModeBuffer;
> -  UINTN                       ValidCount;
> -  UINTN                       ValidIndex;
> -
> -  if ((TextModeCount == NULL) || (TextModeData == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  Count = sizeof (mTerminalConsoleModeData) / sizeof (TERMINAL_CONSOLE_MODE_DATA);
> -
> -  //
> -  // Get defined mode buffer pointer.
> -  //
> -  ModeBuffer = mTerminalConsoleModeData;
> -
> +  TERMINAL_CONSOLE_MODE_DATA  *TextModeData;
> +
> +  ASSERT (TextModeCount != NULL);
> +
>    //
>    // Here we make sure that the final mode exposed does not include the duplicated modes,
>    // and does not include the invalid modes which exceed the max column and row.
>    // Reserve 2 modes for 80x25, 80x50 of terminal console.
>    //

This comment too should have been removed, given that no reservation
occurs any longer; the 80x25 and 80x50 modes have been moved to
"mTerminalConsoleModeData", and are copied like all the other modes in
that array, with AllocateCopyPool().

Thanks
Laszlo


> -  NewModeBuffer = AllocateZeroPool (sizeof (TERMINAL_CONSOLE_MODE_DATA) * (Count + 2));
> -  ASSERT (NewModeBuffer != NULL);
> -
> -  //
> -  // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
> -  //
> -  ValidCount = 0;
> -
> -  NewModeBuffer[ValidCount].Columns = 80;
> -  NewModeBuffer[ValidCount].Rows    = 25;
> -  ValidCount++;
> -
> -  NewModeBuffer[ValidCount].Columns = 80;
> -  NewModeBuffer[ValidCount].Rows    = 50;
> -  ValidCount++;
> -
> -  //
> -  // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
> -  //
> -  for (Index = 0; Index < Count; Index++) {
> -    if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0)) {
> -      //
> -      // Skip the pre-defined mode which is invalid.
> -      //
> -      continue;
> -    }
> -    for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
> -      if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
> -          (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
> -        //
> -        // Skip the duplicated mode.
> -        //
> -        break;
> -      }
> -    }
> -    if (ValidIndex == ValidCount) {
> -      NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
> -      NewModeBuffer[ValidCount].Rows    = ModeBuffer[Index].Rows;
> -      ValidCount++;
> -    }
> +  TextModeData = AllocateCopyPool (sizeof (mTerminalConsoleModeData), mTerminalConsoleModeData);
> +  if (TextModeData == NULL) {
> +    return NULL;
>    }
> -
> +  *TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData);
> +
>    DEBUG_CODE (
> -    for (Index = 0; Index < ValidCount; Index++) {
> -      DEBUG ((EFI_D_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
> -                           Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));
> +    INT32 Index;
> +    for (Index = 0; Index < *TextModeCount; Index++) {
> +      DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
> +              Index, TextModeData[Index].Columns, TextModeData[Index].Rows));
>      }
>    );
> -
> -  //
> -  // Return valid mode count and mode information buffer.
> -  //
> -  *TextModeCount = ValidCount;
> -  *TextModeData  = NewModeBuffer;
> -  return EFI_SUCCESS;
> +  return TextModeData;
>  }
>
>  /**
> @@ -632,7 +576,6 @@ TerminalDriverBindingStart (
>    BOOLEAN                             SimTxtInInstalled;
>    BOOLEAN                             SimTxtOutInstalled;
>    BOOLEAN                             FirstEnter;
> -  UINTN                               ModeCount;
>
>    TerminalDevice     = NULL;
>    ConInSelected      = FALSE;
> @@ -896,12 +839,13 @@ TerminalDriverBindingStart (
>                           );
>      SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
>
> -    Status = InitializeTerminalConsoleTextMode (&ModeCount, &TerminalDevice->TerminalConsoleModeData);
> -    if (EFI_ERROR (Status)) {
> +    TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
> +                                                &SimpleTextOutput->Mode->MaxMode
> +                                                );
> +    if (TerminalDevice->TerminalConsoleModeData == NULL) {
>        goto ReportError;
>      }
> -    TerminalDevice->SimpleTextOutputMode.MaxMode = (INT32) ModeCount;
> -
> +
>      //
>      // For terminal devices, cursor is always visible
>      //
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-01-12 15:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-10  8:38 [PATCH 0/8] Fix TerminalDxe driver model bug Ruiyu Ni
2017-01-10  8:38 ` [PATCH 1/8] MdeModulePkg/TerminalDxe: Replace macro with enum for terminal types Ruiyu Ni
2017-01-11  7:32   ` Tian, Feng
2017-01-10  8:38 ` [PATCH 2/8] MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function Ruiyu Ni
2017-01-10  8:38 ` [PATCH 3/8] MdeModulePkg/TerminalDxe: Separate controller name init logic Ruiyu Ni
2017-01-10  8:39 ` [PATCH 4/8] MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode Ruiyu Ni
2017-01-12 10:41   ` Laszlo Ersek
2017-01-12 15:39     ` Ni, Ruiyu
2017-01-10  8:39 ` [PATCH 5/8] MdeModulePkg/TerminalDxe: Refine SetTerminalDevicePath Ruiyu Ni
2017-01-10  8:39 ` [PATCH 6/8] MdeModulePkg/TerminalDxe: Separate state machine start/stop logic Ruiyu Ni
2017-01-10  8:39 ` [PATCH 7/8] MdeModulePkg/TerminalDxe: Remove unnecessary NULL pointer check Ruiyu Ni
2017-01-10  8:39 ` [PATCH 8/8] MdeModulePkg/TerminalDxe: Fix driver model bug Ruiyu Ni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox