From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.3079.1649307889191969304 for ; Wed, 06 Apr 2022 22:04:49 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([101.224.116.119]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Thu, 07 Apr 2022 13:04:44 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 101.224.116.119 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Chen Lin Z'" , , , , Cc: , References: <20220401060905.841569-1-lin.z.chen@intel.com> In-Reply-To: <20220401060905.841569-1-lin.z.chen@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0gtVjJdIEZpeCBTZXR1cCBudW1lcmljIGRlZmF1bHQgdmFsdWUgaW5jb3JyZWN0IGlzc3Vl?= Date: Thu, 7 Apr 2022 13:04:45 +0800 Message-ID: <02d601d84a3c$fffe78f0$fffb6ad0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQCrk5x5IguJowjuGlp/BcZCaQRoLK89Ur3A Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Reviewed-by: Liming Gao > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Chen Lin Z > =B7=A2=CB=CD=CA=B1=BC=E4: 2022=C4=EA4=D4=C21=C8=D5 14:09 > =CA=D5=BC=FE=C8=CB: jian.j.wang@intel.com; gaoliming@byosoft.com.cn; > dandan.bi@intel.com; eric.dong@intel.com; devel@edk2.groups.io > =B3=AD=CB=CD: zhuangzhi.li@intel.com; di.zhang@intel.com; Chen Lin Z > > =D6=F7=CC=E2: [PATCH-V2] Fix Setup numeric default value incorrect = issue >=20 > When default/manufacturing flag get removed from numeric varid, it = can't > get default value from StructurePcd in = 'UpdateDefaultSettingInFormPackage' > function since there is no EFI_IFR_DEFAULT_OP opcode in IFR file. Add = a > chance to get numeric default value from StructurePcd in the case that > numeric minimum value will be used as default value. >=20 > Signed-off-by: Chen Lin Z > Signed-off-by: Dandan Bi > --- > .../Universal/HiiDatabaseDxe/ConfigRouting.c | 22 ++++++++++++++++++ > .../Universal/HiiDatabaseDxe/HiiDatabase.h | 23 > +++++++++++++++++++ > 2 files changed, 45 insertions(+) >=20 > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > index 2f792d2965..1c6af853b3 100644 > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c > @@ -2171,6 +2171,7 @@ ParseIfrData ( > UINTN PackageOffset; >=20 > EFI_IFR_VARSTORE *IfrVarStore; >=20 > EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; >=20 > + EFI_IFR_VARSTORE_EFI *IfrEfiVarStoreTmp; >=20 > EFI_IFR_OP_HEADER *IfrOpHdr; >=20 > EFI_IFR_ONE_OF *IfrOneOf; >=20 > EFI_IFR_REF4 *IfrRef; >=20 > @@ -2187,6 +2188,7 @@ ParseIfrData ( > IFR_BLOCK_DATA *BlockData; >=20 > CHAR16 *VarStoreName; >=20 > UINTN NameSize; >=20 > + UINTN NvDefaultStoreSize; >=20 > UINT16 VarWidth; >=20 > UINT16 VarDefaultId; >=20 > BOOLEAN FirstOneOfOption; >=20 > @@ -2212,6 +2214,7 @@ ParseIfrData ( > SmallestDefaultId =3D 0xFFFF; >=20 > FromOtherDefaultOpcode =3D FALSE; >=20 > QuestionReferBitField =3D FALSE; >=20 > + IfrEfiVarStoreTmp =3D NULL; >=20 >=20 >=20 > // >=20 > // Go through the form package to parse OpCode one by one. >=20 > @@ -2303,6 +2306,17 @@ ParseIfrData ( > } >=20 >=20 >=20 > AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, > VarStoreName, NameSize); >=20 > + if (IfrEfiVarStoreTmp !=3D NULL) { >=20 > + FreePool (IfrEfiVarStoreTmp); >=20 > + } >=20 > + IfrEfiVarStoreTmp =3D AllocatePool = (IfrEfiVarStore->Header.Length + > AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name)); >=20 > + if (IfrEfiVarStoreTmp =3D=3D NULL) { >=20 > + Status =3D EFI_OUT_OF_RESOURCES; >=20 > + goto Done; >=20 > + } >=20 > + >=20 > + CopyMem (IfrEfiVarStoreTmp, IfrEfiVarStore, > IfrEfiVarStore->Header.Length); >=20 > + AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 > *)&(IfrEfiVarStoreTmp->Name[0]), AsciiStrSize ((CHAR8 > *)IfrEfiVarStore->Name) * sizeof (CHAR16)); >=20 >=20 >=20 > if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, > ConfigHdr)) { >=20 > // >=20 > @@ -2502,9 +2516,13 @@ ParseIfrData ( > // >=20 > // Set default value base on the DefaultId list get from = IFR data. >=20 > // >=20 > + NvDefaultStoreSize =3D PcdGetSize > (PcdNvStoreDefaultValueBuffer); >=20 > for (LinkData =3D DefaultIdArray->Entry.ForwardLink; = LinkData !=3D > &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) { >=20 > DefaultDataPtr =3D BASE_CR (LinkData, > IFR_DEFAULT_DATA, Entry); >=20 > DefaultData.DefaultId =3D DefaultDataPtr->DefaultId; >=20 > + if (NvDefaultStoreSize > sizeof > (PCD_NV_STORE_DEFAULT_BUFFER_HEADER)) { >=20 > + FindQuestionDefaultSetting (DefaultData.DefaultId, > IfrEfiVarStoreTmp, &(IfrOneOf->Question), &DefaultData.Value, = VarWidth, > QuestionReferBitField); >=20 > + } >=20 > InsertDefaultValue (BlockData, &DefaultData); >=20 > } >=20 > } >=20 > @@ -3192,6 +3210,10 @@ Done: > } >=20 > } >=20 >=20 >=20 > + if (IfrEfiVarStoreTmp !=3D NULL) { >=20 > + FreePool (IfrEfiVarStoreTmp); >=20 > + } >=20 > + >=20 > return Status; >=20 > } >=20 >=20 >=20 > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > index c4ca6ad6ee..421c293cfc 100644 > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h > @@ -2308,6 +2308,29 @@ HiiGetConfigRespInfo ( > IN CONST EFI_HII_DATABASE_PROTOCOL *This >=20 > ); >=20 >=20 >=20 > +/** >=20 > + Find question default value from PcdNvStoreDefaultValueBuffer >=20 > + >=20 > + @param DefaultId Default store ID >=20 > + @param EfiVarStore Point to EFI VarStore header >=20 > + @param IfrQuestionHdr Point to Question header >=20 > + @param ValueBuffer Point to Buffer includes the found = default > setting >=20 > + @param Width Width of the default value >=20 > + @param BitFieldQuestion Whether the Question is stored in Bit = field. >=20 > + >=20 > + @retval EFI_SUCCESS Question default value is found. >=20 > + @retval EFI_NOT_FOUND Question default value is not found. >=20 > +**/ >=20 > +EFI_STATUS >=20 > +FindQuestionDefaultSetting ( >=20 > + IN UINT16 DefaultId, >=20 > + IN EFI_IFR_VARSTORE_EFI *EfiVarStore, >=20 > + IN EFI_IFR_QUESTION_HEADER *IfrQuestionHdr, >=20 > + OUT VOID *ValueBuffer, >=20 > + IN UINTN Width, >=20 > + IN BOOLEAN BitFieldQuestion >=20 > + ); >=20 > + >=20 > // >=20 > // Global variables >=20 > // >=20 > -- > 2.25.1