From f79865264f58cc12e3ace3b83cbea1ee289a5e55 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Wed, 6 Jan 2016 00:55:12 +0000 Subject: [PATCH] MdeModulePkg:Change the type of BootNext Currently the invalid boot next set to the number of boot option, when add a new boot option,also need update the boot next value, otherwise it will be incorrect.Now set the type of BootNext value to UINT32,the number out of the range of UINT16 means it is an invalid BootNext Value. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19591 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BootMaintenance.c | 2 +- .../BootMaintenanceManager.h | 2 ++ .../BootMaintenanceManagerLib/FormGuid.h | 2 +- .../BootMaintenanceManagerLib/UpdatePage.c | 18 +++++++++--------- .../BootMaintenanceManagerLib/Variable.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c index 55c294dd73..2d52f9bac3 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c @@ -1295,7 +1295,7 @@ InitializeBmmConfig ( // // Initialize data which located in BMM main page // - CallbackData->BmmFakeNvData.BootNext = (UINT16) (BootOptionMenu.MenuNumber); + CallbackData->BmmFakeNvData.BootNext = NONE_BOOTNEXT_VALUE; for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index); NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h index 6934a692a6..24526e1096 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h @@ -233,6 +233,8 @@ typedef enum _TYPE_OF_TERMINAL { #define STRING_DEPOSITORY_NUMBER 8 +#define NONE_BOOTNEXT_VALUE (0xFFFF + 1) + /// /// Serial Ports attributes, first one is the value for /// return from callback function, stringtoken is used to diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h b/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h index 3e1990dfc6..cf14b40083 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h @@ -103,7 +103,7 @@ typedef struct { // for Timeout, BootNext, Variables respectively // UINT16 BootTimeOut; - UINT16 BootNext; + UINT32 BootNext; // // This is the COM1 Attributes value storage diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c index 78ace0c135..cd1756aa58 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c @@ -686,7 +686,7 @@ UpdateBootNextPage ( OptionsOpCodeHandle = HiiAllocateOpCodeHandle (); ASSERT (OptionsOpCodeHandle != NULL); - CallbackData->BmmFakeNvData.BootNext = (UINT16) (BootOptionMenu.MenuNumber); + CallbackData->BmmFakeNvData.BootNext = NONE_BOOTNEXT_VALUE; for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index); @@ -697,7 +697,7 @@ UpdateBootNextPage ( OptionsOpCodeHandle, NewMenuEntry->DisplayStringToken, EFI_IFR_OPTION_DEFAULT, - EFI_IFR_TYPE_NUM_SIZE_16, + EFI_IFR_TYPE_NUM_SIZE_32, Index ); CallbackData->BmmFakeNvData.BootNext = Index; @@ -706,27 +706,27 @@ UpdateBootNextPage ( OptionsOpCodeHandle, NewMenuEntry->DisplayStringToken, 0, - EFI_IFR_TYPE_NUM_SIZE_16, + EFI_IFR_TYPE_NUM_SIZE_32, Index ); } } - if (CallbackData->BmmFakeNvData.BootNext == Index) { + if (CallbackData->BmmFakeNvData.BootNext == NONE_BOOTNEXT_VALUE) { HiiCreateOneOfOptionOpCode ( OptionsOpCodeHandle, STRING_TOKEN (STR_NONE), EFI_IFR_OPTION_DEFAULT, - EFI_IFR_TYPE_NUM_SIZE_16, - Index + EFI_IFR_TYPE_NUM_SIZE_32, + NONE_BOOTNEXT_VALUE ); } else { HiiCreateOneOfOptionOpCode ( OptionsOpCodeHandle, STRING_TOKEN (STR_NONE), 0, - EFI_IFR_TYPE_NUM_SIZE_16, - Index + EFI_IFR_TYPE_NUM_SIZE_32, + NONE_BOOTNEXT_VALUE ); } @@ -738,7 +738,7 @@ UpdateBootNextPage ( STRING_TOKEN (STR_BOOT_NEXT), STRING_TOKEN (STR_BOOT_NEXT_HELP), 0, - EFI_IFR_NUMERIC_SIZE_2, + EFI_IFR_NUMERIC_SIZE_4, OptionsOpCodeHandle, NULL ); diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c b/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c index cd2da4a905..a276caed05 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c @@ -868,7 +868,7 @@ Var_UpdateBootNext ( NewLoadContext->IsBootNext = FALSE; } - if (CurrentFakeNVMap->BootNext == BootOptionMenu.MenuNumber) { + if (CurrentFakeNVMap->BootNext == NONE_BOOTNEXT_VALUE) { EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid); return EFI_SUCCESS; }