* [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback
@ 2016-10-17 8:51 Dandan Bi
2016-10-17 8:51 ` [patch 2/5] MdeModulePkg/BMMUI: Remove the incorrect and useless codes Dandan Bi
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dandan Bi @ 2016-10-17 8:51 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Liming Gao, Eric Dong
In current codes, When user does some change related to Console or Terminal,
when saving data, it will update the content in TerminalMenu and ConsoleMenu
in BootMaintRouteConfig function. This patch moves the update action to the
BootMaintCallback function with EFI_BROWSER_ACTION_CHANGED type.
The reason for this change is: in BootMaintRouteConfig function when
Var_UpdateConsoleXXXOption() return failure and user discard the previous
change, we should re_update the content in the TerminalMenu and ConsoleMenu.
So we move the update action to the changed callback.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../BootMaintenanceManagerUiLib/BootMaintenance.c | 177 ++++++++++++++-------
.../BootMaintenanceManagerUiLib/UpdatePage.c | 16 +-
2 files changed, 126 insertions(+), 67 deletions(-)
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
index a190596..92c44ea 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
@@ -442,10 +442,112 @@ BmmExtractDevicePathFromHiiHandle (
return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
}
/**
+ Update the terminal content in TerminalMenu.
+
+ @param BmmData The BMM fake NV data.
+
+**/
+VOID
+UpdateTerminalContent (
+ IN BMM_FAKE_NV_DATA *BmmData
+ )
+{
+ UINT16 Index;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
+ BM_MENU_ENTRY *NewMenuEntry;
+
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ ASSERT (NewMenuEntry != NULL);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext->BaudRateIndex = BmmData->COMBaudRate[Index];
+ ASSERT (BmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeof (BaudRateList[0])));
+ NewTerminalContext->BaudRate = BaudRateList[BmmData->COMBaudRate[Index]].Value;
+ NewTerminalContext->DataBitsIndex = BmmData->COMDataRate[Index];
+ ASSERT (BmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeof (DataBitsList[0])));
+ NewTerminalContext->DataBits = (UINT8) DataBitsList[BmmData->COMDataRate[Index]].Value;
+ NewTerminalContext->StopBitsIndex = BmmData->COMStopBits[Index];
+ ASSERT (BmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeof (StopBitsList[0])));
+ NewTerminalContext->StopBits = (UINT8) StopBitsList[BmmData->COMStopBits[Index]].Value;
+ NewTerminalContext->ParityIndex = BmmData->COMParity[Index];
+ ASSERT (BmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (ParityList[0])));
+ NewTerminalContext->Parity = (UINT8) ParityList[BmmData->COMParity[Index]].Value;
+ NewTerminalContext->TerminalType = BmmData->COMTerminalType[Index];
+ NewTerminalContext->FlowControl = BmmData->COMFlowControl[Index];
+ ChangeTerminalDevicePath (
+ NewTerminalContext->DevicePath,
+ FALSE
+ );
+ }
+}
+
+/**
+ Update the console content in ConsoleMenu.
+
+ @param BmmData The BMM fake NV data.
+
+**/
+VOID
+UpdateConsoleContent(
+ IN CHAR16 *ConsoleName,
+ IN BMM_FAKE_NV_DATA *BmmData
+ )
+{
+ UINT16 Index;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
+ BM_MENU_ENTRY *NewMenuEntry;
+
+ if (StrCmp (ConsoleName, L"ConIn") == 0) {
+ for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++){
+ NewMenuEntry = BOpt_GetMenuEntry(&ConsoleInpMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
+ NewConsoleContext->IsActive = BmmData->ConsoleInCheck[Index];
+ }
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
+ NewTerminalContext->IsConIn = BmmData->ConsoleInCheck[Index + ConsoleInpMenu.MenuNumber];
+ }
+ }
+
+ if (StrCmp (ConsoleName, L"ConOut") == 0) {
+ for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++){
+ NewMenuEntry = BOpt_GetMenuEntry(&ConsoleOutMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
+ NewConsoleContext->IsActive = BmmData->ConsoleOutCheck[Index];
+ }
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
+ NewTerminalContext->IsConOut = BmmData->ConsoleOutCheck[Index + ConsoleOutMenu.MenuNumber];
+ }
+ }
+ if (StrCmp (ConsoleName, L"ErrOut") == 0) {
+ for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++){
+ NewMenuEntry = BOpt_GetMenuEntry(&ConsoleErrMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ ASSERT (Index < MAX_MENU_NUMBER);
+ NewConsoleContext->IsActive = BmmData->ConsoleErrCheck[Index];
+ }
+ for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
+ NewTerminalContext->IsStdErr = BmmData->ConsoleErrCheck[Index + ConsoleErrMenu.MenuNumber];
+ }
+ }
+}
+
+/**
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Request A null-terminated Unicode string in <ConfigRequest> format.
@@ -587,12 +689,10 @@ BootMaintRouteConfig (
EFI_STATUS Status;
UINTN BufferSize;
EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
BMM_FAKE_NV_DATA *NewBmmData;
BMM_FAKE_NV_DATA *OldBmmData;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
UINT16 Index;
BOOLEAN TerminalAttChange;
BMM_CALLBACK_DATA *Private;
@@ -733,31 +833,10 @@ BootMaintRouteConfig (
CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) == 0 &&
CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) == 0) {
continue;
}
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- ASSERT (NewMenuEntry != NULL);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- NewTerminalContext->BaudRateIndex = NewBmmData->COMBaudRate[Index];
- ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeof (BaudRateList[0])));
- NewTerminalContext->BaudRate = BaudRateList[NewBmmData->COMBaudRate[Index]].Value;
- NewTerminalContext->DataBitsIndex = NewBmmData->COMDataRate[Index];
- ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeof (DataBitsList[0])));
- NewTerminalContext->DataBits = (UINT8) DataBitsList[NewBmmData->COMDataRate[Index]].Value;
- NewTerminalContext->StopBitsIndex = NewBmmData->COMStopBits[Index];
- ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeof (StopBitsList[0])));
- NewTerminalContext->StopBits = (UINT8) StopBitsList[NewBmmData->COMStopBits[Index]].Value;
- NewTerminalContext->ParityIndex = NewBmmData->COMParity[Index];
- ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (ParityList[0])));
- NewTerminalContext->Parity = (UINT8) ParityList[NewBmmData->COMParity[Index]].Value;
- NewTerminalContext->TerminalType = NewBmmData->COMTerminalType[Index];
- NewTerminalContext->FlowControl = NewBmmData->COMFlowControl[Index];
- ChangeTerminalDevicePath (
- NewTerminalContext->DevicePath,
- FALSE
- );
TerminalAttChange = TRUE;
}
if (TerminalAttChange) {
Var_UpdateConsoleInpOption ();
Var_UpdateConsoleOutOption ();
@@ -765,54 +844,18 @@ BootMaintRouteConfig (
}
//
// Check data which located in Console Options Menu and save the settings if need
//
if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck, sizeof (NewBmmData->ConsoleInCheck)) != 0){
- for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleInpMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
- ASSERT (Index < MAX_MENU_NUMBER);
- NewConsoleContext->IsActive = NewBmmData->ConsoleInCheck[Index];
- }
- for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
- NewTerminalContext->IsConIn = NewBmmData->ConsoleInCheck[Index + ConsoleInpMenu.MenuNumber];
- }
Var_UpdateConsoleInpOption();
}
if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutCheck, sizeof (NewBmmData->ConsoleOutCheck)) != 0){
- for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleOutMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
- ASSERT (Index < MAX_MENU_NUMBER);
- NewConsoleContext->IsActive = NewBmmData->ConsoleOutCheck[Index];
- }
- for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
- NewTerminalContext->IsConOut = NewBmmData->ConsoleOutCheck[Index + ConsoleOutMenu.MenuNumber];
- }
Var_UpdateConsoleOutOption();
}
if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrCheck, sizeof (NewBmmData->ConsoleErrCheck)) != 0){
- for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleErrMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
- ASSERT (Index < MAX_MENU_NUMBER);
- NewConsoleContext->IsActive = NewBmmData->ConsoleErrCheck[Index];
- }
- for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
- NewTerminalContext->IsStdErr = NewBmmData->ConsoleErrCheck[Index + ConsoleErrMenu.MenuNumber];
- }
Var_UpdateErrorOutOption();
}
if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0 ||
CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptionalData, sizeof (NewBmmData->BootOptionalData)) != 0) {
@@ -1074,10 +1117,26 @@ BootMaintCallback (
default:
break;
}
}
+ //
+ // Update the content in Terminal menu and Console menu here.
+ //
+ if (QuestionId == COM_BAUD_RATE_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_DATA_RATE_QUESTION_ID + Private->CurrentTerminal ||
+ QuestionId == COM_PARITY_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_STOP_BITS_QUESTION_ID + Private->CurrentTerminal ||
+ QuestionId == COM_TERMINAL_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_FLOWCONTROL_QUESTION_ID + Private->CurrentTerminal
+ ) {
+ UpdateTerminalContent(CurrentFakeNVMap);
+ }
+ if ((QuestionId >= CON_IN_DEVICE_QUESTION_ID) && (QuestionId < CON_IN_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
+ UpdateConsoleContent (L"ConIn",CurrentFakeNVMap);
+ } else if ((QuestionId >= CON_OUT_DEVICE_QUESTION_ID) && (QuestionId < CON_OUT_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
+ UpdateConsoleContent (L"ConOut", CurrentFakeNVMap);
+ } else if ((QuestionId >= CON_ERR_DEVICE_QUESTION_ID) && (QuestionId < CON_ERR_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
+ UpdateConsoleContent (L"ConErr", CurrentFakeNVMap);
+ }
}
//
// Pass changed uncommitted data back to Form Browser
//
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index 9e79826..ee8ff5d 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -517,11 +517,11 @@ UpdateConsolePage (
(EFI_QUESTION_ID) (QuestionIdBase + Index),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (VariableOffsetBase + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
- 0,
+ EFI_IFR_FLAG_CALLBACK,
CheckFlags,
NULL
);
}
@@ -546,11 +546,11 @@ UpdateConsolePage (
(EFI_QUESTION_ID) (QuestionIdBase + Index),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (VariableOffsetBase + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
- 0,
+ EFI_IFR_FLAG_CALLBACK,
CheckFlags,
NULL
);
Index++;
@@ -829,11 +829,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_BAUD_RATE_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_BAUD_RATE_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_BAUD_RATE),
STRING_TOKEN (STR_COM_BAUD_RATE),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
@@ -862,11 +862,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_DATA_RATE_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_DATA_RATE_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_DATA_BITS),
STRING_TOKEN (STR_COM_DATA_BITS),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
@@ -894,11 +894,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_PARITY_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_PARITY_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_PARITY),
STRING_TOKEN (STR_COM_PARITY),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
@@ -926,11 +926,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_STOP_BITS_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_STOP_BITS_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_STOP_BITS),
STRING_TOKEN (STR_COM_STOP_BITS),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
@@ -958,11 +958,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_TERMINAL_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_TERMINAL_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_TERMI_TYPE),
STRING_TOKEN (STR_COM_TERMI_TYPE),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
@@ -989,11 +989,11 @@ UpdateTerminalPage (
(EFI_QUESTION_ID) (COM_FLOWCONTROL_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
(UINT16) (COM_FLOWCONTROL_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_FLOW_CONTROL),
STRING_TOKEN (STR_COM_FLOW_CONTROL),
- 0,
+ EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [patch 2/5] MdeModulePkg/BMMUI: Remove the incorrect and useless codes
2016-10-17 8:51 [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback Dandan Bi
@ 2016-10-17 8:51 ` Dandan Bi
2016-10-17 8:51 ` [patch 3/5] MdeModulePkg/BMMUI: Make the BmmFakeNvData and BmmOldFakeNVData consistent Dandan Bi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2016-10-17 8:51 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Liming Gao, Eric Dong
When updating console page, the "ConsoleCheck" in BmmFakeNvData may maintain
the old uncommitted data, we should not copy it to BmmOldFakeNVData.
And in BootMaintRouteConfig function, when save data successfully,
it will copy the BmmFakeNvData to the BmmOldFakeNVData.
So we can delete the logic here.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../Library/BootMaintenanceManagerUiLib/UpdatePage.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index ee8ff5d..960d0b0 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -457,46 +457,36 @@ UpdateConsolePage (
BM_TERMINAL_CONTEXT *NewTerminalContext;
UINT16 Index;
UINT16 Index2;
UINT8 CheckFlags;
UINT8 *ConsoleCheck;
- UINT8 *OldConsoleCheck;
- UINTN ConsoleCheckSize;
EFI_QUESTION_ID QuestionIdBase;
UINT16 VariableOffsetBase;
CallbackData->BmmAskSaveOrNot = TRUE;
UpdatePageStart (CallbackData);
ConsoleCheck = NULL;
- OldConsoleCheck = NULL;
QuestionIdBase = 0;
VariableOffsetBase = 0;
- ConsoleCheckSize = 0;
switch (UpdatePageId) {
case FORM_CON_IN_ID:
ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];
- OldConsoleCheck = &CallbackData->BmmOldFakeNVData.ConsoleInCheck[0];
- ConsoleCheckSize = sizeof (CallbackData->BmmFakeNvData.ConsoleInCheck);
QuestionIdBase = CON_IN_DEVICE_QUESTION_ID;
VariableOffsetBase = CON_IN_DEVICE_VAR_OFFSET;
break;
case FORM_CON_OUT_ID:
ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];
- OldConsoleCheck = &CallbackData->BmmOldFakeNVData.ConsoleOutCheck[0];
- ConsoleCheckSize = sizeof (CallbackData->BmmFakeNvData.ConsoleOutCheck);
QuestionIdBase = CON_OUT_DEVICE_QUESTION_ID;
VariableOffsetBase = CON_OUT_DEVICE_VAR_OFFSET;
break;
case FORM_CON_ERR_ID:
ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];
- OldConsoleCheck = &CallbackData->BmmOldFakeNVData.ConsoleErrCheck[0];
- ConsoleCheckSize = sizeof (CallbackData->BmmFakeNvData.ConsoleErrCheck);
QuestionIdBase = CON_ERR_DEVICE_QUESTION_ID;
VariableOffsetBase = CON_ERR_DEVICE_VAR_OFFSET;
break;
}
ASSERT (ConsoleCheck != NULL);
@@ -554,12 +544,10 @@ UpdateConsolePage (
);
Index++;
}
- CopyMem (OldConsoleCheck, ConsoleCheck, ConsoleCheckSize);
-
UpdatePageEnd (CallbackData);
}
/**
Update the page's NV Map if user has changed the order
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [patch 3/5] MdeModulePkg/BMMUI: Make the BmmFakeNvData and BmmOldFakeNVData consistent
2016-10-17 8:51 [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback Dandan Bi
2016-10-17 8:51 ` [patch 2/5] MdeModulePkg/BMMUI: Remove the incorrect and useless codes Dandan Bi
@ 2016-10-17 8:51 ` Dandan Bi
2016-10-17 8:51 ` [patch 4/5] MdeModulePkg/BMMUI: Show "Change Boot/Driver order" page correctly Dandan Bi
2016-10-17 8:51 ` [patch 5/5] MdeModulePkg/BMMUI: Add error handling codes Dandan Bi
3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2016-10-17 8:51 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Liming Gao, Eric Dong
In BootMaintRouteConfig function, it will compare the data in BmmFakeNvData
and BmmOldFakeNVData to see whether there are some changes need to save.
In current codes when discarding changes or removing the useless changes,
it will update the related fields in BmmFakeNvData.
But also need to update related fields in BmmOldFakeNVData,
or it will result in incorrect comparison in BootMaintRouteConfig function,
then resulting in incorrect UI behaviors.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../Library/BootMaintenanceManagerUiLib/BootMaintenance.c | 14 ++++++++++----
.../Library/BootMaintenanceManagerUiLib/UpdatePage.c | 6 ++++++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
index 92c44ea..7475a94 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
@@ -923,10 +923,11 @@ BootMaintCallback (
)
{
BMM_CALLBACK_DATA *Private;
BM_MENU_ENTRY *NewMenuEntry;
BMM_FAKE_NV_DATA *CurrentFakeNVMap;
+ BMM_FAKE_NV_DATA *OldFakeNVMap;
UINTN Index;
EFI_DEVICE_PATH_PROTOCOL * File;
if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED && Action != EFI_BROWSER_ACTION_FORM_OPEN) {
//
@@ -957,10 +958,11 @@ BootMaintCallback (
}
//
// Retrive uncommitted data from Form Browser
//
CurrentFakeNVMap = &Private->BmmFakeNvData;
+ OldFakeNVMap = &Private->BmmOldFakeNVData;
HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (Value == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1059,21 +1061,25 @@ BootMaintCallback (
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
} else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {
//
// Discard changes and exit formset
//
- CurrentFakeNVMap->DriverOptionalData[0] = 0x0000;
- CurrentFakeNVMap->DriverDescriptionData[0] = 0x0000;
+ ZeroMem (CurrentFakeNVMap->DriverOptionalData, sizeof (CurrentFakeNVMap->DriverOptionalData));
+ ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentFakeNVMap->BootDescriptionData));
+ ZeroMem (OldFakeNVMap->DriverOptionalData, sizeof (OldFakeNVMap->DriverOptionalData));
+ ZeroMem (OldFakeNVMap->DriverDescriptionData, sizeof (OldFakeNVMap->DriverDescriptionData));
CurrentFakeNVMap->DriverOptionChanged = FALSE;
CurrentFakeNVMap->ForceReconnect = TRUE;
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
} else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_BOOT) {
//
// Discard changes and exit formset
//
- CurrentFakeNVMap->BootOptionalData[0] = 0x0000;
- CurrentFakeNVMap->BootDescriptionData[0] = 0x0000;
+ ZeroMem (CurrentFakeNVMap->BootOptionalData, sizeof (CurrentFakeNVMap->BootOptionalData));
+ ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentFakeNVMap->BootDescriptionData));
+ ZeroMem (OldFakeNVMap->BootOptionalData, sizeof (OldFakeNVMap->BootOptionalData));
+ ZeroMem (OldFakeNVMap->BootDescriptionData, sizeof (OldFakeNVMap->BootDescriptionData));
CurrentFakeNVMap->BootOptionChanged = FALSE;
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
} else if (QuestionId == KEY_VALUE_BOOT_DESCRIPTION || QuestionId == KEY_VALUE_BOOT_OPTION) {
CurrentFakeNVMap->BootOptionChanged = TRUE;
} else if (QuestionId == KEY_VALUE_DRIVER_DESCRIPTION || QuestionId == KEY_VALUE_DRIVER_OPTION) {
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index 960d0b0..29d3ac9 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -260,10 +260,11 @@ UpdateBootDelPage (
// CallbackData->BmmFakeNvData.BootOptionDelMark[Index] = FALSE means BDS knows the selected boot option has
// deleted, browser maintains old useless info. So clear this info here, and later update this info to browser
// through HiiSetBrowserData function.
//
CallbackData->BmmFakeNvData.BootOptionDel[Index] = FALSE;
+ CallbackData->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;
}
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
(EFI_QUESTION_ID) (BOOT_OPTION_DEL_QUESTION_ID + Index),
@@ -346,10 +347,11 @@ UpdateDrvDelPage (
// CallbackData->BmmFakeNvData.BootOptionDelMark[Index] = FALSE means BDS knows the selected boot option has
// deleted, browser maintains old useless info. So clear this info here, and later update this info to browser
// through HiiSetBrowserData function.
//
CallbackData->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
+ CallbackData->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;
}
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
(EFI_QUESTION_ID) (DRIVER_OPTION_DEL_QUESTION_ID + Index),
VARSTORE_ID_BOOT_MAINT,
@@ -1023,15 +1025,19 @@ UpdateOptionPage(
if(FormId == FORM_BOOT_ADD_ID){
if (!CallbackData->BmmFakeNvData.BootOptionChanged) {
ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (CallbackData->BmmFakeNvData.BootOptionalData));
ZeroMem (CallbackData->BmmFakeNvData.BootDescriptionData, sizeof (CallbackData->BmmFakeNvData.BootDescriptionData));
+ ZeroMem (CallbackData->BmmOldFakeNVData.BootOptionalData, sizeof (CallbackData->BmmOldFakeNVData.BootOptionalData));
+ ZeroMem (CallbackData->BmmOldFakeNVData.BootDescriptionData, sizeof (CallbackData->BmmOldFakeNVData.BootDescriptionData));
}
} else if (FormId == FORM_DRV_ADD_FILE_ID){
if (!CallbackData->BmmFakeNvData.DriverOptionChanged) {
ZeroMem (CallbackData->BmmFakeNvData.DriverOptionalData, sizeof (CallbackData->BmmFakeNvData.DriverOptionalData));
ZeroMem (CallbackData->BmmFakeNvData.DriverDescriptionData, sizeof (CallbackData->BmmFakeNvData.DriverDescriptionData));
+ ZeroMem (CallbackData->BmmOldFakeNVData.DriverOptionalData, sizeof (CallbackData->BmmOldFakeNVData.DriverOptionalData));
+ ZeroMem (CallbackData->BmmOldFakeNVData.DriverDescriptionData, sizeof (CallbackData->BmmOldFakeNVData.DriverDescriptionData));
}
}
RefreshUpdateData();
mStartLabel->Number = FormId;
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [patch 4/5] MdeModulePkg/BMMUI: Show "Change Boot/Driver order" page correctly
2016-10-17 8:51 [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback Dandan Bi
2016-10-17 8:51 ` [patch 2/5] MdeModulePkg/BMMUI: Remove the incorrect and useless codes Dandan Bi
2016-10-17 8:51 ` [patch 3/5] MdeModulePkg/BMMUI: Make the BmmFakeNvData and BmmOldFakeNVData consistent Dandan Bi
@ 2016-10-17 8:51 ` Dandan Bi
2016-10-17 8:51 ` [patch 5/5] MdeModulePkg/BMMUI: Add error handling codes Dandan Bi
3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2016-10-17 8:51 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Liming Gao, Eric Dong
When user enter the "Change Boot Order" page, the BootOptionOrder in
BmmFakeNvData may maintain some uncommitted data which are not saved
in "BootOrder" Variable and BootOptionMenu. So we should not always get
the BootOptionOrder through the function GetBootOrder, it will
result in incorrect UI behaviors. When the BootOptionOrder has not been
saved, we should use the BootOptionOrder in current BmmFakeNvData.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../Library/BootMaintenanceManagerUiLib/UpdatePage.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index 29d3ac9..8194979 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -583,18 +583,34 @@ UpdateOrderPage (
QuestionId = 0;
VarOffset = 0;
switch (UpdatePageId) {
case FORM_BOOT_CHG_ID:
- GetBootOrder (CallbackData);
+ //
+ // If the BootOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
+ // means all Boot Options has been save in BootOptionMenu, we can get the date from the menu.
+ // else means browser maintains some uncommitted date which are not saved in BootOptionMenu,
+ // so we should not get the data from BootOptionMenu to show it.
+ //
+ if (CompareMem (CallbackData->BmmFakeNvData.BootOptionOrder, CallbackData->BmmOldFakeNVData.BootOptionOrder, sizeof (CallbackData->BmmFakeNvData.BootOptionOrder)) == 0) {
+ GetBootOrder (CallbackData);
+ }
OptionOrder = CallbackData->BmmFakeNvData.BootOptionOrder;
QuestionId = BOOT_OPTION_ORDER_QUESTION_ID;
VarOffset = BOOT_OPTION_ORDER_VAR_OFFSET;
break;
case FORM_DRV_CHG_ID:
- GetDriverOrder (CallbackData);
+ //
+ // If the DriverOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
+ // means all Driver Options has been save in DriverOptionMenu, we can get the DriverOptionOrder from the menu.
+ // else means browser maintains some uncommitted date which are not saved in DriverOptionMenu,
+ // so we should not get the data from DriverOptionMenu to show it.
+ //
+ if (CompareMem (CallbackData->BmmFakeNvData.DriverOptionOrder, CallbackData->BmmOldFakeNVData.DriverOptionOrder, sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder)) == 0) {
+ GetDriverOrder (CallbackData);
+ }
OptionOrder = CallbackData->BmmFakeNvData.DriverOptionOrder;
QuestionId = DRIVER_OPTION_ORDER_QUESTION_ID;
VarOffset = DRIVER_OPTION_ORDER_VAR_OFFSET;
break;
}
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [patch 5/5] MdeModulePkg/BMMUI: Add error handling codes
2016-10-17 8:51 [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback Dandan Bi
` (2 preceding siblings ...)
2016-10-17 8:51 ` [patch 4/5] MdeModulePkg/BMMUI: Show "Change Boot/Driver order" page correctly Dandan Bi
@ 2016-10-17 8:51 ` Dandan Bi
3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2016-10-17 8:51 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Liming Gao, Eric Dong
The function which handles the "Boot####", "BootOrder" ...
may return failure. This patch adds the error handling codes.
return the failure info to browser.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../BootMaintenanceManagerUiLib/BootMaintenance.c | 201 ++++++++++++++++++---
.../Library/BootMaintenanceManagerUiLib/Variable.c | 28 ++-
2 files changed, 202 insertions(+), 27 deletions(-)
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
index 7475a94..33c85b7 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
@@ -442,10 +442,95 @@ BmmExtractDevicePathFromHiiHandle (
return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
}
/**
+ Converts the unicode character of the string from uppercase to lowercase.
+ This is a internal function.
+
+ @param ConfigString String to be converted
+
+**/
+VOID
+HiiToLower (
+ IN EFI_STRING ConfigString
+ )
+{
+ EFI_STRING String;
+ BOOLEAN Lower;
+
+ ASSERT (ConfigString != NULL);
+
+ //
+ // Convert all hex digits in range [A-F] in the configuration header to [a-f]
+ //
+ for (String = ConfigString, Lower = FALSE; *String != L'\0'; String++) {
+ if (*String == L'=') {
+ Lower = TRUE;
+ } else if (*String == L'&') {
+ Lower = FALSE;
+ } else if (Lower && *String >= L'A' && *String <= L'F') {
+ *String = (CHAR16) (*String - L'A' + L'a');
+ }
+ }
+}
+
+/**
+ Update the progress string through the offset value.
+
+ @param Offset The offset value
+ @param Configuration Point to the configuration string.
+
+**/
+EFI_STRING
+UpdateProgress(
+ IN UINTN Offset,
+ IN EFI_STRING Configuration
+)
+{
+ UINTN Length;
+ EFI_STRING StringPtr;
+ EFI_STRING ReturnString;
+
+ StringPtr = NULL;
+ ReturnString = NULL;
+
+ //
+ // &OFFSET=XXXX followed by a Null-terminator.
+ // Length = StrLen (L"&OFFSET=") + 4 + 1
+ //
+ Length = StrLen (L"&OFFSET=") + 4 + 1;
+
+ StringPtr = AllocateZeroPool (Length * sizeof (CHAR16));
+
+ if (StringPtr == NULL) {
+ return NULL;
+ }
+
+ UnicodeSPrint (
+ StringPtr,
+ (8 + 4 + 1) * sizeof (CHAR16),
+ L"&OFFSET=%04x",
+ Offset
+ );
+
+ ReturnString = StrStr (Configuration, StringPtr);
+
+ if (ReturnString == NULL) {
+ //
+ // If doesn't find the string in Configuration, convert the string to lower case then search again.
+ //
+ HiiToLower (StringPtr);
+ ReturnString = StrStr (Configuration, StringPtr);
+ }
+
+ FreePool (StringPtr);
+
+ return ReturnString;
+}
+
+/**
Update the terminal content in TerminalMenu.
@param BmmData The BMM fake NV data.
**/
@@ -693,11 +778,12 @@ BootMaintRouteConfig (
BMM_FAKE_NV_DATA *OldBmmData;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
UINT16 Index;
BOOLEAN TerminalAttChange;
- BMM_CALLBACK_DATA *Private;
+ BMM_CALLBACK_DATA *Private;
+ UINTN Offset;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
@@ -728,10 +814,11 @@ BootMaintRouteConfig (
// Get Buffer Storage data from EFI variable
//
BufferSize = sizeof (BMM_FAKE_NV_DATA);
OldBmmData = &Private->BmmOldFakeNVData;
NewBmmData = &Private->BmmFakeNvData;
+ Offset = 0;
//
// Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
//
Status = ConfigRouting->ConfigToBlock (
ConfigRouting,
@@ -749,10 +836,14 @@ BootMaintRouteConfig (
//
// Check data which located in BMM main page and save the settings if need
//
if (CompareMem (&NewBmmData->BootNext, &OldBmmData->BootNext, sizeof (NewBmmData->BootNext)) != 0) {
Status = Var_UpdateBootNext (Private);
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootNext);
+ goto Exit;
+ }
}
//
// Check data which located in Boot Options Menu and save the settings if need
//
@@ -765,15 +856,23 @@ BootMaintRouteConfig (
NewLoadContext->Deleted = NewBmmData->BootOptionDel[Index];
NewBmmData->BootOptionDel[Index] = FALSE;
NewBmmData->BootOptionDelMark[Index] = FALSE;
}
- Var_DelBootOption ();
+ Status = Var_DelBootOption ();
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionDel);
+ goto Exit;
+ }
}
if (CompareMem (NewBmmData->BootOptionOrder, OldBmmData->BootOptionOrder, sizeof (NewBmmData->BootOptionOrder)) != 0) {
Status = Var_UpdateBootOrder (Private);
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionOrder);
+ goto Exit;
+ }
}
if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, sizeof (NewBmmData->BootTimeOut)) != 0){
Status = gRT->SetVariable(
L"Timeout",
@@ -781,19 +880,12 @@ BootMaintRouteConfig (
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof(UINT16),
&(NewBmmData->BootTimeOut)
);
if (EFI_ERROR (Status)) {
- //
- // If set variable fail, and don't have the appropriate error status for RouteConfig fuction to return,
- // just return the EFI_NOT_FOUND.
- //
- if (Status == EFI_OUT_OF_RESOURCES) {
- return Status;
- } else {
- return EFI_NOT_FOUND;
- }
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootTimeOut);
+ goto Exit;
}
Private->BmmOldFakeNVData.BootTimeOut = NewBmmData->BootTimeOut;
}
//
@@ -807,19 +899,31 @@ BootMaintRouteConfig (
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
NewLoadContext->Deleted = NewBmmData->DriverOptionDel[Index];
NewBmmData->DriverOptionDel[Index] = FALSE;
NewBmmData->DriverOptionDelMark[Index] = FALSE;
}
- Var_DelDriverOption ();
+ Status = Var_DelDriverOption ();
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionDel);
+ goto Exit;
+ }
}
if (CompareMem (NewBmmData->DriverOptionOrder, OldBmmData->DriverOptionOrder, sizeof (NewBmmData->DriverOptionOrder)) != 0) {
Status = Var_UpdateDriverOrder (Private);
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionOrder);
+ goto Exit;
+ }
}
if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOutMode, sizeof (NewBmmData->ConsoleOutMode)) != 0){
- Var_UpdateConMode(Private);
+ Status = Var_UpdateConMode(Private);
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutMode);
+ goto Exit;
+ }
}
TerminalAttChange = FALSE;
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
@@ -836,35 +940,74 @@ BootMaintRouteConfig (
}
TerminalAttChange = TRUE;
}
if (TerminalAttChange) {
- Var_UpdateConsoleInpOption ();
- Var_UpdateConsoleOutOption ();
- Var_UpdateErrorOutOption ();
+ if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBaudRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMBaudRate);
+ } else if (CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmData->COMDataRate[Index], sizeof (NewBmmData->COMDataRate[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMDataRate);
+ } else if (CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmData->COMStopBits[Index], sizeof (NewBmmData->COMStopBits[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMStopBits);
+ } else if (CompareMem (&NewBmmData->COMParity[Index], &OldBmmData->COMParity[Index], sizeof (NewBmmData->COMParity[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMParity);
+ } else if (CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMTerminalType);
+ } else if (CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMFlowControl);
+ }
+ Status = Var_UpdateConsoleInpOption ();
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ Status = Var_UpdateConsoleOutOption ();
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ Status = Var_UpdateErrorOutOption ();
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
}
//
// Check data which located in Console Options Menu and save the settings if need
//
if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck, sizeof (NewBmmData->ConsoleInCheck)) != 0){
- Var_UpdateConsoleInpOption();
+ Status = Var_UpdateConsoleInpOption();
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleInCheck);
+ goto Exit;
+ }
}
if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutCheck, sizeof (NewBmmData->ConsoleOutCheck)) != 0){
- Var_UpdateConsoleOutOption();
+ Status = Var_UpdateConsoleOutOption();
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutCheck);
+ goto Exit;
+ }
}
if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrCheck, sizeof (NewBmmData->ConsoleErrCheck)) != 0){
- Var_UpdateErrorOutOption();
+ Status = Var_UpdateErrorOutOption();
+ if (EFI_ERROR (Status)) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleErrCheck);
+ goto Exit;
+ }
}
if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0 ||
CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptionalData, sizeof (NewBmmData->BootOptionalData)) != 0) {
Status = Var_UpdateBootOption (Private);
NewBmmData->BootOptionChanged = FALSE;
if (EFI_ERROR (Status)) {
- return Status;
+ if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootDescriptionData);
+ } else {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionalData);
+ }
+ goto Exit;
}
BOpt_GetBootOptions (Private);
}
if (CompareMem (NewBmmData->DriverDescriptionData, OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptionData)) != 0 ||
@@ -877,11 +1020,16 @@ BootMaintRouteConfig (
NewBmmData->ForceReconnect
);
NewBmmData->DriverOptionChanged = FALSE;
NewBmmData->ForceReconnect = TRUE;
if (EFI_ERROR (Status)) {
- return Status;
+ if (CompareMem (NewBmmData->DriverDescriptionData, OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptionData)) != 0) {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverDescriptionData);
+ } else {
+ Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionalData);
+ }
+ goto Exit;
}
BOpt_GetDriverOptions (Private);
}
@@ -889,10 +1037,21 @@ BootMaintRouteConfig (
// After user do the save action, need to update OldBmmData.
//
CopyMem (OldBmmData, NewBmmData, sizeof (BMM_FAKE_NV_DATA));
return EFI_SUCCESS;
+
+Exit:
+ //
+ // Fail to save the data, update the progress string.
+ //
+ *Progress = UpdateProgress (Offset, Configuration);
+ if (Status == EFI_OUT_OF_RESOURCES) {
+ return Status;
+ } else {
+ return EFI_NOT_FOUND;
+ }
}
/**
This function processes the results of changes in configuration.
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
index b65d6a5..a2ae2a7 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
@@ -463,11 +463,13 @@ Var_UpdateErrorOutOption (
@param HiiHandle The HII handle associated with the BMM formset.
@param DescriptionData The description of this driver option.
@param OptionalData The optional load option.
@param ForceReconnect If to force reconnect.
- @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
+ @retval other Contain some errors when excuting this function.See function
+ EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl
+ for detail return information.
@retval EFI_SUCCESS If function completes successfully.
**/
EFI_STATUS
Var_UpdateDriverOption (
@@ -523,12 +525,18 @@ Var_UpdateDriverOption (
DescriptionData,
CallbackData->LoadContext->FilePathList,
OptionalDesData,
OptionalDataSize
);
- if (!EFI_ERROR (Status)){
- Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ if (EFI_ERROR (Status)){
+ return Status;
+ }
+
+ Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ if (EFI_ERROR (Status)) {
+ EfiBootManagerFreeLoadOption(&LoadOption);
+ return Status;
}
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
NewLoadContext->Deleted = FALSE;
NewLoadContext->Attributes = LoadOption.Attributes;
@@ -580,11 +588,13 @@ Var_UpdateDriverOption (
the "BootOrder" list. It also append this Boot Opotion to the end
of BootOptionMenu.
@param CallbackData The BMM context data.
- @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
+ @retval other Contain some errors when excuting this function. See function
+ EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl
+ for detail return information.
@retval EFI_SUCCESS If function completes successfully.
**/
EFI_STATUS
Var_UpdateBootOption (
@@ -633,12 +643,18 @@ Var_UpdateBootOption (
NvRamMap->BootDescriptionData,
CallbackData->LoadContext->FilePathList,
OptionalData,
OptionalDataSize
);
- if (!EFI_ERROR (Status)){
- Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ if (EFI_ERROR (Status)){
+ return Status;
+ }
+
+ Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ if (EFI_ERROR (Status)) {
+ EfiBootManagerFreeLoadOption(&LoadOption);
+ return Status;
}
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
NewLoadContext->Deleted = FALSE;
NewLoadContext->Attributes = LoadOption.Attributes;
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-17 8:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17 8:51 [patch 1/5] MdeModulePkg/BMMUI: Update TerminalMenu and ConsoleMenu in callback Dandan Bi
2016-10-17 8:51 ` [patch 2/5] MdeModulePkg/BMMUI: Remove the incorrect and useless codes Dandan Bi
2016-10-17 8:51 ` [patch 3/5] MdeModulePkg/BMMUI: Make the BmmFakeNvData and BmmOldFakeNVData consistent Dandan Bi
2016-10-17 8:51 ` [patch 4/5] MdeModulePkg/BMMUI: Show "Change Boot/Driver order" page correctly Dandan Bi
2016-10-17 8:51 ` [patch 5/5] MdeModulePkg/BMMUI: Add error handling codes Dandan Bi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox