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 37AE11A1E10 for ; Mon, 17 Oct 2016 02:07:50 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP; 17 Oct 2016 02:07:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,357,1473145200"; d="scan'208";a="20311707" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 17 Oct 2016 02:07:49 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 17 Oct 2016 02:07:49 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 17 Oct 2016 02:07:48 -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; Mon, 17 Oct 2016 17:07:46 +0800 From: "Bi, Dandan" To: Laszlo Ersek , "edk2-devel@ml01.01.org" CC: "Dong, Eric" , "Gao, Liming" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/BootMaintenanceUi: Enhance the codes logic Thread-Index: AQHSJeZzcRKhCyAIY0ypYA3zee2JAqCnXKeAgAT/TZA= Date: Mon, 17 Oct 2016 09:07:46 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB39639B97@shsmsx102.ccr.corp.intel.com> References: <1476427423-72636-1-git-send-email-dandan.bi@intel.com> In-Reply-To: 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: Mon, 17 Oct 2016 09:07:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Laszlo, Thank you very much for your comments! =20 I have split this patch into 5 independent patches with following subject := =20 [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: ... Hi Liming/Eric Please review the new patches and ignore this one. Sorry for any inconven= ience. Regards, Dandan -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 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 the = codes logic 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. My apologies, but both the subject line and the commit message are mostly i= mpenetrable. This patch should be split up into a series of two patches, minimally (acco= rding 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. If I got a bug report for OVMF that I managed to bisect back to this patch,= I'd be *completely* helpless figuring out what it does. What kind of variables are set by the code? What happens now if setting tho= se variables fails? What is the expected behavior instead that the (first) patch implements? What are those incorrect UI behaviors? When do they happen? What does the s= econd patch do to address those issues? Dear Developers, please *stop* writing subject lines like "Enhance the code in DNS driver" "Enhance the codes logic" those subject lines are *completely* useless. You could replace all those s= ubject lines, without any loss of information, with the following one: "Do Work" Please spend time thinking about the granularity, the focus of your patches= , as a *standalone activity* during development. Ask yourselves, "Is this p= atch small enough? Am I doing two or more independent things here? Is the s= ubject line clear enough? If a person sees the code for the first time, wil= l my commit message help them?" You don't write the commit message for yourselves only, you write it for ot= her developers who might have absolutely no clue what's going on in your mo= dule. Thanks Laszlo > V2: Update the Console/Terminal menu when the related question changed. >=20 > 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(-) >=20 > diff --git=20 > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c=20 > b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c > index a190596..924eb49 100644 > ---=20 > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c > +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance > +++ .c > @@ -442,10 +442,197 @@ BmmExtractDevicePathFromHiiHandle ( > return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle),=20 > FALSE, FALSE); > =20 > } > =20 > /** > + Converts the unicode character of the string from uppercase to lowerca= se. > + 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=20 > +header to [a-f] > + // > + for (String =3D ConfigString, Lower =3D FALSE; *String !=3D L'\0'; Str= ing++) { > + 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 t= o 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->Variabl= eContext; > + NewTerminalContext->BaudRateIndex =3D BmmData->COMBaudRate[Index]; > + ASSERT (BmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeo= f (BaudRateList[0]))); > + NewTerminalContext->BaudRate =3D BaudRateList[BmmData->COMBaudR= ate[Index]].Value; > + NewTerminalContext->DataBitsIndex =3D BmmData->COMDataRate[Index]; > + ASSERT (BmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeo= f (DataBitsList[0]))); > + NewTerminalContext->DataBits =3D (UINT8) DataBitsList[BmmData->= COMDataRate[Index]].Value; > + NewTerminalContext->StopBitsIndex =3D BmmData->COMStopBits[Index]; > + ASSERT (BmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeo= f (StopBitsList[0]))); > + NewTerminalContext->StopBits =3D (UINT8) StopBitsList[BmmData->= COMStopBits[Index]].Value; > + NewTerminalContext->ParityIndex =3D BmmData->COMParity[Index]; > + ASSERT (BmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (P= arityList[0]))); > + NewTerminalContext->Parity =3D (UINT8) ParityList[BmmData->CO= MParity[Index]].Value; > + NewTerminalContext->TerminalType =3D BmmData->COMTerminalType[Index= ]; > + NewTerminalContext->FlowControl =3D 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") =3D=3D 0) { > + for (Index =3D 0; Index < ConsoleInpMenu.MenuNumber; Index++){ > + NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleInpMenu,= Index); > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->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 *) NewMenuEnt= ry->VariableContext; > + ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER); > + NewTerminalContext->IsConIn =3D BmmData->ConsoleInCheck[Index + Co= nsoleInpMenu.MenuNumber]; > + } > + } > + > + if (StrCmp (ConsoleName, L"ConOut") =3D=3D 0) { > + for (Index =3D 0; Index < ConsoleOutMenu.MenuNumber; Index++){ > + NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleOutMenu,= Index); > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->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 *) NewMenuEnt= ry->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(&ConsoleErrMenu,= Index); > + NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->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 *) NewMenuEnt= ry->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 for= one > or more named elements from the target driver. > =20 > @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;=20 > + BMM_CALLBACK_DATA *Private; > + UINTN Offset; > =20 > 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 ConfigToBloc= k() > // > Status =3D ConfigRouting->ConfigToBlock ( > ConfigRouting, @@ -649,10 +836,14 @@=20 > BootMaintRouteConfig ( > // > // Check data which located in BMM main page and save the settings if = need > // =20 > 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; > + } > } > =20 > // > // Check data which located in Boot Options Menu and save the settings= if need > // =20 > @@ -665,15 +856,23 @@ BootMaintRouteConfig ( > NewLoadContext->Deleted =3D NewBmmData->BootOptionDel[Index]; > NewBmmData->BootOptionDel[Index] =3D FALSE; > NewBmmData->BootOptionDelMark[Index] =3D FALSE; > } > =20 > - Var_DelBootOption (); > + Status =3D Var_DelBootOption (); > + if (EFI_ERROR (Status)) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionDel); > + goto Exit; > + } > } > =20 > if (CompareMem (NewBmmData->BootOptionOrder, OldBmmData->BootOptionOrd= er, 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; > + } > } > =20 > if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, si= zeof (NewBmmData->BootTimeOut)) !=3D 0){ > Status =3D gRT->SetVariable( > L"Timeout", > @@ -681,19 +880,12 @@ BootMaintRouteConfig ( > EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTI= ME_ACCESS | EFI_VARIABLE_NON_VOLATILE, > sizeof(UINT16), > &(NewBmmData->BootTimeOut) > ); > if (EFI_ERROR (Status)) { > - // > - // If set variable fail, and don't have the appropriate error stat= us 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; > } > =20 > // > @@ -707,19 +899,31 @@ BootMaintRouteConfig ( > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry->Vari= ableContext; > NewLoadContext->Deleted =3D NewBmmData->DriverOptionDel[Index]; > NewBmmData->DriverOptionDel[Index] =3D FALSE; > NewBmmData->DriverOptionDelMark[Index] =3D FALSE; > } > - Var_DelDriverOption (); =20 > + Status =3D Var_DelDriverOption (); > + if (EFI_ERROR (Status)) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionDel); > + goto Exit; > + } > } > =20 > if (CompareMem (NewBmmData->DriverOptionOrder, OldBmmData->DriverOptio= nOrder, sizeof (NewBmmData->DriverOptionOrder)) !=3D 0) { =20 > Status =3D Var_UpdateDriverOrder (Private); > + if (EFI_ERROR (Status)) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionOrder); > + goto Exit; > + } > } > =20 > if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOutMo= de, 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; > + } > } > =20 > TerminalAttChange =3D FALSE; > for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > =20 > @@ -733,95 +937,81 @@ BootMaintRouteConfig ( > CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->C= OMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) =3D=3D = 0 && > CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->CO= MFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) =3D=3D 0) = { > continue; > } > =20 > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu, Index); > - ASSERT (NewMenuEntry !=3D NULL); > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEntry->Variabl= eContext; > - NewTerminalContext->BaudRateIndex =3D NewBmmData->COMBaudRate[Index]= ; > - ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / si= zeof (BaudRateList[0]))); > - NewTerminalContext->BaudRate =3D BaudRateList[NewBmmData->COMBa= udRate[Index]].Value; > - NewTerminalContext->DataBitsIndex =3D NewBmmData->COMDataRate[Index]= ; > - ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / si= zeof (DataBitsList[0]))); > - NewTerminalContext->DataBits =3D (UINT8) DataBitsList[NewBmmDat= a->COMDataRate[Index]].Value; > - NewTerminalContext->StopBitsIndex =3D NewBmmData->COMStopBits[Index]= ; > - ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / si= zeof (StopBitsList[0]))); > - NewTerminalContext->StopBits =3D (UINT8) StopBitsList[NewBmmDat= a->COMStopBits[Index]].Value; > - NewTerminalContext->ParityIndex =3D NewBmmData->COMParity[Index]; > - ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / sizeof= (ParityList[0]))); > - NewTerminalContext->Parity =3D (UINT8) ParityList[NewBmmData-= >COMParity[Index]].Value; > - NewTerminalContext->TerminalType =3D NewBmmData->COMTerminalType[In= dex]; > - NewTerminalContext->FlowControl =3D NewBmmData->COMFlowControl[Ind= ex]; > - ChangeTerminalDevicePath ( > - NewTerminalContext->DevicePath, > - FALSE > - ); > TerminalAttChange =3D TRUE; > } > if (TerminalAttChange) { > - Var_UpdateConsoleInpOption (); > - Var_UpdateConsoleOutOption (); > - Var_UpdateErrorOutOption (); > + if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBau= dRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) !=3D 0) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMBaudRate); > + } else if (CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmData-= >COMDataRate[Index], sizeof (NewBmmData->COMDataRate[Index])) !=3D 0) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMDataRate); > + } else if (CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmData-= >COMStopBits[Index], sizeof (NewBmmData->COMStopBits[Index])) !=3D 0) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMStopBits); > + } else if (CompareMem (&NewBmmData->COMParity[Index], &OldBmmData->C= OMParity[Index], sizeof (NewBmmData->COMParity[Index])) !=3D 0) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMParity); > + } else if (CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmD= ata->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) != =3D 0) { > + Offset =3D OFFSET_OF (BMM_FAKE_NV_DATA, COMTerminalType); > + } else if (CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmDa= ta->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 setti= ngs if need > // > if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck= , sizeof (NewBmmData->ConsoleInCheck)) !=3D 0){ > - for (Index =3D 0; Index < ConsoleInpMenu.MenuNumber; Index++){ > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleInpMenu,= Index); > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->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 *) NewMenuEnt= ry->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(); > } > =20 > if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutChe= ck, sizeof (NewBmmData->ConsoleOutCheck)) !=3D 0){ > - for (Index =3D 0; Index < ConsoleOutMenu.MenuNumber; Index++){ > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleOutMenu,= Index); > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->VariableContext; > - ASSERT (Index < MAX_MENU_NUMBER); > - NewConsoleContext->IsActive =3D NewBmmData->ConsoleOutCheck[Index]= ; > - } > - for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu, = Index); > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEnt= ry->VariableContext; > - ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER); > - NewTerminalContext->IsConOut =3D NewBmmData->ConsoleOutCheck[Index= + 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(); > } > =20 > if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrChe= ck, sizeof (NewBmmData->ConsoleErrCheck)) !=3D 0){ > - for (Index =3D 0; Index < ConsoleErrMenu.MenuNumber; Index++){ > - NewMenuEntry =3D BOpt_GetMenuEntry(&ConsoleErrMenu,= Index); > - NewConsoleContext =3D (BM_CONSOLE_CONTEXT *)NewMenuEntry= ->VariableContext; > - ASSERT (Index < MAX_MENU_NUMBER); > - NewConsoleContext->IsActive =3D NewBmmData->ConsoleErrCheck[Index]= ; > - } > - for (Index =3D 0; Index < TerminalMenu.MenuNumber; Index++) { > - NewMenuEntry =3D BOpt_GetMenuEntry (&TerminalMenu, = Index); > - NewTerminalContext =3D (BM_TERMINAL_CONTEXT *) NewMenuEnt= ry->VariableContext; > - ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER); > - NewTerminalContext->IsStdErr =3D NewBmmData->ConsoleErrCheck[Index= + 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(); > } > =20 > if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescr= iptionData, sizeof (NewBmmData->BootDescriptionData)) !=3D 0 || > CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptiona= lData, 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->BootD= escriptionData, 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); > } > =20 > if (CompareMem (NewBmmData->DriverDescriptionData,=20 > OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptionD= ata)) !=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->Dri= verDescriptionData, 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; > } > =20 > BOpt_GetDriverOptions (Private); > } > =20 > @@ -846,10 +1041,21 @@ BootMaintRouteConfig ( > // After user do the save action, need to update OldBmmData. > // > CopyMem (OldBmmData, NewBmmData, sizeof (BMM_FAKE_NV_DATA)); > =20 > 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; > + } > } > =20 > /** > This function processes the results of changes in configuration. > =20 > @@ -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; > =20 > if (Action !=3D EFI_BROWSER_ACTION_CHANGING && Action !=3D EFI_BROWSER= _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=20 > (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap); > =20 > 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 (CurrentFake= NVMap->DriverOptionalData)); > + ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentFak= eNVMap->BootDescriptionData)); > + ZeroMem (OldFakeNVMap->DriverOptionalData, sizeof (OldFakeNVMap->D= riverOptionalData)); > + ZeroMem (OldFakeNVMap->DriverDescriptionData, sizeof=20 > + (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 (CurrentFakeNV= Map->BootOptionalData)); > + ZeroMem (CurrentFakeNVMap->BootDescriptionData, sizeof (CurrentFak= eNVMap->BootDescriptionData)); > + ZeroMem (OldFakeNVMap->BootOptionalData, sizeof (OldFakeNVMap->Boo= tOptionalData)); > + ZeroMem (OldFakeNVMap->BootDescriptionData, sizeof=20 > + (OldFakeNVMap->BootDescriptionData)); > CurrentFakeNVMap->BootOptionChanged =3D FALSE; > *ActionRequest =3D EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; > } else if (QuestionId =3D=3D KEY_VALUE_BOOT_DESCRIPTION || QuestionI= d =3D=3D KEY_VALUE_BOOT_OPTION) { > CurrentFakeNVMap->BootOptionChanged =3D TRUE; > } else if (QuestionId =3D=3D KEY_VALUE_DRIVER_DESCRIPTION ||=20 > QuestionId =3D=3D KEY_VALUE_DRIVER_OPTION) { @@ -1074,10 +1286,26 @@=20 > BootMaintCallback ( > =20 > default: > break; > } > } > + // > + // Update the content in Terminal menu and Console menu here. > + // > + if ((QuestionId >=3D CON_IN_DEVICE_QUESTION_ID) && (QuestionId < CON= _IN_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) { > + UpdateConsoleContent (L"ConIn",CurrentFakeNVMap); > + UpdateTerminalContent(CurrentFakeNVMap); > + } else if ((QuestionId >=3D CON_OUT_DEVICE_QUESTION_ID) && (Question= Id < CON_OUT_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) { > + UpdateConsoleContent (L"ConOut", CurrentFakeNVMap); > + UpdateTerminalContent(CurrentFakeNVMap); > + } else if ((QuestionId >=3D CON_ERR_DEVICE_QUESTION_ID) && (Question= Id < CON_ERR_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) { > + UpdateConsoleContent (L"ConErr", CurrentFakeNVMap); > + UpdateTerminalContent(CurrentFakeNVMap); > + } > } > =20 > // > // Pass changed uncommitted data back to Form Browser > // > diff --git=20 > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c=20 > 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 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] =3D FALSE; > + CallbackData->BmmOldFakeNVData.BootOptionDel[Index] =3D FALSE; > } > =20 > HiiCreateCheckBoxOpCode ( > mStartOpCodeHandle, > (EFI_QUESTION_ID) (BOOT_OPTION_DEL_QUESTION_ID + Index), @@=20 > -346,10 +347,11 @@ UpdateDrvDelPage ( > // CallbackData->BmmFakeNvData.BootOptionDelMark[Index] =3D 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] =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; > =20 > CallbackData->BmmAskSaveOrNot =3D TRUE; > =20 > UpdatePageStart (CallbackData); > =20 > ConsoleCheck =3D NULL; > - OldConsoleCheck =3D NULL; > QuestionIdBase =3D 0; > VariableOffsetBase =3D 0; > - ConsoleCheckSize =3D 0; > =20 > switch (UpdatePageId) { > case FORM_CON_IN_ID: > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleInCheck[0= ]; > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleInChec= k[0]; > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.ConsoleIn= Check); > QuestionIdBase =3D CON_IN_DEVICE_QUESTION_ID; > VariableOffsetBase =3D CON_IN_DEVICE_VAR_OFFSET; > break; > =20 > case FORM_CON_OUT_ID: > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleOutCheck[= 0]; > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleOutChe= ck[0]; > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.ConsoleOu= tCheck); > QuestionIdBase =3D CON_OUT_DEVICE_QUESTION_ID; > VariableOffsetBase =3D CON_OUT_DEVICE_VAR_OFFSET; > break; > =20 > case FORM_CON_ERR_ID: > ConsoleCheck =3D &CallbackData->BmmFakeNvData.ConsoleErrCheck[= 0]; > - OldConsoleCheck =3D &CallbackData->BmmOldFakeNVData.ConsoleErrChe= ck[0]; > - ConsoleCheckSize =3D sizeof (CallbackData->BmmFakeNvData.ConsoleEr= rCheck); > 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 > ); > } > =20 > @@ -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 > ); > =20 > Index++; > } > =20 > - CopyMem (OldConsoleCheck, ConsoleCheck, ConsoleCheckSize); > - > UpdatePageEnd (CallbackData); > } > =20 > /** > Update the page's NV Map if user has changed the order @@ -593,18=20 > +583,34 @@ UpdateOrderPage ( > QuestionId =3D 0; > VarOffset =3D 0; > switch (UpdatePageId) { > =20 > case FORM_BOOT_CHG_ID: > - GetBootOrder (CallbackData); > + // > + // If the BootOptionOrder in the BmmFakeNvData are same with the dat= e in the BmmOldFakeNVData, > + // means all Boot Options has been save in BootOptionMenu, we can ge= t 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, Callbac= kData->BmmOldFakeNVData.BootOptionOrder, sizeof (CallbackData->BmmFakeNvDat= a.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; > =20 > case FORM_DRV_CHG_ID: > - GetDriverOrder (CallbackData); > + // > + // If the DriverOptionOrder in the BmmFakeNvData are same with the d= ate in the BmmOldFakeNVData, > + // means all Driver Options has been save in DriverOptionMenu, we ca= n 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, Callb= ackData->BmmOldFakeNVData.DriverOptionOrder, sizeof (CallbackData->BmmFakeN= vData.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( > =20 > if(FormId =3D=3D FORM_BOOT_ADD_ID){ > if (!CallbackData->BmmFakeNvData.BootOptionChanged) { > ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (Cal= lbackData->BmmFakeNvData.BootOptionalData)); > ZeroMem (CallbackData->BmmFakeNvData.BootDescriptionData,=20 > sizeof (CallbackData->BmmFakeNvData.BootDescriptionData)); > + ZeroMem (CallbackData->BmmOldFakeNVData.BootOptionalData, sizeof (= CallbackData->BmmOldFakeNVData.BootOptionalData)); > + ZeroMem (CallbackData->BmmOldFakeNVData.BootDescriptionData,=20 > + sizeof (CallbackData->BmmOldFakeNVData.BootDescriptionData)); > } > } else if (FormId =3D=3D FORM_DRV_ADD_FILE_ID){ > if (!CallbackData->BmmFakeNvData.DriverOptionChanged) { > ZeroMem (CallbackData->BmmFakeNvData.DriverOptionalData, sizeof (C= allbackData->BmmFakeNvData.DriverOptionalData)); > ZeroMem (CallbackData->BmmFakeNvData.DriverDescriptionData,=20 > sizeof (CallbackData->BmmFakeNvData.DriverDescriptionData)); > + ZeroMem (CallbackData->BmmOldFakeNVData.DriverOptionalData, sizeof= (CallbackData->BmmOldFakeNVData.DriverOptionalData)); > + ZeroMem (CallbackData->BmmOldFakeNVData.DriverDescriptionData,=20 > + sizeof (CallbackData->BmmOldFakeNVData.DriverDescriptionData)); > } > } > =20 > RefreshUpdateData(); > mStartLabel->Number =3D FormId; > diff --git=20 > a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c=20 > 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. > =20 > - @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the ope= ration. > + @retval other Contain some errors when excuting this fu= nction.See function > + EfiBootManagerInitializeLoadOption/EfiBoo= tManagerAddLoadOptionVariabl > + for detail return information. > @retval EFI_SUCCESS If function completes successfully. > =20 > **/ > 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)=20 > + -1 ); if (EFI_ERROR (Status)) { > + EfiBootManagerFreeLoadOption(&LoadOption); > + return Status; > } > =20 > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry->= VariableContext; > NewLoadContext->Deleted =3D FALSE; > NewLoadContext->Attributes =3D LoadOption.Attributes; @@ -580,11=20 > +588,13 @@ Var_UpdateDriverOption ( > the "BootOrder" list. It also append this Boot Opotion to the end > of BootOptionMenu. > =20 > @param CallbackData The BMM context data. > =20 > - @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the ope= ration. > + @retval other Contain some errors when excuting this fu= nction. See function > + EfiBootManagerInitializeLoadOption/EfiBoo= tManagerAddLoadOptionVariabl > + for detail return information. > @retval EFI_SUCCESS If function completes successfully. > =20 > **/ > 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)=20 > + -1 ); if (EFI_ERROR (Status)) { > + EfiBootManagerFreeLoadOption(&LoadOption); > + return Status; > } > =20 > NewLoadContext =3D (BM_LOAD_CONTEXT *) NewMenuEntry->= VariableContext; > NewLoadContext->Deleted =3D FALSE; > NewLoadContext->Attributes =3D LoadOption.Attributes; >=20