From a49f6a2f7e0d0141519c136905ce70038573ce40 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Fri, 15 Apr 2011 18:20:40 +0000 Subject: [PATCH] fix for word wrapping. fix for SimpleTextInEx callbacks. remove an ASSERT. fix for -noconsolein parameter. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11544 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ConsoleLogger.c | 14 +++++- .../Application/Shell/FileHandleWrappers.c | 3 +- ShellPkg/Application/Shell/Shell.c | 44 ++++++++++++------ ShellPkg/Application/Shell/Shell.h | 2 + ShellPkg/Application/Shell/ShellProtocol.c | 8 +--- .../UefiShellLevel3CommandsLib/Pause.c | 3 +- .../UefiShellLevel3CommandsLib.uni | Bin 42494 -> 42500 bytes 7 files changed, 48 insertions(+), 26 deletions(-) diff --git a/ShellPkg/Application/Shell/ConsoleLogger.c b/ShellPkg/Application/Shell/ConsoleLogger.c index 58518cabe9..01104e6735 100644 --- a/ShellPkg/Application/Shell/ConsoleLogger.c +++ b/ShellPkg/Application/Shell/ConsoleLogger.c @@ -729,7 +729,7 @@ ConsoleLoggerPrintWithPageBreak( // // check if that is the last column // - if ((INTN)ConsoleInfo->ColsPerScreen == ConsoleInfo->OurConOut.Mode->CursorColumn - 1) { + if ((INTN)ConsoleInfo->ColsPerScreen == ConsoleInfo->OurConOut.Mode->CursorColumn + 1) { // // output a line similar to the linefeed character. // @@ -753,7 +753,7 @@ ConsoleLoggerPrintWithPageBreak( // // Update LineStart Variable // - LineStart = Walker; + LineStart = Walker + 1; // // increment row count and zero the column @@ -810,12 +810,22 @@ ConsoleLoggerOutputString ( IN CHAR16 *WString ) { + EFI_INPUT_KEY Key; + 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; + } if (!ShellInfoObject.ConsoleInfo->Enabled) { return (EFI_DEVICE_ERROR); } else if (ShellInfoObject.PageBreakEnabled) { diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index b2163bebb9..3cadc41e0b 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -249,7 +249,7 @@ FileInterfaceStdErrRead( File style interface for NUL file (Read). @param[in] This Ignored. - @param[in,out] BufferSize Ignored. + @param[in,out] BufferSize Poiner to 0 upon return. @param[out] Buffer Ignored. @retval EFI_SUCCESS Always. @@ -262,6 +262,7 @@ FileInterfaceNulRead( OUT VOID *Buffer ) { + *BufferSize = 0; return (EFI_SUCCESS); } diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index a56967189b..ae4c0606e3 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -55,7 +55,8 @@ SHELL_INFO ShellInfoObject = { NULL, NULL, NULL, - NULL + NULL, + FALSE }; STATIC CONST CHAR16 mScriptExtension[] = L".NSH"; @@ -155,17 +156,11 @@ UefiMain ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - CHAR16 *TempString; - UINTN Size; -// EFI_INPUT_KEY Key; - -// gST->ConOut->OutputString(gST->ConOut, L"ReadKeyStroke Calling\r\n"); -// -// Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); -// -// gST->ConOut->OutputString(gST->ConOut, L"ReadKeyStroke Done\r\n"); -// gBS->Stall (1000000); + EFI_STATUS Status; + CHAR16 *TempString; + UINTN Size; + EFI_HANDLE ConInHandle; + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *OldConIn; if (PcdGet8(PcdShellSupportLevel) > 3) { return (EFI_UNSUPPORTED); @@ -361,6 +356,18 @@ UefiMain ( Status = InternalEfiShellStartCtrlSMonitor(); } + if (!EFI_ERROR(Status) && ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) { + // + // close off the gST->ConIn + // + OldConIn = gST->ConIn; + ConInHandle = gST->ConsoleInHandle; + gST->ConIn = CreateSimpleTextInOnFile((SHELL_FILE_HANDLE)&FileInterfaceNulFile, &gST->ConsoleInHandle); + } else { + OldConIn = NULL; + ConInHandle = NULL; + } + if (!EFI_ERROR(Status) && PcdGet8(PcdShellSupportLevel) >= 1) { // // process the startup script or launch the called app. @@ -399,6 +406,11 @@ UefiMain ( Status = DoShellPrompt(); } while (!ShellCommandGetExit()); } + if (OldConIn != NULL && ConInHandle != NULL) { + CloseSimpleTextInOnFile (gST->ConIn); + gST->ConIn = OldConIn; + gST->ConsoleInHandle = ConInHandle; + } } } @@ -548,8 +560,6 @@ IsScriptOnlyCommand( return (FALSE); } - - /** This function will populate the 2 device path protocol parameters based on the global gImageHandle. The DevPath will point to the device path for the handle that has @@ -598,6 +608,11 @@ GetDevicePathsForImageAndFile ( if (!EFI_ERROR (Status)) { *DevPath = DuplicateDevicePath (ImageDevicePath); *FilePath = DuplicateDevicePath (LoadedImage->FilePath); + gBS->CloseProtocol( + LoadedImage->DeviceHandle, + &gEfiDevicePathProtocolGuid, + gImageHandle, + NULL); } gBS->CloseProtocol( gImageHandle, @@ -620,6 +635,7 @@ STATIC CONST SHELL_PARAM_ITEM mShellParamList[] = { {L"-delay", TypeValue}, {NULL, TypeMax} }; + /** Process all Uefi Shell 2.0 command line options. diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h index 3699fb233d..51ec4f3a4b 100644 --- a/ShellPkg/Application/Shell/Shell.h +++ b/ShellPkg/Application/Shell/Shell.h @@ -50,6 +50,7 @@ #include "ShellEnvVar.h" #include "ConsoleLogger.h" #include "ShellManParser.h" +#include "ConsoleWrappers.h" typedef struct { LIST_ENTRY Link; ///< Standard linked list handler. @@ -113,6 +114,7 @@ typedef struct { EFI_HANDLE CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. EFI_HANDLE CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. EFI_HANDLE CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt. } SHELL_INFO; extern SHELL_INFO ShellInfoObject; diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 2d587ea03b..8b2e89041b 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -3326,8 +3326,6 @@ NotificationFunction( IN EFI_KEY_DATA *KeyData ) { - EFI_INPUT_KEY Key; - UINTN EventIndex; // ShellPrintEx(-1,-1,L" "); if ((KeyData->Key.UnicodeChar == L'c' || KeyData->Key.UnicodeChar == 3) && (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)) @@ -3339,11 +3337,7 @@ NotificationFunction( } else if ((KeyData->Key.UnicodeChar == L's') && (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)) ){ - // - // just get some key - // - gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex); - gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + ShellInfoObject.HaltOutput = TRUE; } return (EFI_SUCCESS); } diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c index facacaac7d..d6ed793579 100644 --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c @@ -82,9 +82,8 @@ ShellCommandRunPause ( } else { Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp); } - ASSERT_EFI_ERROR(Status); - if (Resp == NULL || *Resp == ShellPromptResponseQuit) { + if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) { ShellCommandRegisterExit(TRUE); ShellStatus = SHELL_ABORTED; } diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni index 346b464e8235aa2684b8d8c8a5074d873562bc3a..a50aa28d26827168cae93a10b28e328641fe9230 100644 GIT binary patch delta 30 mcmex&nyKXs(*`whb_E7Q20aFY$&M1*lkbT0Y>pFO&<6mU4++2k delta 21 dcmZoU!}RYo(*`y1$tnB-la{e;b`U?(2LNPe2)O_N -- 2.39.2