From: Chen A Chen Date: Thu, 3 Nov 2016 07:20:48 +0000 (+0800) Subject: ShellPkg/reset: Support "-fwui" flag X-Git-Tag: edk2-stable201903~5355 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=f675a1b42235b508e17220878453b4b1f04dd990 ShellPkg/reset: Support "-fwui" flag 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 Reviewed-by: Ruiyu Ni Reviewed-by: Jaben Carsey --- diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c index 7d4cfb470e..40ad8d9c4e 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c @@ -2,7 +2,7 @@ Main file for attrib shell level 2 function. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, 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 @@ -16,10 +16,11 @@ #include "UefiShellLevel2CommandsLib.h" STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = { - {L"-w", TypeValue}, - {L"-s", TypeValue}, - {L"-c", TypeValue}, - {NULL, TypeMax} + {L"-w", TypeValue}, + {L"-s", TypeValue}, + {L"-c", TypeValue}, + {L"-fwui", TypeFlag }, + {NULL, TypeMax } }; /** @@ -40,6 +41,9 @@ ShellCommandRunReset ( CONST CHAR16 *String; CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; + UINT64 OsIndications; + UINT32 Attr; + UINTN DataSize; ShellStatus = SHELL_SUCCESS; ProblemParam = NULL; @@ -72,6 +76,39 @@ ShellCommandRunReset ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset"); ShellStatus = SHELL_INVALID_PARAMETER; } else { + + if (ShellCommandLineGetFlag (Package, L"-fwui")) { + + DataSize = sizeof (OsIndications); + Status = gRT->GetVariable ( + EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, &gEfiGlobalVariableGuid, + &Attr, &DataSize, &OsIndications + ); + if (!EFI_ERROR (Status)) { + if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) { + DataSize = sizeof (OsIndications); + Status = gRT->GetVariable ( + EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid, + &Attr, &DataSize, &OsIndications + ); + if (!EFI_ERROR (Status)) { + OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + } else { + OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + } + Status = gRT->SetVariable ( + EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof (OsIndications), &OsIndications + ); + } + } + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_UNSUPPORTED; + goto Error; + } + } + // // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag // @@ -119,6 +156,7 @@ ShellCommandRunReset ( // as the ResetSystem function should not return... // +Error: // // free the command line package // diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h index c262bb50f4..857487fd80 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h @@ -25,6 +25,7 @@ #include +#include #include #include