ShellPkg: Per UEFI Shell 2.2 SPEC to make Shell supports 'NoNesting'.

This patch makes Shell support -nonesting invocation option. This option
specifies that EFI_SHELL_PROTOCOL.Execute API nesting of a new Shell
instance is optional and dependent on the 'nonesting' Shell environment
variable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jim Dailey <Jim_Dailey@Dell.com>
This commit is contained in:
Qiu Shumin
2016-03-08 10:26:29 +08:00
parent 7537258100
commit dcbdb8bfb0
3 changed files with 162 additions and 25 deletions

View File

@ -1,7 +1,7 @@
/** @file
This is THE shell (application)
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -33,6 +33,7 @@ SHELL_INFO ShellInfoObject = {
0,
0,
0,
0,
0
}},
0,
@ -69,6 +70,9 @@ SHELL_INFO ShellInfoObject = {
STATIC CONST CHAR16 mScriptExtension[] = L".NSH";
STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
CONST CHAR16 mNoNestingEnvVarName[] = L"nonesting";
CONST CHAR16 mNoNestingTrue[] = L"True";
CONST CHAR16 mNoNestingFalse[] = L"False";
/**
Cleans off leading and trailing spaces and tabs.
@ -456,6 +460,29 @@ UefiMain (
Status = ShellCommandCreateInitialMappingsAndPaths();
}
//
// Set the environment variable for nesting support
//
Size = 0;
TempString = NULL;
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest) {
//
// No change. require nesting in Shell Protocol Execute()
//
StrnCatGrow(&TempString,
&Size,
L"False",
0);
} else {
StrnCatGrow(&TempString,
&Size,
mNoNestingTrue,
0);
}
Status = InternalEfiShellSetEnv(mNoNestingEnvVarName, TempString, TRUE);
SHELL_FREE_NON_NULL(TempString);
Size = 0;
//
// save the device path for the loaded image and the device path for the filepath (under loaded image)
// These are where to look for the startup.nsh file
@ -891,6 +918,7 @@ ProcessCommandLine(
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = FALSE;
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = FALSE;
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = FALSE;
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = FALSE;
ShellInfoObject.ShellInitSettings.Delay = 5;
//
@ -950,6 +978,13 @@ ProcessCommandLine(
) == 0) {
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = TRUE;
}
else if (UnicodeCollation->StriColl (
UnicodeCollation,
L"-nonest",
CurrentArg
) == 0) {
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = TRUE;
}
else if (UnicodeCollation->StriColl (
UnicodeCollation,
L"-delay",
@ -1324,7 +1359,7 @@ AddLineToCommandHistory(
BUFFER_LIST *Walker;
UINT16 MaxHistoryCmdCount;
UINT16 Count;
Count = 0;
MaxHistoryCmdCount = PcdGet16(PcdShellMaxHistoryCommandCount);
@ -2452,7 +2487,7 @@ SetupAndRunCommandOrFile(
IN CHAR16 *CmdLine,
IN CHAR16 *FirstParameter,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,
OUT EFI_STATUS *CommandStatus
OUT EFI_STATUS *CommandStatus
)
{
EFI_STATUS Status;