* [PATCH] ShellPkg/reset: Support "-fwui" flag
@ 2016-11-04 8:47 Ruiyu Ni
2016-11-04 15:35 ` Carsey, Jaben
0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2016-11-04 8:47 UTC (permalink / raw)
To: edk2-devel; +Cc: Chen A Chen, Jaben Carsey
From: Chen A Chen <chen.a.chen@intel.com>
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>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
.../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.<BR>
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, 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
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 <Uefi.h>
+#include <Guid/GlobalVariable.h>
#include <Guid/ShellLibHiiGuid.h>
#include <Protocol/Shell.h>
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ShellPkg/reset: Support "-fwui" flag
2016-11-04 8:47 [PATCH] ShellPkg/reset: Support "-fwui" flag Ruiyu Ni
@ 2016-11-04 15:35 ` Carsey, Jaben
0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2016-11-04 15:35 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Chen, Chen A, Carsey, Jaben
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Friday, November 04, 2016 1:48 AM
> To: edk2-devel@lists.01.org
> Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> <jaben.carsey@intel.com>
> Subject: [PATCH] ShellPkg/reset: Support "-fwui" flag
> Importance: High
>
> From: Chen A Chen <chen.a.chen@intel.com>
>
> 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>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> ---
> .../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.<BR>
> - Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2009 - 2016, 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
> 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/UefiShellLevel2Commands
> Lib.h
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.h
> index c262bb5..857487f 100644
> ---
> a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.h
> +++
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.h
> @@ -25,6 +25,7 @@
>
> #include <Uefi.h>
>
> +#include <Guid/GlobalVariable.h>
> #include <Guid/ShellLibHiiGuid.h>
>
> #include <Protocol/Shell.h>
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-04 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-04 8:47 [PATCH] ShellPkg/reset: Support "-fwui" flag Ruiyu Ni
2016-11-04 15:35 ` Carsey, Jaben
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox