From 31c2a2c7c07365abd3ee9389b390ac4c8b7d4aac Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Tue, 7 Jan 2014 02:23:10 +0000 Subject: [PATCH] Enhance Shell 2.0 to not depend on keyboard driver implementation to fix the "CTRL+s" pause malfunction issue. Signed-off-by: Ruiyu Ni Reviewed-by: Carsey Jaben git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15052 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ConsoleLogger.c | 41 ++++++++++++++++------ ShellPkg/Application/Shell/ShellProtocol.c | 7 ---- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ShellPkg/Application/Shell/ConsoleLogger.c b/ShellPkg/Application/Shell/ConsoleLogger.c index c3729f16c9..6f7ed95a61 100644 --- a/ShellPkg/Application/Shell/ConsoleLogger.c +++ b/ShellPkg/Application/Shell/ConsoleLogger.c @@ -2,7 +2,7 @@ Provides interface to shell console logger. Copyright (c) 2013 Hewlett-Packard Development Company, L.P. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
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 @@ -819,22 +819,41 @@ ConsoleLoggerOutputString ( IN CHAR16 *WString ) { - EFI_INPUT_KEY Key; - UINTN EventIndex; - CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; + EFI_STATUS Status; + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx; + EFI_KEY_DATA KeyData; + UINTN EventIndex; + CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; + ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This); if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) { return (EFI_UNSUPPORTED); } ASSERT(ShellInfoObject.ConsoleInfo == ConsoleInfo); - if (ShellInfoObject.HaltOutput) { - // - // just get some key - // - gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex); - gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); - ShellInfoObject.HaltOutput = FALSE; + + Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx); + if (!EFI_ERROR (Status)) { + while (ShellInfoObject.HaltOutput) { + + ShellInfoObject.HaltOutput = FALSE; + // + // just get some key + // + Status = gBS->WaitForEvent (1, &TxtInEx->WaitForKeyEx, &EventIndex); + ASSERT_EFI_ERROR (Status); + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData); + ASSERT_EFI_ERROR (Status); + + if ((KeyData.Key.UnicodeChar == L's') && (KeyData.Key.ScanCode == SCAN_NULL) && + ((KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED)) || + (KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED)) + ) + ) { + ShellInfoObject.HaltOutput = TRUE; + } + } } + if (!ShellInfoObject.ConsoleInfo->Enabled) { return (EFI_DEVICE_ERROR); } else if (ShellInfoObject.PageBreakEnabled) { diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index ea30aaefc3..a337e5829e 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -3297,7 +3297,6 @@ NotificationFunction( IN EFI_KEY_DATA *KeyData ) { - EFI_INPUT_KEY Key; if ( ((KeyData->Key.UnicodeChar == L'c') && (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))) || (KeyData->Key.UnicodeChar == 3) @@ -3310,12 +3309,6 @@ NotificationFunction( (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)) ){ ShellInfoObject.HaltOutput = TRUE; - - // - // Make sure that there are no pending keystrokes to pervent the pause. - // - gST->ConIn->Reset(gST->ConIn, FALSE); - while (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key)==EFI_SUCCESS); } return (EFI_SUCCESS); } -- 2.39.2