Revision: 14800
          http://sourceforge.net/p/edk2/code/14800
Author:   jcarsey
Date:     2013-10-24 17:47:57 +0000 (Thu, 24 Oct 2013)
Log Message:
-----------
ShellPkg: Fixes the shell so output redirection works for the 'mode' command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <[email protected]>
reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.c
    trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.h
    trunk/edk2/ShellPkg/Application/Shell/ShellParametersProtocol.c

Modified: trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.c     2013-10-24 
17:29:33 UTC (rev 14799)
+++ trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.c     2013-10-24 
17:47:57 UTC (rev 14800)
@@ -1,6 +1,7 @@
 /** @file
   Function definitions for shell simple text in and out on top of file handles.
 
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
   Copyright (c) 2010 - 2011, 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
@@ -24,6 +25,7 @@
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
   SHELL_FILE_HANDLE               FileHandle;
   EFI_HANDLE                      TheHandle;
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
 } SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
 
 /**
@@ -253,7 +255,14 @@
   OUT UINTN                           *Rows
   )
 {
-  return (EFI_UNSUPPORTED);
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol = 
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
+  
+  // Pass the QueryMode call thru to the original SimpleTextOutProtocol
+  return (PassThruProtocol->QueryMode(
+    PassThruProtocol,
+    ModeNumber,
+    Columns,
+    Rows));
 }
 
 /**
@@ -386,8 +395,9 @@
   Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a 
   SHELL_FILE_HANDLE to support redirecting output from a file.
 
-  @param[in]  FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
-  @param[in]  HandleLocation  The pointer of a location to copy handle with 
protocol to.
+  @param[in]  FileHandleToUse  The pointer to the SHELL_FILE_HANDLE to use.
+  @param[in]  HandleLocation   The pointer of a location to copy handle with 
protocol to.
+  @param[in]  OriginalProtocol The pointer to the original output protocol for 
pass thru of functions.
 
   @retval NULL                There was insufficient memory available.
   @return                     A pointer to the allocated protocol structure;
@@ -395,8 +405,9 @@
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
 EFIAPI
 CreateSimpleTextOutOnFile(
-  IN SHELL_FILE_HANDLE  FileHandleToUse,
-  IN EFI_HANDLE         *HandleLocation
+  IN SHELL_FILE_HANDLE               FileHandleToUse,
+  IN EFI_HANDLE                      *HandleLocation,
+  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
   )
 {
   SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
@@ -411,6 +422,7 @@
     return (NULL);
   }
   ProtocolToReturn->FileHandle                      = FileHandleToUse;
+  ProtocolToReturn->OriginalSimpleTextOut           = OriginalProtocol;
   ProtocolToReturn->SimpleTextOut.Reset             = 
FileBasedSimpleTextOutReset;
   ProtocolToReturn->SimpleTextOut.TestString        = 
FileBasedSimpleTextOutTestString;
   ProtocolToReturn->SimpleTextOut.QueryMode         = 
FileBasedSimpleTextOutQueryMode;
@@ -425,12 +437,12 @@
     FreePool(ProtocolToReturn);
     return (NULL);
   }
-  ProtocolToReturn->SimpleTextOut.Mode->MaxMode       = 0;
-  ProtocolToReturn->SimpleTextOut.Mode->Mode          = 0;
-  ProtocolToReturn->SimpleTextOut.Mode->Attribute     = 0;
-  ProtocolToReturn->SimpleTextOut.Mode->CursorColumn  = 0;
-  ProtocolToReturn->SimpleTextOut.Mode->CursorRow     = 0;
-  ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = FALSE;
+  ProtocolToReturn->SimpleTextOut.Mode->MaxMode       = 
OriginalProtocol->Mode->MaxMode;
+  ProtocolToReturn->SimpleTextOut.Mode->Mode          = 
OriginalProtocol->Mode->Mode;
+  ProtocolToReturn->SimpleTextOut.Mode->Attribute     = 
OriginalProtocol->Mode->Attribute;
+  ProtocolToReturn->SimpleTextOut.Mode->CursorColumn  = 
OriginalProtocol->Mode->CursorColumn;
+  ProtocolToReturn->SimpleTextOut.Mode->CursorRow     = 
OriginalProtocol->Mode->CursorRow;
+  ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = 
OriginalProtocol->Mode->CursorVisible;
 
   Status = gBS->InstallProtocolInterface(
     &(ProtocolToReturn->TheHandle), 

Modified: trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.h
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.h     2013-10-24 
17:29:33 UTC (rev 14799)
+++ trunk/edk2/ShellPkg/Application/Shell/ConsoleWrappers.h     2013-10-24 
17:47:57 UTC (rev 14800)
@@ -1,6 +1,7 @@
 /** @file
   Function definitions for shell simple text in and out on top of file handles.
 
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
   Copyright (c) 2010 - 2011, 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
@@ -50,8 +51,9 @@
   Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a 
   SHELL_FILE_HANDLE to support redirecting output from a file.
 
-  @param[in]  FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
-  @param[in]  HandleLocation  The pointer of a location to copy handle with 
protocol to.
+  @param[in]  FileHandleToUse  The pointer to the SHELL_FILE_HANDLE to use.
+  @param[in]  HandleLocation   The pointer of a location to copy handle with 
protocol to.
+  @param[in]  OriginalProtocol The pointer to the original output protocol for 
pass thru of functions.
 
   @retval NULL                There was insufficient memory available.
   @return                     A pointer to the allocated protocol structure;
@@ -59,8 +61,9 @@
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
 EFIAPI
 CreateSimpleTextOutOnFile(
-  IN SHELL_FILE_HANDLE  FileHandleToUse,
-  IN EFI_HANDLE         *HandleLocation
+  IN SHELL_FILE_HANDLE               FileHandleToUse,
+  IN EFI_HANDLE                      *HandleLocation,
+  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
   );
 
 /**

Modified: trunk/edk2/ShellPkg/Application/Shell/ShellParametersProtocol.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/ShellParametersProtocol.c     
2013-10-24 17:29:33 UTC (rev 14799)
+++ trunk/edk2/ShellPkg/Application/Shell/ShellParametersProtocol.c     
2013-10-24 17:47:57 UTC (rev 14800)
@@ -2,6 +2,7 @@
   Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
 
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
   Copyright (c) 2009 - 2013, 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
@@ -1008,7 +1009,7 @@
         }
         if (!EFI_ERROR(Status)) {
           ShellParameters->StdErr = TempHandle;
-          gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, 
&gST->StandardErrorHandle);
+          gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, 
&gST->StandardErrorHandle, gST->StdErr);
         }
       }
 
@@ -1051,7 +1052,7 @@
           }
           if (!EFI_ERROR(Status)) {
             ShellParameters->StdOut = TempHandle;
-            gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, 
&gST->ConsoleOutHandle);
+            gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, 
&gST->ConsoleOutHandle, gST->ConOut);
           }
         }
       }
@@ -1069,7 +1070,7 @@
         TempHandle = CreateFileInterfaceEnv(StdOutVarName);
         ASSERT(TempHandle != NULL);
         ShellParameters->StdOut = TempHandle;
-        gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, 
&gST->ConsoleOutHandle);
+        gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, 
&gST->ConsoleOutHandle, gST->ConOut);
       }
 
       //
@@ -1085,7 +1086,7 @@
         TempHandle = CreateFileInterfaceEnv(StdErrVarName);
         ASSERT(TempHandle != NULL);
         ShellParameters->StdErr = TempHandle;
-        gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, 
&gST->StandardErrorHandle);
+        gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, 
&gST->StandardErrorHandle, gST->StdErr);
       }
 
       //

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to