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.

Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
---
 .../BootMaintenanceManagerLib/BootMaintenance.c        |  2 +-
 .../BootMaintenanceManagerLib/BootMaintenanceManager.h |  2 ++
 .../Library/BootMaintenanceManagerLib/FormGuid.h       |  2 +-
 .../Library/BootMaintenanceManagerLib/UpdatePage.c     | 18 +++++++++---------
 .../Library/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 55c294d..2d52f9b 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenance.c
@@ -1293,11 +1293,11 @@ InitializeBmmConfig (
   InitializeDrivers (CallbackData);
 
   //
   // 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;
 
     if (NewLoadContext->IsBootNext) {
diff --git 
a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h 
b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h
index 6934a69..24526e1 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/BootMaintenanceManager.h
@@ -231,10 +231,12 @@ typedef enum _TYPE_OF_TERMINAL {
 #define COM_TERMINAL_QUESTION_ID        QUESTION_ID (COMTerminalType)
 #define COM_FLOWCONTROL_QUESTION_ID     QUESTION_ID (COMFlowControl)
 
 #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
 /// display the value properly
 ///
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h 
b/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h
index 3e1990d..cf14b40 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/FormGuid.h
@@ -101,11 +101,11 @@ typedef struct {
   //
   // Three questions displayed at the main page
   // for Timeout, BootNext, Variables respectively
   //
   UINT16  BootTimeOut;
-  UINT16  BootNext;
+  UINT32  BootNext;
 
   //
   // This is the COM1 Attributes value storage
   //
   UINT8   COM1BaudRate;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c 
b/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c
index 78ace0c..cd1756a 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/UpdatePage.c
@@ -684,51 +684,51 @@ UpdateBootNextPage (
 
   if (NumberOfOptions > 0) {
     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);
       NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
 
       if (NewLoadContext->IsBootNext) {
         HiiCreateOneOfOptionOpCode (
           OptionsOpCodeHandle,
           NewMenuEntry->DisplayStringToken,
           EFI_IFR_OPTION_DEFAULT,
-          EFI_IFR_TYPE_NUM_SIZE_16,
+          EFI_IFR_TYPE_NUM_SIZE_32,
           Index
           );
         CallbackData->BmmFakeNvData.BootNext = Index;
       } else {
         HiiCreateOneOfOptionOpCode (
           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
         );
     }      
 
     HiiCreateOneOfOpCode (
       mStartOpCodeHandle,
@@ -736,11 +736,11 @@ UpdateBootNextPage (
       VARSTORE_ID_BOOT_MAINT,
       BOOT_NEXT_VAR_OFFSET,
       STRING_TOKEN (STR_BOOT_NEXT),
       STRING_TOKEN (STR_BOOT_NEXT_HELP),
       0,
-      EFI_IFR_NUMERIC_SIZE_2,
+      EFI_IFR_NUMERIC_SIZE_4,
       OptionsOpCodeHandle,
       NULL
       );
 
     HiiFreeOpCodeHandle (OptionsOpCodeHandle);
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c 
b/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c
index cd2da4a..a276cae 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerLib/Variable.c
@@ -866,11 +866,11 @@ Var_UpdateBootNext (
 
     NewLoadContext              = (BM_LOAD_CONTEXT *) 
NewMenuEntry->VariableContext;
     NewLoadContext->IsBootNext  = FALSE;
   }
 
-  if (CurrentFakeNVMap->BootNext == BootOptionMenu.MenuNumber) {
+  if (CurrentFakeNVMap->BootNext == NONE_BOOTNEXT_VALUE) {
     EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid);
     return EFI_SUCCESS;
   }
 
   NewMenuEntry = BOpt_GetMenuEntry (
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to