summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2014-09-23 01:14:30 +0000
committershenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524>2014-09-23 01:14:30 +0000
commit77eef0d5a82bf2a49cc6bb25077ba73e922ea160 (patch)
treeea41b305f41f4f9cf1ed76dc19ff75af1c03533a /ShellPkg
parent387536e472aa0eb4a169f8456167fef53524fbe0 (diff)
downloadedk2-platforms-77eef0d5a82bf2a49cc6bb25077ba73e922ea160.tar.xz
ShellPkg: Fix setting hot key for boot option fail.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16159 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c40
-rw-r--r--ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.unibin17972 -> 18278 bytes
2 files changed, 23 insertions, 17 deletions
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
index 28f05eb1de..33c2470938 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -768,8 +768,9 @@ BcfgAddOpt(
CHAR16 *FileName;
CHAR16 *Temp2;
CHAR16 *Data;
- UINT16 KeyIndex;
+ UINT32 KeyIndex;
CHAR16 VariableName[12];
+ UINT8 *VariableData;
SHELL_FILE_HANDLE FileHandle;
@@ -779,8 +780,10 @@ BcfgAddOpt(
FileName = NULL;
Data = NULL;
KeyOptionBuffer = NULL;
+ VariableData = NULL;
ZeroMem(&NewKeyOption, sizeof(EFI_KEY_OPTION));
+ ZeroMem(VariableName, sizeof(VariableName));
while(Walker[0] == L' ') {
Walker++;
@@ -941,28 +944,31 @@ BcfgAddOpt(
}
if (ShellStatus == SHELL_SUCCESS) {
- for (Temp2 = NULL, KeyIndex = 0 ; KeyIndex < 0xFFFF ; KeyIndex++) {
+ for (Temp2 = NULL, KeyIndex = 0 ; KeyIndex <= 0xFFFF ; KeyIndex++) {
UnicodeSPrint(VariableName, sizeof(VariableName), L"Key%04x", KeyIndex);
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- (UINTN*)&Intermediate,
- NULL);
+ Status = GetEfiGlobalVariable2 (VariableName, &VariableData, NULL);
if (Status == EFI_NOT_FOUND) {
break;
}
+ if (!EFI_ERROR(Status)) {
+ SHELL_FREE_NON_NULL(VariableData);
+ }
}
- Status = gRT->SetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
- KeyOptionBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, VariableName, Status);
+ if (KeyIndex <= 0xFFFF) {
+ Status = gRT->SetVariable(
+ VariableName,
+ (EFI_GUID*)&gEfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
+ KeyOptionBuffer);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, VariableName, Status);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ }
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_VAR_NO_NUM), gShellBcfgHiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
- }
+ }
ASSERT(FileName == NULL && Data == NULL);
}
}
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
index 2a3c232dfc..3b80bdc441 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
Binary files differ