]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fixes the shell so output redirection works for the 'mode' command
authorChris Phillips <chrisp@hp.com>
Thu, 24 Oct 2013 17:47:57 +0000 (17:47 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 24 Oct 2013 17:47:57 +0000 (17:47 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hp.com>
reviewed-by: Jaben Carsey <Jaben.Carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14800 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ConsoleWrappers.c
ShellPkg/Application/Shell/ConsoleWrappers.h
ShellPkg/Application/Shell/ShellParametersProtocol.c

index d85d1acf4d713e937d897ea53cc5bc0f33e14f9c..38491216f39a87635428ad23ed4dc73485683ad7 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Function definitions for shell simple text in and out on top of file handles.\r
 \r
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -24,6 +25,7 @@ typedef struct {
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;\r
   SHELL_FILE_HANDLE               FileHandle;\r
   EFI_HANDLE                      TheHandle;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;\r
 } SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;\r
 \r
 /**\r
@@ -253,7 +255,14 @@ FileBasedSimpleTextOutQueryMode (
   OUT UINTN                           *Rows\r
   )\r
 {\r
-  return (EFI_UNSUPPORTED);\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;\r
+  \r
+  // Pass the QueryMode call thru to the original SimpleTextOutProtocol\r
+  return (PassThruProtocol->QueryMode(\r
+    PassThruProtocol,\r
+    ModeNumber,\r
+    Columns,\r
+    Rows));\r
 }\r
 \r
 /**\r
@@ -386,8 +395,9 @@ FileBasedSimpleTextOutOutputString (
   Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a \r
   SHELL_FILE_HANDLE to support redirecting output from a file.\r
 \r
-  @param[in]  FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.\r
-  @param[in]  HandleLocation  The pointer of a location to copy handle with protocol to.\r
+  @param[in]  FileHandleToUse  The pointer to the SHELL_FILE_HANDLE to use.\r
+  @param[in]  HandleLocation   The pointer of a location to copy handle with protocol to.\r
+  @param[in]  OriginalProtocol The pointer to the original output protocol for pass thru of functions.\r
 \r
   @retval NULL                There was insufficient memory available.\r
   @return                     A pointer to the allocated protocol structure;\r
@@ -395,8 +405,9 @@ FileBasedSimpleTextOutOutputString (
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*\r
 EFIAPI\r
 CreateSimpleTextOutOnFile(\r
-  IN SHELL_FILE_HANDLE  FileHandleToUse,\r
-  IN EFI_HANDLE         *HandleLocation\r
+  IN SHELL_FILE_HANDLE               FileHandleToUse,\r
+  IN EFI_HANDLE                      *HandleLocation,\r
+  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol\r
   )\r
 {\r
   SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;\r
@@ -411,6 +422,7 @@ CreateSimpleTextOutOnFile(
     return (NULL);\r
   }\r
   ProtocolToReturn->FileHandle                      = FileHandleToUse;\r
+  ProtocolToReturn->OriginalSimpleTextOut           = OriginalProtocol;\r
   ProtocolToReturn->SimpleTextOut.Reset             = FileBasedSimpleTextOutReset;\r
   ProtocolToReturn->SimpleTextOut.TestString        = FileBasedSimpleTextOutTestString;\r
   ProtocolToReturn->SimpleTextOut.QueryMode         = FileBasedSimpleTextOutQueryMode;\r
@@ -425,12 +437,12 @@ CreateSimpleTextOutOnFile(
     FreePool(ProtocolToReturn);\r
     return (NULL);\r
   }\r
-  ProtocolToReturn->SimpleTextOut.Mode->MaxMode       = 0;\r
-  ProtocolToReturn->SimpleTextOut.Mode->Mode          = 0;\r
-  ProtocolToReturn->SimpleTextOut.Mode->Attribute     = 0;\r
-  ProtocolToReturn->SimpleTextOut.Mode->CursorColumn  = 0;\r
-  ProtocolToReturn->SimpleTextOut.Mode->CursorRow     = 0;\r
-  ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = FALSE;\r
+  ProtocolToReturn->SimpleTextOut.Mode->MaxMode       = OriginalProtocol->Mode->MaxMode;\r
+  ProtocolToReturn->SimpleTextOut.Mode->Mode          = OriginalProtocol->Mode->Mode;\r
+  ProtocolToReturn->SimpleTextOut.Mode->Attribute     = OriginalProtocol->Mode->Attribute;\r
+  ProtocolToReturn->SimpleTextOut.Mode->CursorColumn  = OriginalProtocol->Mode->CursorColumn;\r
+  ProtocolToReturn->SimpleTextOut.Mode->CursorRow     = OriginalProtocol->Mode->CursorRow;\r
+  ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;\r
 \r
   Status = gBS->InstallProtocolInterface(\r
     &(ProtocolToReturn->TheHandle), \r
index 572113d39776ad41eff6e3a89ce4d03f6daa32f0..13d12e8f45592601063591b8a96b77338c5d9c85 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Function definitions for shell simple text in and out on top of file handles.\r
 \r
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -50,8 +51,9 @@ CloseSimpleTextInOnFile(
   Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a \r
   SHELL_FILE_HANDLE to support redirecting output from a file.\r
 \r
-  @param[in]  FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.\r
-  @param[in]  HandleLocation  The pointer of a location to copy handle with protocol to.\r
+  @param[in]  FileHandleToUse  The pointer to the SHELL_FILE_HANDLE to use.\r
+  @param[in]  HandleLocation   The pointer of a location to copy handle with protocol to.\r
+  @param[in]  OriginalProtocol The pointer to the original output protocol for pass thru of functions.\r
 \r
   @retval NULL                There was insufficient memory available.\r
   @return                     A pointer to the allocated protocol structure;\r
@@ -59,8 +61,9 @@ CloseSimpleTextInOnFile(
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*\r
 EFIAPI\r
 CreateSimpleTextOutOnFile(\r
-  IN SHELL_FILE_HANDLE  FileHandleToUse,\r
-  IN EFI_HANDLE         *HandleLocation\r
+  IN SHELL_FILE_HANDLE               FileHandleToUse,\r
+  IN EFI_HANDLE                      *HandleLocation,\r
+  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol\r
   );\r
 \r
 /**\r
index 2f8c626b010d4dd64188d603a1d08de989d9bf4f..3564e066600fc77ba5c2e641101da61d1678f623 100644 (file)
@@ -2,6 +2,7 @@
   Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,\r
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.\r
 \r
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1008,7 +1009,7 @@ UpdateStdInStdOutStdErr(
         }\r
         if (!EFI_ERROR(Status)) {\r
           ShellParameters->StdErr = TempHandle;\r
-          gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);\r
+          gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);\r
         }\r
       }\r
 \r
@@ -1051,7 +1052,7 @@ UpdateStdInStdOutStdErr(
           }\r
           if (!EFI_ERROR(Status)) {\r
             ShellParameters->StdOut = TempHandle;\r
-            gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);\r
+            gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);\r
           }\r
         }\r
       }\r
@@ -1069,7 +1070,7 @@ UpdateStdInStdOutStdErr(
         TempHandle = CreateFileInterfaceEnv(StdOutVarName);\r
         ASSERT(TempHandle != NULL);\r
         ShellParameters->StdOut = TempHandle;\r
-        gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);\r
+        gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);\r
       }\r
 \r
       //\r
@@ -1085,7 +1086,7 @@ UpdateStdInStdOutStdErr(
         TempHandle = CreateFileInterfaceEnv(StdErrVarName);\r
         ASSERT(TempHandle != NULL);\r
         ShellParameters->StdErr = TempHandle;\r
-        gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);\r
+        gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);\r
       }\r
 \r
       //\r