From nobody Fri Dec 27 20:56:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1496717974877435.13915867992944; Mon, 5 Jun 2017 19:59:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0BDDC21C93EF1; Mon, 5 Jun 2017 19:58:27 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 B4D2221A08D6A for ; Mon, 5 Jun 2017 19:58:25 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2017 19:59:32 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga002.fm.intel.com with ESMTP; 05 Jun 2017 19:59:30 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,304,1493708400"; d="scan'208";a="1178733938" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 6 Jun 2017 10:58:25 +0800 Message-Id: <1496717906-372916-2-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1496717906-372916-1-git-send-email-dandan.bi@intel.com> References: <1496717906-372916-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [RFC v3 1/2] BaseTool/VfrCompile: Support Union type in VFR X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Eric Dong , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" V3: Avoid adding new member in current stucture to indicate indicate whether current date type is Union or not. We can directly paas the data type info to sub-statement/function during parsing phase. Cc: Eric Dong Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 81 +++++++++++++++------= ---- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 17 +++++- BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 4 +- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C= /VfrCompile/VfrSyntax.g index 406dbc5..1dc9477 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -155,10 +155,11 @@ VfrParserStart ( #token Label("label") "label" #token Timeout("timeout") "timeout" #token Inventory("inventory") "inventory" #token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP" #token Struct("struct") "struct" +#token Union("union") "union" #token Boolean("BOOLEAN") "BOOLEAN" #token Uint64("UINT64") "UINT64" #token Uint32("UINT32") "UINT32" #token Uint16("UINT16") "UINT16" #token Char16("CHAR16") "CHAR16" @@ -270,10 +271,11 @@ vfrProgram > [UINT8 Return] : mConstantOnlyInExpression =3D FALSE; >> ( vfrPragmaPackDefinition | vfrDataStructDefinition + | vfrDataUnionDefinition )* vfrFormSetDefinition << $Return =3D mParserStatus; >> ; =20 @@ -318,140 +320,155 @@ vfrPragmaPackDefinition : | pragmaPackNumber } "\)" ; =20 + vfrDataUnionDefinition : + { TypeDef } Union << gCVfrVarDataTypeDB.D= eclareDataTypeBegin (); >> + { NonNvDataMap } + { + N1:StringIdentifier << _PCATCH(gCVfrVarDat= aTypeDB.SetNewTypeName (N1->getText()), N1); >> + } + OpenBrace + vfrDataStructFields[TRUE] + CloseBrace + { + N2:StringIdentifier << _PCATCH(gCVfrVarDat= aTypeDB.SetNewTypeName (N2->getText()), N2); >> + } + ";" << gCVfrVarDataTypeDB.= DeclareDataTypeEnd ();>> + ; + vfrDataStructDefinition : { TypeDef } Struct << gCVfrVarDataTypeDB.= DeclareDataTypeBegin (); >> { NonNvDataMap } { N1:StringIdentifier << _PCATCH(gCVfrVarDat= aTypeDB.SetNewTypeName (N1->getText()), N1); >> } OpenBrace - vfrDataStructFields + vfrDataStructFields[FALSE] CloseBrace { N2:StringIdentifier << _PCATCH(gCVfrVarDat= aTypeDB.SetNewTypeName (N2->getText()), N2); >> } ";" << gCVfrVarDataTypeDB.= DeclareDataTypeEnd (); >> ; =20 -vfrDataStructFields : +vfrDataStructFields [BOOLEAN FieldInUnion]: ( - dataStructField64 | - dataStructField32 | - dataStructField16 | - dataStructField8 | - dataStructFieldBool | - dataStructFieldString | - dataStructFieldDate | - dataStructFieldTime | - dataStructFieldRef | - dataStructFieldUser + dataStructField64 [FieldInUnion] | + dataStructField32 [FieldInUnion] | + dataStructField16 [FieldInUnion] | + dataStructField8 [FieldInUnion] | + dataStructFieldBool [FieldInUnion] | + dataStructFieldString [FieldInUnion]| + dataStructFieldDate [FieldInUnion] | + dataStructFieldTime [FieldInUnion] | + dataStructFieldRef [FieldInUnion] | + dataStructFieldUser [FieldInUnion] )* ; =20 -dataStructField64 : +dataStructField64 [BOOLEAN FieldInUnion] : << UINT32 ArrayNum =3D 0; >> D:"UINT64" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructField32 : +dataStructField32 [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"UINT32" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructField16 : +dataStructField16 [BOOLEAN FieldInUnion]: <<=20 UINT32 ArrayNum =3D 0;=20 >> ("UINT16" | "CHAR16") N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum), N); = >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum, Field= InUnion), N); >> ; =20 -dataStructField8 : +dataStructField8 [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"UINT8" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldBool : +dataStructFieldBool [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"BOOLEAN" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldString : +dataStructFieldString [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"EFI_STRING_ID" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldDate : +dataStructFieldDate [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"EFI_HII_DATE" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldTime : +dataStructFieldTime [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"EFI_HII_TIME" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldRef : +dataStructFieldRef [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> D:"EFI_HII_REF" N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum, FieldInUnio= n), N); >> ; =20 -dataStructFieldUser : +dataStructFieldUser [BOOLEAN FieldInUnion]: << UINT32 ArrayNum =3D 0; >> T:StringIdentifier N:StringIdentifier { OpenBracket I:Number CloseBracket << ArrayNum =3D _STOU3= 2(I->getText(), I->getLine()); >> } - ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >> + ";" << _PCATCH(gCVfrVarDat= aTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum, FieldInUnio= n), T); >> ; =20 //************************************************************************= ***** // // the syntax of GUID definition diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/So= urce/C/VfrCompile/VfrUtilityLib.cpp index 2f97975..37b58e2 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -1,10 +1,10 @@ /** @file =20 Vfr common library functions. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -1011,19 +1011,22 @@ CVfrVarDataTypeDB::SetNewTypeName ( =20 EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::DataTypeAddField ( IN CHAR8 *FieldName, IN CHAR8 *TypeName, - IN UINT32 ArrayNum + IN UINT32 ArrayNum, + IN BOOLEAN FieldInUnion ) { SVfrDataField *pNewField =3D NULL; SVfrDataType *pFieldType =3D NULL; SVfrDataField *pTmp; UINT32 Align; + UINT32 MaxDataTypeSize; =20 CHECK_ERROR_RETURN (GetDataType (TypeName, &pFieldType), VFR_RETURN_SUCC= ESS); + MaxDataTypeSize =3D mNewDataType->mTotalSize; =20 if (strlen (FieldName) >=3D MAX_NAME_LEN) { return VFR_RETURN_INVALID_PARAMETER; } =20 @@ -1055,11 +1058,19 @@ CVfrVarDataTypeDB::DataTypeAddField ( pTmp->mNext =3D pNewField; pNewField->mNext =3D NULL; } =20 mNewDataType->mAlign =3D MIN (mPackAlign, MAX (pFieldType->mAlign, m= NewDataType->mAlign)); - mNewDataType->mTotalSize =3D pNewField->mOffset + (pNewField->mFieldType= ->mTotalSize) * ((ArrayNum =3D=3D 0) ? 1 : ArrayNum); + + if (FieldInUnion) { + if (MaxDataTypeSize < pNewField->mFieldType->mTotalSize) { + mNewDataType->mTotalSize =3D pNewField->mFieldType->mTotalSize; + } + pNewField->mOffset =3D 0; + } else { + mNewDataType->mTotalSize =3D pNewField->mOffset + (pNewField->mFieldTy= pe->mTotalSize) * ((ArrayNum =3D=3D 0) ? 1 : ArrayNum); + } =20 return VFR_RETURN_SUCCESS; } =20 VOID diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Sour= ce/C/VfrCompile/VfrUtilityLib.h index 59509c3..0c67d73 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h @@ -1,10 +1,10 @@ /** @file =20 Vfr common library functions. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 http://opensource.org/licenses/bsd-license.php = =20 = =20 @@ -203,11 +203,11 @@ public: CVfrVarDataTypeDB (VOID); ~CVfrVarDataTypeDB (VOID); =20 VOID DeclareDataTypeBegin (VOID); EFI_VFR_RETURN_CODE SetNewTypeName (IN CHAR8 *); - EFI_VFR_RETURN_CODE DataTypeAddField (IN CHAR8 *, IN CHAR8 *, IN UINT32); + EFI_VFR_RETURN_CODE DataTypeAddField (IN CHAR8 *, IN CHAR8 *, IN UINT32,= IN BOOLEAN); VOID DeclareDataTypeEnd (VOID); =20 EFI_VFR_RETURN_CODE GetDataType (IN CHAR8 *, OUT SVfrDataType **); EFI_VFR_RETURN_CODE GetDataTypeSize (IN CHAR8 *, OUT UINT32 *); EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 20:56:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1496717977879836.5909797264151; Mon, 5 Jun 2017 19:59:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4612F21C93EFF; Mon, 5 Jun 2017 19:58:30 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 07A2D21A08D6A for ; Mon, 5 Jun 2017 19:58:29 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2017 19:59:35 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga002.fm.intel.com with ESMTP; 05 Jun 2017 19:59:34 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,304,1493708400"; d="scan'208";a="1178733950" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 6 Jun 2017 10:58:26 +0800 Message-Id: <1496717906-372916-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1496717906-372916-1-git-send-email-dandan.bi@intel.com> References: <1496717906-372916-1-git-send-email-dandan.bi@intel.com> MIME-Version: 1.0 Subject: [edk2] [RFC v3 2/2] MdeModulePkg/DriverSample: Add sample questions to refer union type X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Eric Dong , Liming Gao Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Cc: Eric Dong Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/DriverSampleDxe/DriverSample.c | 57 ++++++++++++++++++= ++++ .../Universal/DriverSampleDxe/DriverSample.h | 1 + .../Universal/DriverSampleDxe/NVDataStruc.h | 18 +++++++ MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 25 ++++++++++ .../Universal/DriverSampleDxe/VfrStrings.uni | 4 ++ 5 files changed, 105 insertions(+) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.c index f103b9c..c4cd7f2 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -18,10 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 #define DISPLAY_ONLY_MY_ITEM 0x0002 =20 CHAR16 VariableName[] =3D L"MyIfrNVData"; CHAR16 MyEfiVar[] =3D L"MyEfiVar"; +CHAR16 MyUnionVar[] =3D L"MyUnionVar"; EFI_HANDLE DriverHandle[2] =3D {NULL, NULL}; DRIVER_SAMPLE_PRIVATE_DATA *mPrivateData =3D NULL; EFI_EVENT mEvent; =20 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 =3D { @@ -662,10 +663,14 @@ ExtractConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiVar))= { return EFI_UNSUPPORTED; } + + if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyUnionVar= )) { + return EFI_UNSUPPORTED; + } // // Set Request to the unified request string. // ConfigRequest =3D Request; // @@ -884,10 +889,14 @@ RouteConfig ( // if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiV= ar)) { return EFI_UNSUPPORTED; } =20 + if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyUnio= nVar)) { + return EFI_UNSUPPORTED; + } + // // Get Buffer Storage data from EFI variable // BufferSize =3D sizeof (DRIVER_SAMPLE_CONFIGURATION); Status =3D gRT->GetVariable ( @@ -1685,10 +1694,11 @@ DriverSampleInit ( EFI_STRING ConfigRequestHdr; EFI_STRING NameRequestHdr; MY_EFI_VARSTORE_DATA *VarStoreConfig; EFI_INPUT_KEY HotKey; EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx; + MY_UNION_DATA *UnionConfig; =20 // // Initialize the local variables. // ConfigRequestHdr =3D NULL; @@ -1962,10 +1972,57 @@ DriverSampleInit ( return EFI_INVALID_PARAMETER; } } FreePool (ConfigRequestHdr); =20 + // + // Initialize Union efi varstore configuration data + // + UnionConfig =3D &mPrivateData->UnionConfig; + ZeroMem (UnionConfig, sizeof (MY_UNION_DATA)); + + ConfigRequestHdr =3D HiiConstructConfigHdr (&gDriverSampleFormSetGuid, M= yUnionVar, DriverHandle[0]); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (MY_UNION_DATA); + Status =3D gRT->GetVariable (MyUnionVar, &gDriverSampleFormSetGuid, NULL= , &BufferSize, UnionConfig); + if (EFI_ERROR (Status)) { + // + // Store zero data to EFI variable Storage. + // + Status =3D gRT->SetVariable( + MyUnionVar, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (MY_UNION_DATA), + UnionConfig + ); + if (EFI_ERROR (Status)) { + DriverSampleUnload (ImageHandle); + return Status; + } + // + // EFI variable for NV config doesn't exit, we should build this varia= ble + // based on default values stored in IFR + // + ActionFlag =3D HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLA= SS_STANDARD); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } else { + // + // EFI variable does exist and Validate Current Setting + // + ActionFlag =3D HiiValidateSettings (ConfigRequestHdr); + if (!ActionFlag) { + DriverSampleUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + } + FreePool (ConfigRequestHdr); + Status =3D gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL,=20 TPL_NOTIFY, EfiEventEmptyFunction, NULL, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.h index 6c97239..895547a 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -82,10 +82,11 @@ typedef struct { =20 EFI_HANDLE DriverHandle[2]; EFI_HII_HANDLE HiiHandle[2]; DRIVER_SAMPLE_CONFIGURATION Configuration; MY_EFI_VARSTORE_DATA VarStoreConfig; + MY_UNION_DATA UnionConfig; =20 // // Name/Value storage Name list // EFI_STRING_ID NameStringId[NAME_VALUE_NAME_NUMBER]; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModu= lePkg/Universal/DriverSampleDxe/NVDataStruc.h index 195cc8a..eee7282 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -31,10 +31,22 @@ Revision History: #include =20 #define CONFIGURATION_VARSTORE_ID 0x1234 =20 #pragma pack(1) + +typedef struct { + UINT8 Field8; + UINT16 Field16; + UINT8 OrderedList[6]; +} MY_EFI_VARSTORE2_DATA; + +typedef union { + MY_EFI_VARSTORE2_DATA Data2; + UINT8 HowOldAreYouInYearsManual; +} UNION_DATA_TEST; + typedef struct { UINT16 MyStringData[40]; UINT16 SomethingHiddenForHtml; UINT8 HowOldAreYouInYearsManual; UINT16 HowTallAreYouManual; @@ -62,10 +74,11 @@ typedef struct { UINT16 SerialPortIo; UINT8 SerialPortIrq; UINT8 GetDefaultValueFromCallBack; UINT8 GetDefaultValueFromAccess; EFI_HII_TIME Time; + UNION_DATA_TEST UnionData; UINT8 RefreshGuidCount; UINT8 Match2; UINT8 GetDefaultValueFromCallBackForOrderedList[3]; } DRIVER_SAMPLE_CONFIGURATION; =20 @@ -77,10 +90,15 @@ typedef struct { UINT16 Field16; UINT8 OrderedList[3]; UINT16 SubmittedCallback; } MY_EFI_VARSTORE_DATA; =20 +typedef union { + MY_EFI_VARSTORE_DATA Data1; + MY_EFI_VARSTORE2_DATA Data2; +} MY_UNION_DATA; + // // Labels definition // #define LABEL_UPDATE1 0x1234 #define LABEL_UPDATE2 0x2234 diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/= Universal/DriverSampleDxe/Vfr.vfr index 4bdaf76..9dc88ab 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -85,10 +85,15 @@ formset efivarstore MY_EFI_VARSTORE_DATA, attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures =20 name =3D MyEfiVar, guid =3D DRIVER_SAMPLE_FORMSET_GUID; =20 + efivarstore MY_UNION_DATA, + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures + name =3D MyUnionVar, + guid =3D DRIVER_SAMPLE_FORMSET_GUID; + // // Define a Name/Value Storage (EFI_IFR_VARSTORE_NAME_VALUE) // namevaluevarstore MyNameValueVar, // Define storage refer= ence name in vfr name =3D STRING_TOKEN(STR_NAME_VALUE_VAR_NAME0), // Define Name list o= f this storage, refer it by MyNameValueVar[0] @@ -112,10 +117,30 @@ formset =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT); =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); =20 + numeric varid =3D MyUnionVar.Data2.Field8, + prompt =3D STRING_TOKEN(STR_UNION_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_UNION_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 20, + step =3D 0, + default =3D 7, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 8, defaultstore =3D MyManufactureDefault, // This= is manufacture default value + endnumeric; + + numeric varid =3D MyIfrNVData.UnionData.Data2.Field8, + prompt =3D STRING_TOKEN(STR_UNION_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_UNION_NUMERIC_HELP), + minimum =3D 0, + maximum =3D 20, + step =3D 0, + default =3D 7, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 8, defaultstore =3D MyManufactureDefault, // This= is manufacture default value + endnumeric; + // // Define a display only text (EFI_IFR_TEXT) // text help =3D STRING_TOKEN(STR_TEXT_HELP), // Help string diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeMod= ulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 8d24a47..2a632d4 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -86,10 +86,14 @@ #language fr-FR "=C3=89ste es el me= nsaje de la ayuda para la activaci=C3=B3n del armamento nuclear. Cu=C3=A1l = es exactamente resistente calcular fuera sobre de eso?" #string STR_CHECK_DYNAMIC_PROMPT #language en-US "Activate Dynamic c= heck box" #language fr-FR "Activate Dynamico = check box" #string STR_CHECK_DYNAMIC_HELP #language en-US "This is the help m= essage for the activation of check boxes. This is not to be confused with = activating Czech boxes, since one can never tell what the ramifications are= of activating foreign controlled boxes are." #language fr-FR "Spanish - This is = the help message for the activation of check boxes. This is not to be conf= used with activating Czech boxes, since one can never tell what the ramific= ations are of activating foreign controlled boxes are." +#string STR_UNION_NUMERIC_PROMPT #language en-US "UNION numeric" + #language fr-FR "UNION numeric" +#string STR_UNION_NUMERIC_HELP #language en-US "Varstore refer to = union type" + #language fr-FR "Varstore refer to = union type" #string STR_NUMERIC_PROMPT #language en-US "How old are you?" #language fr-FR "C=C3=B3mo viejo es= usted?" #string STR_NUMERIC_STEP_PROMPT #language en-US "How old are you? (= Step)" #language fr-FR "C=C3=B3mo viejo es= usted?(Step)" #string STR_NUMERIC_PROMPT1 #language en-US "How tall are you?" --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel