public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>
Subject: [PATCH v2] Emulator/Win: Fix build failure using VS2015x86 or old WinSDK
Date: Fri,  7 Sep 2018 13:48:28 +0800	[thread overview]
Message-ID: <20180907054828.28240-1-ruiyu.ni@intel.com> (raw)

When build with WinSDK <= Win10 TH2, the terminal over CMD.exe
doesn't work. Because Win10 later than TH2 starts to support VT
terminal.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
 EmulatorPkg/Win/Host/WinHost.c  |  2 +-
 EmulatorPkg/Win/Host/WinThunk.c | 23 ++++++++++++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 9b98d5330f..65e8960eff 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -673,7 +673,7 @@ Returns:
   // Transfer control to the SEC Core
   //
   SwitchStack (
-    (SWITCH_STACK_ENTRY_POINT)SecCoreEntryPoint,
+    (SWITCH_STACK_ENTRY_POINT)(UINTN)SecCoreEntryPoint,
     SecCoreData,
     GetThunkPpiList (),
     TopOfStack
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index 306fe75ecd..6007db73b5 100644
--- a/EmulatorPkg/Win/Host/WinThunk.c
+++ b/EmulatorPkg/Win/Host/WinThunk.c
@@ -71,15 +71,23 @@ SecConfigStdIn (
     //
     // Disable buffer (line input), echo, mouse, window
     //
-    Success = SetConsoleMode (
-                GetStdHandle (STD_INPUT_HANDLE),
-                Mode | ENABLE_VIRTUAL_TERMINAL_INPUT & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)
-                );
-  }
-  if (Success) {
+    Mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
+
+#if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
     //
-    // Enable terminal mode
+    // Enable virtual terminal input for Win10 above TH2
     //
+    Mode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
+#endif
+
+    Success = SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), Mode);
+  }
+
+#if defined(NTDDI_VERSION) && defined (NTDDI_WIN10_TH2) && (NTDDI_VERSION > NTDDI_WIN10_TH2)
+  //
+  // Enable terminal mode for Win10 above TH2
+  //
+  if (Success) {
     Success = GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &Mode);
     if (Success) {
       Success = SetConsoleMode (
@@ -88,6 +96,7 @@ SecConfigStdIn (
       );
     }
   }
+#endif
   return Success ? EFI_SUCCESS : EFI_DEVICE_ERROR;
 }
 
-- 
2.16.1.windows.1



             reply	other threads:[~2018-09-07  5:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07  5:48 Ruiyu Ni [this message]
2018-09-10  1:19 ` [PATCH v2] Emulator/Win: Fix build failure using VS2015x86 or old WinSDK Wu, Hao A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180907054828.28240-1-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox