From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5959A81D65 for ; Fri, 4 Nov 2016 01:48:51 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 04 Nov 2016 01:48:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,442,1473145200"; d="scan'208";a="187537816" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 04 Nov 2016 01:48:52 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Chen A Chen , Jaben Carsey Date: Fri, 4 Nov 2016 16:47:56 +0800 Message-Id: <20161104084756.388044-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] ShellPkg/reset: Support "-fwui" flag X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 08:48:51 -0000 From: Chen A Chen 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 Cc: Jaben Carsey --- .../Library/UefiShellLevel2CommandsLib/Reset.c | 48 +++++++++++++++++++--- .../UefiShellLevel2CommandsLib.h | 1 + 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c index 7d4cfb4..40ad8d9 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 c262bb5..857487f 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h @@ -25,6 +25,7 @@ #include +#include #include #include -- 2.9.0.windows.1