From d4468cdf14e37bdbb35bff98c04e984d0622fcd1 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Wed, 18 Dec 2013 05:51:22 +0000 Subject: Rollback the change to EFI_BOOT_KEY_DATA structure since UEFI Spec adds the clarification that bitfields are ordered such that bit 0 is the least significant bit. Signed-off-by: Ruiyu Ni git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15000 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c | 18 ++++-------------- ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c | 18 ++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c index 73831d267e..b19d8d9fb8 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c @@ -47,16 +47,6 @@ typedef struct { CONST CHAR16 *OptData; } BGFG_OPERATION; -/** - Get the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3. - - @param KeyOption Pointer to the EFI_KEY_OPTION structure. - - @return Actual number of entries in EFI_KEY_OPTION.Keys. -**/ -#define KEY_OPTION_INPUT_KEY_COUNT(KeyOption) \ - (((KeyOption)->KeyData & EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK) >> LowBitSet32 (EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK)) - /** Update the optional data for a boot or driver option. @@ -843,7 +833,7 @@ BcfgAddOptDebug1( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Walker); ShellStatus = SHELL_INVALID_PARAMETER; } - NewKeyOption.KeyData = (UINT32)Intermediate; + NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate; Temp = StrStr(Walker, L" "); if (Temp != NULL) { Walker = Temp; @@ -858,13 +848,13 @@ BcfgAddOptDebug1( // Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct. // Re-allocate with the added information. // - KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption); + KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * NewKeyOption.KeyData.Options.InputKeyCount), &NewKeyOption); if (KeyOptionBuffer == NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellDebug1HiiHandle); ShellStatus = SHELL_OUT_OF_RESOURCES; } } - for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption); LoopCounter++) { + for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) { // // ScanCode // @@ -930,7 +920,7 @@ BcfgAddOptDebug1( VariableName, (EFI_GUID*)&gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), + sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * NewKeyOption.KeyData.Options.InputKeyCount), KeyOptionBuffer); if (EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, VariableName, Status); diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c index 543ae376e9..b91b34ffae 100644 --- a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c @@ -47,16 +47,6 @@ typedef struct { CONST CHAR16 *OptData; } BGFG_OPERATION; -/** - Get the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3. - - @param KeyOption Pointer to the EFI_KEY_OPTION structure. - - @return Actual number of entries in EFI_KEY_OPTION.Keys. -**/ -#define KEY_OPTION_INPUT_KEY_COUNT(KeyOption) \ - (((KeyOption)->KeyData & EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK) >> LowBitSet32 (EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK)) - /** Update the optional data for a boot or driver option. @@ -841,7 +831,7 @@ BcfgAddOptInstall1( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellInstall1HiiHandle, Walker); ShellStatus = SHELL_INVALID_PARAMETER; } - NewKeyOption.KeyData = (UINT32)Intermediate; + NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate; Temp = StrStr(Walker, L" "); if (Temp != NULL) { Walker = Temp; @@ -856,13 +846,13 @@ BcfgAddOptInstall1( // Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct. // Re-allocate with the added information. // - KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption); + KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount), &NewKeyOption); if (KeyOptionBuffer == NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellInstall1HiiHandle); ShellStatus = SHELL_OUT_OF_RESOURCES; } } - for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption); LoopCounter++) { + for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) { // // ScanCode // @@ -928,7 +918,7 @@ BcfgAddOptInstall1( VariableName, (EFI_GUID*)&gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), + 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), gShellInstall1HiiHandle, VariableName, Status); -- cgit v1.2.3