From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web08.10900.1648474000230552508 for ; Mon, 28 Mar 2022 06:26:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=IIYDvg1c; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: lin.z.chen@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648474000; x=1680010000; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=39KWfptjjO1RNeHZKPjzIg6tL3k4tHj1tfQno9KTFXM=; b=IIYDvg1cC5Ijfa3BiUnD5ecacH07yNptJnwicF/60qY2IRqaocWBZXct V6l1cCyAd1mzHAz24IGlIcPR8sHHx/41VD3e/GQruE7zuUEGT4GEIROCQ 2bCz2J+Z2PnHTvLBSKqkPZcbrlV0Ubcwc6PLxLzT/g8KuILVzjiNbv3Aj mGGKWW4XD5Y6eFY4TrC/UAzP0pxaXwV3neACd3d2OG7hnB/nHp67y/KNh 7L5AZxMZUGku8goEjtJwSVPMQOaMF7TP0qLH1ZjoO/5qGulJHIlKWKDz1 aVwsxiOQoBLNe9/kQOolP7Am+IzVeHaxdnIt5zXZigaHi/7GbmENOiGUa A==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="283884069" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="283884069" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 06:26:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="563655392" Received: from shbiosbuild1001.sh.intel.com ([10.239.133.42]) by orsmga008.jf.intel.com with ESMTP; 28 Mar 2022 06:26:36 -0700 From: "Chen Lin Z" To: jian.j.wang@intel.com, gaoliming@byosoft.com.cn, dandan.bi@intel.com, eric.dong@intel.com, devel@edk2.groups.io Cc: zhuangzhi.li@intel.com, di.zhang@intel.com, Chen Lin Z Subject: [PATCH] Fix Setup numeric default value incorrect issue Date: Mon, 28 Mar 2022 21:26:30 +0800 Message-Id: <949b224dbfc992759531166b24c2e0af8c10e0f0.1648473720.git.lin.z.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Chen Lin Z Signed-off-by: Dandan Bi --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 14 +++++++++++ .../Universal/HiiDatabaseDxe/HiiDatabase.h | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 2f792d2965..8bfa0f4bf1 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -2171,6 +2171,7 @@ ParseIfrData ( UINTN PackageOffset;=0D EFI_IFR_VARSTORE *IfrVarStore;=0D EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;=0D + EFI_IFR_VARSTORE_EFI *IfrEfiVarStoreTmp;=0D EFI_IFR_OP_HEADER *IfrOpHdr;=0D EFI_IFR_ONE_OF *IfrOneOf;=0D EFI_IFR_REF4 *IfrRef;=0D @@ -2187,6 +2188,7 @@ ParseIfrData ( IFR_BLOCK_DATA *BlockData;=0D CHAR16 *VarStoreName;=0D UINTN NameSize;=0D + UINTN NvDefaultStoreSize;=0D UINT16 VarWidth;=0D UINT16 VarDefaultId;=0D BOOLEAN FirstOneOfOption;=0D @@ -2303,6 +2305,14 @@ ParseIfrData ( }=0D =0D AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName= , NameSize);=0D + IfrEfiVarStoreTmp =3D AllocatePool (IfrEfiVarStore->Header.Length = + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name));=0D + if (IfrEfiVarStoreTmp =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto Done;=0D + }=0D +=0D + CopyMem (IfrEfiVarStoreTmp, IfrEfiVarStore, IfrEfiVarStore->Header= .Length);=0D + AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *)&(= IfrEfiVarStoreTmp->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) *= sizeof (CHAR16));=0D =0D if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr= )) {=0D //=0D @@ -2502,9 +2512,13 @@ ParseIfrData ( //=0D // Set default value base on the DefaultId list get from IFR dat= a.=0D //=0D + NvDefaultStoreSize =3D PcdGetSize (PcdNvStoreDefaultValueBuffer)= ;=0D for (LinkData =3D DefaultIdArray->Entry.ForwardLink; LinkData != =3D &DefaultIdArray->Entry; LinkData =3D LinkData->ForwardLink) {=0D DefaultDataPtr =3D BASE_CR (LinkData, IFR_DEFAULT_DATA,= Entry);=0D DefaultData.DefaultId =3D DefaultDataPtr->DefaultId;=0D + if (NvDefaultStoreSize > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_H= EADER)) {=0D + FindQuestionDefaultSetting (DefaultData.DefaultId, IfrEfiVar= StoreTmp, &(IfrOneOf->Question), &DefaultData.Value, VarWidth, QuestionRefe= rBitField);=0D + }=0D InsertDefaultValue (BlockData, &DefaultData);=0D }=0D }=0D diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModul= ePkg/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=0D );=0D =0D +/**=0D + Find question default value from PcdNvStoreDefaultValueBuffer=0D +=0D + @param DefaultId Default store ID=0D + @param EfiVarStore Point to EFI VarStore header=0D + @param IfrQuestionHdr Point to Question header=0D + @param ValueBuffer Point to Buffer includes the found default set= ting=0D + @param Width Width of the default value=0D + @param BitFieldQuestion Whether the Question is stored in Bit field.=0D +=0D + @retval EFI_SUCCESS Question default value is found.=0D + @retval EFI_NOT_FOUND Question default value is not found.=0D +**/=0D +EFI_STATUS=0D +FindQuestionDefaultSetting (=0D + IN UINT16 DefaultId,=0D + IN EFI_IFR_VARSTORE_EFI *EfiVarStore,=0D + IN EFI_IFR_QUESTION_HEADER *IfrQuestionHdr,=0D + OUT VOID *ValueBuffer,=0D + IN UINTN Width,=0D + IN BOOLEAN BitFieldQuestion=0D + );=0D +=0D //=0D // Global variables=0D //=0D --=20 2.25.1