]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/reset: Support "-fwui" flag
authorChen A Chen <chen.a.chen@intel.com>
Thu, 3 Nov 2016 07:20:48 +0000 (15:20 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 7 Nov 2016 02:43:27 +0000 (10:43 +0800)
The patch adds "-fwui" support to reset command which is newly added
to Shell 2.2 spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h

index 7d4cfb470e8d50b6ce98372c25849b7f34d6e638..40ad8d9c4e0aad41f17ddd6e9fc4afa42c0cc146 100644 (file)
@@ -2,7 +2,7 @@
   Main file for attrib shell level 2 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, 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
   which accompanies this distribution.  The full text of the license may be found at\r
 #include "UefiShellLevel2CommandsLib.h"\r
 \r
 STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {\r
-  {L"-w", TypeValue},\r
-  {L"-s", TypeValue},\r
-  {L"-c", TypeValue},\r
-  {NULL, TypeMax}\r
+  {L"-w",    TypeValue},\r
+  {L"-s",    TypeValue},\r
+  {L"-c",    TypeValue},\r
+  {L"-fwui", TypeFlag },\r
+  {NULL,     TypeMax  }\r
   };\r
 \r
 /**\r
@@ -40,6 +41,9 @@ ShellCommandRunReset (
   CONST CHAR16  *String;\r
   CHAR16        *ProblemParam;\r
   SHELL_STATUS  ShellStatus;\r
+  UINT64        OsIndications;\r
+  UINT32        Attr;\r
+  UINTN         DataSize;\r
 \r
   ShellStatus = SHELL_SUCCESS;\r
   ProblemParam = NULL;\r
@@ -72,6 +76,39 @@ ShellCommandRunReset (
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");  \r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
+\r
+      if (ShellCommandLineGetFlag (Package, L"-fwui")) {\r
+\r
+        DataSize  = sizeof (OsIndications);\r
+        Status = gRT->GetVariable (\r
+                        EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r
+                        &Attr, &DataSize, &OsIndications\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) {\r
+            DataSize = sizeof (OsIndications);\r
+            Status = gRT->GetVariable (\r
+                            EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r
+                            &Attr, &DataSize, &OsIndications\r
+                            );\r
+            if (!EFI_ERROR (Status)) {\r
+              OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;\r
+            } else {\r
+              OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;\r
+            }\r
+            Status = gRT->SetVariable (\r
+                            EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r
+                            EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                            sizeof (OsIndications), &OsIndications\r
+                            );\r
+          }\r
+        }\r
+        if (EFI_ERROR (Status)) {\r
+          ShellStatus = SHELL_UNSUPPORTED;\r
+          goto Error;\r
+        }\r
+      }\r
+\r
       //\r
       // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag\r
       //\r
@@ -119,6 +156,7 @@ ShellCommandRunReset (
   // as the ResetSystem function should not return...\r
   //\r
 \r
+Error:\r
   //\r
   // free the command line package\r
   //\r
index c262bb50f433770b8acf02a7d892b89f59f77489..857487fd809341aad7b4adf4894dd9f9b08dde22 100644 (file)
@@ -25,6 +25,7 @@
 \r
 #include <Uefi.h>\r
 \r
+#include <Guid/GlobalVariable.h>\r
 #include <Guid/ShellLibHiiGuid.h>\r
 \r
 #include <Protocol/Shell.h>\r