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
This commit is contained in:
Qiu Shumin
2014-09-23 01:14:30 +00:00
committed by shenshushi
parent 387536e472
commit 77eef0d5a8
2 changed files with 23 additions and 17 deletions

View File

@ -768,8 +768,9 @@ BcfgAddOpt(
CHAR16 *FileName; CHAR16 *FileName;
CHAR16 *Temp2; CHAR16 *Temp2;
CHAR16 *Data; CHAR16 *Data;
UINT16 KeyIndex; UINT32 KeyIndex;
CHAR16 VariableName[12]; CHAR16 VariableName[12];
UINT8 *VariableData;
SHELL_FILE_HANDLE FileHandle; SHELL_FILE_HANDLE FileHandle;
@ -779,8 +780,10 @@ BcfgAddOpt(
FileName = NULL; FileName = NULL;
Data = NULL; Data = NULL;
KeyOptionBuffer = NULL; KeyOptionBuffer = NULL;
VariableData = NULL;
ZeroMem(&NewKeyOption, sizeof(EFI_KEY_OPTION)); ZeroMem(&NewKeyOption, sizeof(EFI_KEY_OPTION));
ZeroMem(VariableName, sizeof(VariableName));
while(Walker[0] == L' ') { while(Walker[0] == L' ') {
Walker++; Walker++;
@ -941,18 +944,17 @@ BcfgAddOpt(
} }
if (ShellStatus == SHELL_SUCCESS) { 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); UnicodeSPrint(VariableName, sizeof(VariableName), L"Key%04x", KeyIndex);
Status = gRT->GetVariable( Status = GetEfiGlobalVariable2 (VariableName, &VariableData, NULL);
VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid,
NULL,
(UINTN*)&Intermediate,
NULL);
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
break; break;
} }
if (!EFI_ERROR(Status)) {
SHELL_FREE_NON_NULL(VariableData);
} }
}
if (KeyIndex <= 0xFFFF) {
Status = gRT->SetVariable( Status = gRT->SetVariable(
VariableName, VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid, (EFI_GUID*)&gEfiGlobalVariableGuid,
@ -963,6 +965,10 @@ BcfgAddOpt(
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, VariableName, Status); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, VariableName, Status);
ShellStatus = SHELL_INVALID_PARAMETER; 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); ASSERT(FileName == NULL && Data == NULL);
} }
} }