From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B312B1A1E4F for ; Tue, 18 Oct 2016 18:36:17 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 18 Oct 2016 18:36:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,364,1473145200"; d="scan'208";a="891442478" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 18 Oct 2016 18:36:18 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 18 Oct 2016 18:36:17 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 18 Oct 2016 18:36:16 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.139]) with mapi id 14.03.0248.002; Wed, 19 Oct 2016 09:36:14 +0800 From: "Dong, Eric" To: "Bi, Dandan" , Laszlo Ersek , "edk2-devel@ml01.01.org" CC: "Gao, Liming" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/BootMaintenanceUi: Enhance the codes logic Thread-Index: AQHSJeZtyHGSZg5lL06o52rQbUgRBqCnXKeAgAR9SQCAAyyDIA== Date: Wed, 19 Oct 2016 01:36:13 +0000 Message-ID: References: <1476427423-72636-1-git-send-email-dandan.bi@intel.com> <3C0D5C461C9E904E8F62152F6274C0BB39639B97@shsmsx102.ccr.corp.intel.com> In-Reply-To: <3C0D5C461C9E904E8F62152F6274C0BB39639B97@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/BootMaintenanceUi: Enhance the codes logic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2016 01:36:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: Bi, Dandan > Sent: Monday, October 17, 2016 5:08 PM > To: Laszlo Ersek; edk2-devel@ml01.01.org > Cc: Dong, Eric; Gao, Liming > Subject: RE: [edk2] [PATCH v2] MdeModulePkg/BootMaintenanceUi: Enhance th= e codes logic >=20 > Hi Laszlo, >=20 > Thank you very much for your comments! > I have split this patch into 5 independent patches with following subject= : > [patch 1/5] MdeModulePkg/BMMUI: ... > [patch 2/5] MdeModulePkg/BMMUI: ... > [patch 3/5] MdeModulePkg/BMMUI: ... > [patch 4/5] MdeModulePkg/BMMUI: ... > [patch 5/5] MdeModulePkg/BMMUI: ... >=20 > Hi Liming/Eric > Please review the new patches and ignore this one. Sorry for any inconv= enience. >=20 >=20 > Regards, > Dandan >=20 > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Friday, October 14, 2016 8:34 PM > To: Bi, Dandan ; edk2-devel@ml01.01.org > Cc: Dong, Eric ; Gao, Liming > Subject: Re: [edk2] [PATCH v2] MdeModulePkg/BootMaintenanceUi: Enhance th= e codes logic >=20 > On 10/14/16 08:43, Dandan Bi wrote: > > This patch is mainly to: > > 1. Enhance the error handling codes when set variable fail. > > 2. Enhance the logic to fix some incorrect UI behaviors. >=20 > My apologies, but both the subject line and the commit message are mostly= impenetrable. >=20 > This patch should be split up into a series of two patches, minimally (ac= cording to the two goals above that it implements), and each > change should be described correctly in both the subject line and in the = commit message. >=20 > If I got a bug report for OVMF that I managed to bisect back to this patc= h, I'd be *completely* helpless figuring out what it does. >=20 > What kind of variables are set by the code? What happens now if setting t= hose variables fails? What is the expected behavior instead that > the > (first) patch implements? >=20 > What are those incorrect UI behaviors? When do they happen? What does the= second patch do to address those issues? >=20 > Dear Developers, please *stop* writing subject lines like >=20 > "Enhance the code in DNS driver" > "Enhance the codes logic" >=20 > those subject lines are *completely* useless. You could replace all those= subject lines, without any loss of information, with the following > one: >=20 > "Do Work" >=20 > Please spend time thinking about the granularity, the focus of your patch= es, as a *standalone activity* during development. Ask yourselves, > "Is this patch small enough? Am I doing two or more independent things he= re? Is the subject line clear enough? If a person sees the code > for the first time, will my commit message help them?" >=20 > You don't write the commit message for yourselves only, you write it for = other developers who might have absolutely no clue what's going > on in your module. >=20 > Thanks > Laszlo >=20 > > V2: Update the Console/Terminal menu when the related question changed. > > > > Cc: Liming Gao > > Cc: Eric Dong > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Dandan Bi > > --- > > .../BootMaintenanceManagerUiLib/BootMaintenance.c | 390 +++++++++++++= +++----- > > .../BootMaintenanceManagerUiLib/UpdatePage.c | 42 ++- > > .../Library/BootMaintenanceManagerUiLib/Variable.c | 28 +- > > 3 files changed, 357 insertions(+), 103 deletions(-) > > > > diff --git > > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c > > b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c > > index a190596..924eb49 100644 > > --- > > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c > > +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance > > +++ .c > > @@ -442,10 +442,197 @@ BmmExtractDevicePathFromHiiHandle ( > > return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), > > FALSE, FALSE); > > > > } > > > > /** > > + Converts the unicode character of the string from uppercase to lower= case. > > + This is a internal function. > > + > > + @param ConfigString String to be converted > > + > > +**/ > > +VOID > > +HiiToLower ( > > + IN EFI_STRING ConfigString > > + ) > > +{ > > + EFI_STRING String; > > + BOOLEAN Lower; > > + > > + ASSERT (ConfigString !=3D NULL); > > + > > + // > > + // Convert all hex digits in range [A-F] in the configuration > > +header to [a-f] > > + // > > + for (String =3D ConfigString, Lower =3D FALSE; *String !=3D L'\0'; S= tring++) { > > + if (*String =3D=3D L'=3D') { > > + Lower =3D TRUE; > > + } else if (*String =3D=3D L'&') { > > + Lower =3D FALSE; > > + } else if (Lower && *String >=3D L'A' && *String <=3D L'F') { > > + *String =3D (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 =3D NULL; > > + ReturnString =3D NULL; > > + > > + // > > + // &OFFSET=3DXXXX followed by a Null-terminator. > > + // Length =3D StrLen (L"&OFFSET=3D") + 4 + 1 // > > + Length =3D StrLen (L"&OFFSET=3D") + 4 + 1; > > + > > + StringPtr =3D AllocateZeroPool (Length * sizeof (CHAR16)); > > + > > + if (StringPtr =3D=3D NULL) { > > + return NULL; > > + } > > + > > + UnicodeSPrint ( > > + StringPtr, > > + (8 + 4 + 1) * sizeof (CHAR16), > > + L"&OFFSET=3D%04x", > > + Offset > > + ); > > + > > + ReturnString =3D StrStr (Configuration, StringPtr); > > + > > + if (ReturnString =3D=3D NULL) { > > + // > > + // If doesn't find the string in Configuration, convert the string= to lower case then search again. > > + // > > + HiiToLower (StringPtr); > > + ReturnString =3D StrStr (Configuration, StringPtr); } > > + > > + FreePool (StringPtr); > > + > > + return ReturnString; > > +} > > + > > +/** > > + 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 =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > + NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu, Index); > > + ASSERT (NewMenuEntry !=3D NULL); > > + NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEntry->Varia= bleContext; > > + NewTerminalContext->BaudRateIndex =3D BmmData->COMBaudRate[Index]; > > + ASSERT (BmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / siz= eof (BaudRateList[0]))); > > + NewTerminalContext->BaudRate =3D BaudRateList[BmmData->COMBau= dRate[Index]].Value; > > + NewTerminalContext->DataBitsIndex =3D BmmData->COMDataRate[Index]; > > + ASSERT (BmmData->COMDataRate[Index] < (sizeof (DataBitsList) / siz= eof (DataBitsList[0]))); > > + NewTerminalContext->DataBits =3D (UINT8) DataBitsList[BmmData= ->COMDataRate[Index]].Value; > > + NewTerminalContext->StopBitsIndex =3D BmmData->COMStopBits[Index]; > > + ASSERT (BmmData->COMStopBits[Index] < (sizeof (StopBitsList) / siz= eof (StopBitsList[0]))); > > + NewTerminalContext->StopBits =3D (UINT8) StopBitsList[BmmData= ->COMStopBits[Index]].Value; > > + NewTerminalContext->ParityIndex =3D BmmData->COMParity[Index]; > > + ASSERT (BmmData->COMParity[Index] < (sizeof (ParityList) / sizeof = (ParityList[0]))); > > + NewTerminalContext->Parity =3D (UINT8) ParityList[BmmData->= COMParity[Index]].Value; > > + NewTerminalContext->TerminalType =3D BmmData->COMTerminalType[Ind= ex]; > > + NewTerminalContext->FlowControl =3D BmmData->COMFlowControl[Inde= x]; > > + 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") =3D=3D 0) { > > + for (Index =3D 0; Index < ConsoleInpMenu.MenuNumber; Index++){ > > + NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleInpMen= u, Index); > > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > + ASSERT (Index < MAX_MENU_NUMBER); > > + NewConsoleContext->IsActive =3D BmmData->ConsoleInCheck[Index]; > > + } > > + for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > + NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > + NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > + ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER); > > + NewTerminalContext->IsConIn =3D BmmData->ConsoleInCheck[Index + = ConsoleInpMenu.MenuNumber]; > > + } > > + } > > + > > + if (StrCmp (ConsoleName, L"ConOut") =3D=3D 0) { > > + for (Index =3D 0; Index < ConsoleOutMenu.MenuNumber; Index++){ > > + NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleOutMen= u, Index); > > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > + ASSERT (Index < MAX_MENU_NUMBER); > > + NewConsoleContext->IsActive =3D BmmData->ConsoleOutCheck[Index]; > > + } > > + for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > + NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > + NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > + ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER); > > + NewTerminalContext->IsConOut =3D BmmData->ConsoleOutCheck[Index = + ConsoleOutMenu.MenuNumber]; > > + } > > + } > > + if (StrCmp (ConsoleName, L"ErrOut") =3D=3D 0) { > > + for (Index =3D 0; Index < ConsoleErrMenu.MenuNumber; Index++){ > > + NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleErrMen= u, Index); > > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > + ASSERT (Index < MAX_MENU_NUMBER); > > + NewConsoleContext->IsActive =3D BmmData->ConsoleErrCheck[Index]; > > + } > > + for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > + NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > + NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > + ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER); > > + NewTerminalContext->IsStdErr =3D BmmData->ConsoleErrCheck[Index = + ConsoleErrMenu.MenuNumber]; > > + } > > + } > > +} > > + > > +/** > > This function allows a caller to extract the current configuration f= or 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 format. > > @@ -587,17 +774,16 @@ 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; > > + BMM_CALLBACK_DATA *Private; > > + UINTN Offset; > > > > if (Progress =3D=3D NULL) { > > return EFI_INVALID_PARAMETER; > > } > > *Progress =3D Configuration; > > @@ -628,10 +814,11 @@ BootMaintRouteConfig ( > > // Get Buffer Storage data from EFI variable > > // > > BufferSize =3D sizeof (BMM_FAKE_NV_DATA); > > OldBmmData =3D &Private->BmmOldFakeNVData; > > NewBmmData =3D &Private->BmmFakeNvData; > > + Offset =3D 0; > > // > > // Convert to buffer data by helper function ConfigToBl= ock() > > // > > Status =3D ConfigRouting->ConfigToBlock ( > > ConfigRouting, @@ -649,10 +836,14 @@ > > BootMaintRouteConfig ( > > // > > // Check data which located in BMM main page and save the settings i= f need > > // > > if (CompareMem (&NewBmmData->BootNext, &OldBmmData->BootNext, sizeof= (NewBmmData->BootNext)) !=3D 0) { > > Status =3D Var_UpdateBootNext (Private); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootNext); > > + goto Exit; > > + } > > } > > > > // > > // Check data which located in Boot Options Menu and save the settin= gs if need > > // > > @@ -665,15 +856,23 @@ BootMaintRouteConfig ( > > NewLoadContext->Deleted =3D NewBmmData->BootOptionDel[Index]; > > NewBmmData->BootOptionDel[Index] =3D FALSE; > > NewBmmData->BootOptionDelMark[Index] =3D FALSE; > > } > > > > - Var_DelBootOption (); > > + Status =3D Var_DelBootOption (); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionDel); > > + goto Exit; > > + } > > } > > > > if (CompareMem (NewBmmData->BootOptionOrder, OldBmmData->BootOptionO= rder, sizeof (NewBmmData->BootOptionOrder)) !=3D > 0) { > > Status =3D Var_UpdateBootOrder (Private); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionOrder); > > + goto Exit; > > + } > > } > > > > if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, = sizeof (NewBmmData->BootTimeOut)) !=3D 0){ > > Status =3D gRT->SetVariable( > > L"Timeout", > > @@ -681,19 +880,12 @@ BootMaintRouteConfig ( > > EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUN= TIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, > > sizeof(UINT16), > > &(NewBmmData->BootTimeOut) > > ); > > if (EFI_ERROR (Status)) { > > - // > > - // If set variable fail, and don't have the appropriate error st= atus for RouteConfig fuction to return, > > - // just return the EFI_NOT_FOUND. > > - // > > - if (Status =3D=3D EFI_OUT_OF_RESOURCES) { > > - return Status; > > - } else { > > - return EFI_NOT_FOUND; > > - } > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootTimeOut); > > + goto Exit; > > } > > Private->BmmOldFakeNVData.BootTimeOut =3D NewBmmData->BootTimeOut; > > } > > > > // > > @@ -707,19 +899,31 @@ BootMaintRouteConfig ( > > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry->Va= riableContext; > > NewLoadContext->Deleted =3D NewBmmData->DriverOptionDel[Index]; > > NewBmmData->DriverOptionDel[Index] =3D FALSE; > > NewBmmData->DriverOptionDelMark[Index] =3D FALSE; > > } > > - Var_DelDriverOption (); > > + Status =3D Var_DelDriverOption (); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionDel); > > + goto Exit; > > + } > > } > > > > if (CompareMem (NewBmmData->DriverOptionOrder, OldBmmData->DriverOpt= ionOrder, sizeof (NewBmmData- > >DriverOptionOrder)) !=3D 0) { > > Status =3D Var_UpdateDriverOrder (Private); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionOrder); > > + goto Exit; > > + } > > } > > > > if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOut= Mode, sizeof (NewBmmData- > >ConsoleOutMode)) !=3D 0){ > > - Var_UpdateConMode(Private); > > + Status =3D Var_UpdateConMode(Private); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutMode); > > + goto Exit; > > + } > > } > > > > TerminalAttChange =3D FALSE; > > for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > > > @@ -733,95 +937,81 @@ BootMaintRouteConfig ( > > CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData-= >COMTerminalType[Index], sizeof (NewBmmData- > >COMTerminalType[Index])) =3D=3D 0 && > > CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->= COMFlowControl[Index], sizeof (NewBmmData- > >COMFlowControl[Index])) =3D=3D 0) { > > continue; > > } > > > > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu, Index); > > - ASSERT (NewMenuEntry !=3D NULL); > > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEntry->Varia= bleContext; > > - NewTerminalContext->BaudRateIndex =3D NewBmmData->COMBaudRate[Inde= x]; > > - ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / = sizeof (BaudRateList[0]))); > > - NewTerminalContext->BaudRate =3D BaudRateList[NewBmmData->COM= BaudRate[Index]].Value; > > - NewTerminalContext->DataBitsIndex =3D NewBmmData->COMDataRate[Inde= x]; > > - ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / = sizeof (DataBitsList[0]))); > > - NewTerminalContext->DataBits =3D (UINT8) DataBitsList[NewBmmD= ata->COMDataRate[Index]].Value; > > - NewTerminalContext->StopBitsIndex =3D NewBmmData->COMStopBits[Inde= x]; > > - ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / = sizeof (StopBitsList[0]))); > > - NewTerminalContext->StopBits =3D (UINT8) StopBitsList[NewBmmD= ata->COMStopBits[Index]].Value; > > - NewTerminalContext->ParityIndex =3D NewBmmData->COMParity[Index]= ; > > - ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / size= of (ParityList[0]))); > > - NewTerminalContext->Parity =3D (UINT8) ParityList[NewBmmDat= a->COMParity[Index]].Value; > > - NewTerminalContext->TerminalType =3D NewBmmData->COMTerminalType[= Index]; > > - NewTerminalContext->FlowControl =3D NewBmmData->COMFlowControl[I= ndex]; > > - ChangeTerminalDevicePath ( > > - NewTerminalContext->DevicePath, > > - FALSE > > - ); > > TerminalAttChange =3D TRUE; > > } > > if (TerminalAttChange) { > > - Var_UpdateConsoleInpOption (); > > - Var_UpdateConsoleOutOption (); > > - Var_UpdateErrorOutOption (); > > + if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMB= audRate[Index], sizeof (NewBmmData- > >COMBaudRate[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMBaudRate); > > + } else if (CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmDat= a->COMDataRate[Index], sizeof (NewBmmData- > >COMDataRate[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMDataRate); > > + } else if (CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmDat= a->COMStopBits[Index], sizeof (NewBmmData- > >COMStopBits[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMStopBits); > > + } else if (CompareMem (&NewBmmData->COMParity[Index], &OldBmmData-= >COMParity[Index], sizeof (NewBmmData- > >COMParity[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMParity); > > + } else if (CompareMem (&NewBmmData->COMTerminalType[Index], &OldBm= mData->COMTerminalType[Index], sizeof > (NewBmmData->COMTerminalType[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMTerminalType); > > + } else if (CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmm= Data->COMFlowControl[Index], sizeof > (NewBmmData->COMFlowControl[Index])) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMFlowControl); > > + } > > + UpdateTerminalContent (NewBmmData); > > + Status =3D Var_UpdateConsoleInpOption (); > > + if (EFI_ERROR (Status)) { > > + goto Exit; > > + } > > + Status =3D Var_UpdateConsoleOutOption (); > > + if (EFI_ERROR (Status)) { > > + goto Exit; > > + } > > + Status =3D Var_UpdateErrorOutOption (); > > + if (EFI_ERROR (Status)) { > > + goto Exit; > > + } > > } > > // > > // Check data which located in Console Options Menu and save the set= tings if need > > // > > if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInChe= ck, sizeof (NewBmmData->ConsoleInCheck)) !=3D 0){ > > - for (Index =3D 0; Index < ConsoleInpMenu.MenuNumber; Index++){ > > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleInpMen= u, Index); > > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > - ASSERT (Index < MAX_MENU_NUMBER); > > - NewConsoleContext->IsActive =3D NewBmmData->ConsoleInCheck[Index= ]; > > - } > > - for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > - ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER); > > - NewTerminalContext->IsConIn =3D NewBmmData->ConsoleInCheck[Index= + ConsoleInpMenu.MenuNumber]; > > + UpdateConsoleContent (L"ConIn", NewBmmData); > > + Status =3D Var_UpdateConsoleInpOption(); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleInCheck); > > + goto Exit; > > } > > - Var_UpdateConsoleInpOption(); > > } > > > > if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutC= heck, sizeof (NewBmmData->ConsoleOutCheck)) !=3D > 0){ > > - for (Index =3D 0; Index < ConsoleOutMenu.MenuNumber; Index++){ > > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleOutMen= u, Index); > > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > - ASSERT (Index < MAX_MENU_NUMBER); > > - NewConsoleContext->IsActive =3D NewBmmData->ConsoleOutCheck[Inde= x]; > > - } > > - for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > - ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER); > > - NewTerminalContext->IsConOut =3D NewBmmData->ConsoleOutCheck[Ind= ex + ConsoleOutMenu.MenuNumber]; > > + UpdateConsoleContent (L"ConOut", NewBmmData); > > + Status =3D Var_UpdateConsoleOutOption(); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutCheck); > > + goto Exit; > > } > > - Var_UpdateConsoleOutOption(); > > } > > > > if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrC= heck, sizeof (NewBmmData->ConsoleErrCheck)) !=3D > 0){ > > - for (Index =3D 0; Index < ConsoleErrMenu.MenuNumber; Index++){ > > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleErrMen= u, Index); > > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEnt= ry->VariableContext; > > - ASSERT (Index < MAX_MENU_NUMBER); > > - NewConsoleContext->IsActive =3D NewBmmData->ConsoleErrCheck[Inde= x]; > > - } > > - for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu= , Index); > > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuE= ntry->VariableContext; > > - ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER); > > - NewTerminalContext->IsStdErr =3D NewBmmData->ConsoleErrCheck[Ind= ex + ConsoleErrMenu.MenuNumber]; > > + UpdateConsoleContent (L"ErrOut", NewBmmData); > > + Status =3D Var_UpdateErrorOutOption(); > > + if (EFI_ERROR (Status)) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleErrCheck); > > + goto Exit; > > } > > - Var_UpdateErrorOutOption(); > > } > > > > if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDes= criptionData, sizeof (NewBmmData- > >BootDescriptionData)) !=3D 0 || > > CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptio= nalData, sizeof (NewBmmData- > >BootOptionalData)) !=3D 0) { > > Status =3D Var_UpdateBootOption (Private); > > NewBmmData->BootOptionChanged =3D FALSE; > > if (EFI_ERROR (Status)) { > > - return Status; > > + if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->Boo= tDescriptionData, sizeof (NewBmmData- > >BootDescriptionData)) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootDescriptionData); > > + } else { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionalData); > > + } > > + goto Exit; > > } > > BOpt_GetBootOptions (Private); > > } > > > > if (CompareMem (NewBmmData->DriverDescriptionData, > > OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptio= nData)) !=3D 0 || @@ -834,11 +1024,16 @@ > BootMaintRouteConfig ( > > NewBmmData->ForceReconnect > > ); > > NewBmmData->DriverOptionChanged =3D FALSE; > > NewBmmData->ForceReconnect =3D TRUE; > > if (EFI_ERROR (Status)) { > > - return Status; > > + if (CompareMem (NewBmmData->DriverDescriptionData, OldBmmData->D= riverDescriptionData, sizeof (NewBmmData- > >DriverDescriptionData)) !=3D 0) { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverDescriptionData)= ; > > + } else { > > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionalData); > > + } > > + goto Exit; > > } > > > > BOpt_GetDriverOptions (Private); > > } > > > > @@ -846,10 +1041,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 =3D UpdateProgress (Offset, Configuration); > > + if (Status =3D=3D EFI_OUT_OF_RESOURCES) { > > + return Status; > > + } else { > > + return EFI_NOT_FOUND; > > + } > > } > > > > /** > > This function processes the results of changes in configuration. > > > > @@ -880,10 +1086,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 !=3D EFI_BROWSER_ACTION_CHANGING && Action !=3D EFI_BROWS= ER_ACTION_CHANGED && Action !=3D > EFI_BROWSER_ACTION_FORM_OPEN) { > > // > > @@ -914,10 +1121,11 @@ BootMaintCallback ( > > } > > // > > // Retrive uncommitted data from Form Browser > > // > > CurrentFakeNVMap =3D &Private->BmmFakeNvData; > > + OldFakeNVMap =3D &Private->BmmOldFakeNVData; > > HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof > > (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap); > > > > if (Action =3D=3D EFI_BROWSER_ACTION_CHANGING) { > > if (Value =3D=3D NULL) { > > return EFI_INVALID_PARAMETER; > > @@ -1016,21 +1224,25 @@ BootMaintCallback ( > > *ActionRequest =3D EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; > > } else if (QuestionId =3D=3D KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) { > > // > > // Discard changes and exit formset > > // > > - CurrentFakeNVMap->DriverOptionalData[0] =3D 0x0000; > > - CurrentFakeNVMap->DriverDescriptionData[0] =3D 0x0000; > > + ZeroMem (CurrentFakeNVMap->DriverOptionalData, sizeof (CurrentFa= keNVMap->DriverOptionalData)); > > + ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentF= akeNVMap->BootDescriptionData)); > > + ZeroMem (OldFakeNVMap->DriverOptionalData, sizeof (OldFakeNVMap-= >DriverOptionalData)); > > + ZeroMem (OldFakeNVMap->DriverDescriptionData, sizeof > > + (OldFakeNVMap->DriverDescriptionData)); > > CurrentFakeNVMap->DriverOptionChanged =3D FALSE; > > CurrentFakeNVMap->ForceReconnect =3D TRUE; > > *ActionRequest =3D EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; > > } else if (QuestionId =3D=3D KEY_VALUE_NO_SAVE_AND_EXIT_BOOT) { > > // > > // Discard changes and exit formset > > // > > - CurrentFakeNVMap->BootOptionalData[0] =3D 0x0000; > > - CurrentFakeNVMap->BootDescriptionData[0] =3D 0x0000; > > + ZeroMem (CurrentFakeNVMap->BootOptionalData, sizeof (CurrentFake= NVMap->BootOptionalData)); > > + ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentF= akeNVMap->BootDescriptionData)); > > + ZeroMem (OldFakeNVMap->BootOptionalData, sizeof (OldFakeNVMap->B= ootOptionalData)); > > + ZeroMem (OldFakeNVMap->BootDescriptionData, sizeof > > + (OldFakeNVMap->BootDescriptionData)); > > CurrentFakeNVMap->BootOptionChanged =3D FALSE; > > *ActionRequest =3D EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; > > } else if (QuestionId =3D=3D KEY_VALUE_BOOT_DESCRIPTION || Questio= nId =3D=3D KEY_VALUE_BOOT_OPTION) { > > CurrentFakeNVMap->BootOptionChanged =3D TRUE; > > } else if (QuestionId =3D=3D KEY_VALUE_DRIVER_DESCRIPTION || > > QuestionId =3D=3D KEY_VALUE_DRIVER_OPTION) { @@ -1074,10 +1286,26 @@ > > BootMaintCallback ( > > > > default: > > break; > > } > > } > > + // > > + // Update the content in Terminal menu and Console menu here. > > + // > > + if ((QuestionId >=3D CON_IN_DEVICE_QUESTION_ID) && (QuestionId < C= ON_IN_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) { > > + UpdateConsoleContent (L"ConIn",CurrentFakeNVMap); > > + UpdateTerminalContent(CurrentFakeNVMap); > > + } else if ((QuestionId >=3D CON_OUT_DEVICE_QUESTION_ID) && (Questi= onId < CON_OUT_DEVICE_QUESTION_ID + > MAX_MENU_NUMBER)) { > > + UpdateConsoleContent (L"ConOut", CurrentFakeNVMap); > > + UpdateTerminalContent(CurrentFakeNVMap); > > + } else if ((QuestionId >=3D CON_ERR_DEVICE_QUESTION_ID) && (Questi= onId < CON_ERR_DEVICE_QUESTION_ID + > MAX_MENU_NUMBER)) { > > + UpdateConsoleContent (L"ConErr", CurrentFakeNVMap); > > + UpdateTerminalContent(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..398c346 100644 > > --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c > > +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c > > @@ -260,10 +260,11 @@ UpdateBootDelPage ( > > // CallbackData->BmmFakeNvData.BootOptionDelMark[Index] =3D FALS= E means BDS knows the selected boot option has > > // deleted, browser maintains old useless info. So clear this in= fo here, and later update this info to browser > > // through HiiSetBrowserData function. > > // > > CallbackData->BmmFakeNvData.BootOptionDel[Index] =3D FALSE; > > + CallbackData->BmmOldFakeNVData.BootOptionDel[Index] =3D FALSE; > > } > > > > HiiCreateCheckBoxOpCode ( > > mStartOpCodeHandle, > > (EFI_QUESTION_ID) (BOOT_OPTION_DEL_QUESTION_ID + Index), @@ > > -346,10 +347,11 @@ UpdateDrvDelPage ( > > // CallbackData->BmmFakeNvData.BootOptionDelMark[Index] =3D FALS= E means BDS knows the selected boot option has > > // deleted, browser maintains old useless info. So clear this in= fo here, and later update this info to browser > > // through HiiSetBrowserData function. > > // > > CallbackData->BmmFakeNvData.DriverOptionDel[Index] =3D FALSE; > > + CallbackData->BmmOldFakeNVData.DriverOptionDel[Index] =3D FALSE; > > } > > HiiCreateCheckBoxOpCode ( > > mStartOpCodeHandle, > > (EFI_QUESTION_ID) (DRIVER_OPTION_DEL_QUESTION_ID + Index), > > VARSTORE_ID_BOOT_MAINT, > > @@ -457,46 +459,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 =3D TRUE; > > > > UpdatePageStart (CallbackData); > > > > ConsoleCheck =3D NULL; > > - OldConsoleCheck =3D NULL; > > QuestionIdBase =3D 0; > > VariableOffsetBase =3D 0; > > - ConsoleCheckSize =3D 0; > > > > switch (UpdatePageId) { > > case FORM_CON_IN_ID: > > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleInCheck= [0]; > > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleInCh= eck[0]; > > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.Console= InCheck); > > QuestionIdBase =3D CON_IN_DEVICE_QUESTION_ID; > > VariableOffsetBase =3D CON_IN_DEVICE_VAR_OFFSET; > > break; > > > > case FORM_CON_OUT_ID: > > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleOutChec= k[0]; > > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleOutC= heck[0]; > > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.Console= OutCheck); > > QuestionIdBase =3D CON_OUT_DEVICE_QUESTION_ID; > > VariableOffsetBase =3D CON_OUT_DEVICE_VAR_OFFSET; > > break; > > > > case FORM_CON_ERR_ID: > > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleErrChec= k[0]; > > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleErrC= heck[0]; > > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.Console= ErrCheck); > > QuestionIdBase =3D CON_ERR_DEVICE_QUESTION_ID; > > VariableOffsetBase =3D CON_ERR_DEVICE_VAR_OFFSET; > > break; > > } > > ASSERT (ConsoleCheck !=3D NULL); > > @@ -517,11 +509,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,20 +538,18 @@ 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++; > > } > > > > - CopyMem (OldConsoleCheck, ConsoleCheck, ConsoleCheckSize); > > - > > UpdatePageEnd (CallbackData); > > } > > > > /** > > Update the page's NV Map if user has changed the order @@ -593,18 > > +583,34 @@ UpdateOrderPage ( > > QuestionId =3D 0; > > VarOffset =3D 0; > > switch (UpdatePageId) { > > > > case FORM_BOOT_CHG_ID: > > - GetBootOrder (CallbackData); > > + // > > + // If the BootOptionOrder in the BmmFakeNvData are same with the d= ate 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 no= t saved in BootOptionMenu, > > + // so we should not get the data from BootOptionMenu to show it. > > + // > > + if (CompareMem (CallbackData->BmmFakeNvData.BootOptionOrder, Callb= ackData->BmmOldFakeNVData.BootOptionOrder, sizeof > (CallbackData->BmmFakeNvData.BootOptionOrder)) =3D=3D 0) { > > + GetBootOrder (CallbackData); > > + } > > OptionOrder =3D CallbackData->BmmFakeNvData.BootOptionOrder; > > QuestionId =3D BOOT_OPTION_ORDER_QUESTION_ID; > > VarOffset =3D 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 no= t saved in DriverOptionMenu, > > + // so we should not get the data from DriverOptionMenu to show it. > > + // > > + if (CompareMem (CallbackData->BmmFakeNvData.DriverOptionOrder, Cal= lbackData->BmmOldFakeNVData.DriverOptionOrder, > sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder)) =3D=3D 0) { > > + GetDriverOrder (CallbackData); > > + } > > OptionOrder =3D CallbackData->BmmFakeNvData.DriverOptionOrder; > > QuestionId =3D DRIVER_OPTION_ORDER_QUESTION_ID; > > VarOffset =3D DRIVER_OPTION_ORDER_VAR_OFFSET; > > break; > > } > > @@ -1035,15 +1041,19 @@ UpdateOptionPage( > > > > if(FormId =3D=3D FORM_BOOT_ADD_ID){ > > if (!CallbackData->BmmFakeNvData.BootOptionChanged) { > > ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (C= allbackData->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 =3D=3D 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, size= of (CallbackData- > >BmmOldFakeNVData.DriverOptionalData)); > > + ZeroMem (CallbackData->BmmOldFakeNVData.DriverDescriptionData, > > + sizeof (CallbackData->BmmOldFakeNVData.DriverDescriptionData)); > > } > > } > > > > RefreshUpdateData(); > > mStartLabel->Number =3D FormId; > > 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 formse= t. > > @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 o= peration. > > + @retval other Contain some errors when excuting this = function.See function > > + EfiBootManagerInitializeLoadOption/EfiB= ootManagerAddLoadOptionVariabl > > + 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 =3D EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN= ) -1 ); > > + if (EFI_ERROR (Status)){ > > + return Status; > > + } > > + > > + Status =3D EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) > > + -1 ); if (EFI_ERROR (Status)) { > > + EfiBootManagerFreeLoadOption(&LoadOption); > > + return Status; > > } > > > > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry= ->VariableContext; > > NewLoadContext->Deleted =3D FALSE; > > NewLoadContext->Attributes =3D 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 o= peration. > > + @retval other Contain some errors when excuting this = function. See function > > + EfiBootManagerInitializeLoadOption/EfiB= ootManagerAddLoadOptionVariabl > > + 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 =3D EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN= ) -1 ); > > + if (EFI_ERROR (Status)){ > > + return Status; > > + } > > + > > + Status =3D EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) > > + -1 ); if (EFI_ERROR (Status)) { > > + EfiBootManagerFreeLoadOption(&LoadOption); > > + return Status; > > } > > > > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry= ->VariableContext; > > NewLoadContext->Deleted =3D FALSE; > > NewLoadContext->Attributes =3D LoadOption.Attributes; > >