From nobody Sun Dec 29 19:09:54 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 14925196258791020.8788738131518; Tue, 18 Apr 2017 05:47:05 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 605CF2195408F; Tue, 18 Apr 2017 05:47:04 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 165DB21A18AAB for ; Tue, 18 Apr 2017 05:47:03 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 05:47:03 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 18 Apr 2017 05:47:02 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="90823112" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 18 Apr 2017 20:46:32 +0800 Message-Id: <1492519592-173060-5-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> References: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> MIME-Version: 1.0 Subject: [edk2] [RFC patch 4/4] MdeModulePkg/DriverSample: Add smaple questions with bit VarStore 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: Eric Dong , Liming Gao Content-Type: multipart/mixed; boundary="===============0048130975599519945==" Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 --===============0048130975599519945== Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 1.Construct the EFI VarStore with: (a) bit fields (b) nested structure( the nested structure contains bit fields). 2.Construct oneof/numeric/check to refer the bit fields of the EFI VarStore. Cc: Eric Dong Cc: Liming Gao Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/DriverSampleDxe/DriverSample.c | 56 +++++++++++++++++++ .../Universal/DriverSampleDxe/DriverSample.h | 1 + .../Universal/DriverSampleDxe/NVDataStruc.h | 19 +++++++ MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 65 ++++++++++++++++++= ++++ .../Universal/DriverSampleDxe/VfrStrings.uni | 12 ++++ 5 files changed, 153 insertions(+) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeMod= ulePkg/Universal/DriverSampleDxe/DriverSample.c index f103b9c..b226a65 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 MyBitVar[] =3D L"MyBitVar"; 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, MyBitVar))= { + return EFI_UNSUPPORTED; + } + // // Set Request to the unified request string. // ConfigRequest =3D Request; // @@ -883,10 +888,13 @@ RouteConfig ( // through hii database, not support in this path. // if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiV= ar)) { return EFI_UNSUPPORTED; } + if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyBitV= ar)) { + return EFI_UNSUPPORTED; + } =20 // // Get Buffer Storage data from EFI variable // BufferSize =3D sizeof (DRIVER_SAMPLE_CONFIGURATION); @@ -1683,10 +1691,11 @@ DriverSampleInit ( DRIVER_SAMPLE_CONFIGURATION *Configuration; BOOLEAN ActionFlag; EFI_STRING ConfigRequestHdr; EFI_STRING NameRequestHdr; MY_EFI_VARSTORE_DATA *VarStoreConfig; + MY_BITS_VARSTORE_DATA *BitsVarStoreConfig; EFI_INPUT_KEY HotKey; EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx; =20 // // Initialize the local variables. @@ -1962,10 +1971,57 @@ DriverSampleInit ( return EFI_INVALID_PARAMETER; } } FreePool (ConfigRequestHdr); =20 + // + // Initialize Bits efi varstore configuration data + // + BitsVarStoreConfig =3D &mPrivateData->BitsVarStoreConfig; + ZeroMem (BitsVarStoreConfig, sizeof (MY_BITS_VARSTORE_DATA)); + + ConfigRequestHdr =3D HiiConstructConfigHdr (&gDriverSampleFormSetGuid, M= yBitVar, DriverHandle[0]); + ASSERT (ConfigRequestHdr !=3D NULL); + + BufferSize =3D sizeof (MY_BITS_VARSTORE_DATA); + Status =3D gRT->GetVariable (MyBitVar, &gDriverSampleFormSetGuid, NULL, = &BufferSize, BitsVarStoreConfig); + if (EFI_ERROR (Status)) { + // + // Store zero data to EFI variable Storage. + // + Status =3D gRT->SetVariable( + MyBitVar, + &gDriverSampleFormSetGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS, + sizeof (MY_BITS_VARSTORE_DATA), + BitsVarStoreConfig + ); + 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..6947cea 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_BITS_VARSTORE_DATA BitsVarStoreConfig; =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..9b74dda 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -29,10 +29,11 @@ Revision History: #include #include #include =20 #define CONFIGURATION_VARSTORE_ID 0x1234 +#define BITS_VARSTORE_ID 0x2345 =20 #pragma pack(1) typedef struct { UINT16 MyStringData[40]; UINT16 SomethingHiddenForHtml; @@ -77,10 +78,28 @@ typedef struct { UINT16 Field16; UINT8 OrderedList[3]; UINT16 SubmittedCallback; } MY_EFI_VARSTORE_DATA; =20 +typedef struct { + UINT16 Field16; + UINT8 MyBits4 : 1; ///< Bits 0 + UINT8 MyBits3 : 3; ///< Bits 3:1 + UINT8 MyBits5 : 3; ///< Bits 6:4 + UINT16 MyBits6 : 4; ///< Bits 3:0 + UINT8 Field8; +} MY_BITS_VARSTORE_DATA1; + +typedef struct { + UINT16 Field16; + MY_BITS_VARSTORE_DATA1 BitsData; + UINT8 Field8; + UINT16 MyBits7 : 3; ///< Bits 2:0 + UINT16 MyBits8 : 3; ///< Bits 5:3 + UINT16 MyBits9 : 1; ///< Bits 6 +} MY_BITS_VARSTORE_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..cbc8f6d 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -86,10 +86,18 @@ formset 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 // + // Define a Buffer Storage (EFI_IFR_VARSTORE) + // + efivarstore MY_BITS_VARSTORE_DATA, // This is the data structure t= ype + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLAT= ILE, // EFI variable attribures + name =3D MyBitVar, // Define referenced name in= vfr + guid =3D DRIVER_SAMPLE_FORMSET_GUID; // GUID of this buffer stora= ge + + // // 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] name =3D STRING_TOKEN(STR_NAME_VALUE_VAR_NAME1), // Define Name list o= f this storage, refer it by MyNameValueVar[1] @@ -112,10 +120,67 @@ formset =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT); =20 subtitle text =3D STRING_TOKEN(STR_SUBTITLE_TEXT2); =20 + checkbox varid =3D MyBitVar.BitsData.MyBits4, + questionid =3D 0x6666, + prompt =3D STRING_TOKEN(STR_BIT_NEST_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyBitVar.BitsData.MyBits3, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_NEST_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + numeric varid =3D MyBitVar.BitsData.MyBits5, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 5, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 6, defaultstore =3D MyManufactureDefault, // This= is manufacture default value + endnumeric; + + numeric varid =3D MyBitVar.BitsData.MyBits6, + prompt =3D STRING_TOKEN(STR_BIT_NEST_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 15, + step =3D 0, + default =3D 11, defaultstore =3D MyStandardDefault, // Thi= s is standard default value + default =3D 12, defaultstore =3D MyManufactureDefault, // Thi= s is manufacture default value + endnumeric; + + checkbox varid =3D MyBitVar.MyBits9, + prompt =3D STRING_TOKEN(STR_BIT_CHECK_BOX_PROMPT), + help =3D STRING_TOKEN(STR_CHECK_BOX_HELP), + flags =3D CHECKBOX_DEFAULT, + endcheckbox; + + oneof varid =3D MyBitVar.MyBits8, + prompt =3D STRING_TOKEN(STR_ONE_OF_BIT_PROMPT), + help =3D STRING_TOKEN(STR_ONE_OF_HELP), + option text =3D STRING_TOKEN(STR_BOOT_ORDER1), value =3D 0, flags = =3D MANUFACTURING; + option text =3D STRING_TOKEN(STR_BOOT_ORDER2), value =3D 1, flags = =3D DEFAULT; + endoneof; + + numeric varid =3D MyBitVar.MyBits7, + prompt =3D STRING_TOKEN(STR_BIT_NUMERIC_PROMPT), + help =3D STRING_TOKEN(STR_NUMERIC_HELP0), + minimum =3D 0, + maximum =3D 7, + step =3D 0, + default =3D 5, defaultstore =3D MyStandardDefault, // This= is standard default value + default =3D 6, 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..9a52c02 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -55,10 +55,14 @@ #language fr-FR "Please select the = number" =20 #string STR_NUMERIC_NUM_HELP #language en-US "Check the input nu= mber, test the efi buffer varstore" #language fr-FR "Check the input nu= mber, test the efi buffer varstore" =20 #string STR_ONE_OF_PROMPT #language en-US "My one-of prompt #= 1" #language fr-FR "Mi uno- de gu=C3= =ADa # 1" +#string STR_ONE_OF_BIT_PROMPT #language en-US "BIT one-of" + #language fr-FR "BIT one-of" +#string STR_ONE_OF_BIT_NEST_PROMPT #language en-US "NEST_BIT one-of" + #language fr-FR "NEST_BIT one-of" #string STR_ONE_OF_PROMPT_KEYWORD #language en-US "My Keyword Namespa= ce Test" #language fr-FR "My Keyword Namespa= ce Test" #language x-UEFI-ns "iSCSIBootEnabl= e" #string STR_CHECK_KEYWORD_SUPPORT #language en-US "Check iSCSI Boot E= nable" #language fr-FR "Check iSCSI Boot E= nable" @@ -78,12 +82,20 @@ #language fr-FR "Mi uno- del texto = # 6" #string STR_BOOT_ORDER1 #language en-US "SmallBootList" #language fr-FR "Mi uno- del texto = # 7" #string STR_BOOT_ORDER2 #language en-US "LargeBootList" #language fr-FR "Mi uno- del texto = # 8" +#string STR_BIT_NUMERIC_PROMPT #language en-US "BIT numeric" + #language fr-FR "BIT numeric" +#string STR_BIT_NEST_NUMERIC_PROMPT #language en-US "NEST_BIT numeric" + #language fr-FR "NEST_BIT numeric" #string STR_CHECK_BOX_PROMPT #language en-US "Activate this chec= k box" #language fr-FR "Active Las Armas N= ucleares" +#string STR_BIT_CHECK_BOX_PROMPT #language en-US "BIT check box" + #language fr-FR "BIT check box" +#string STR_BIT_NEST_CHECK_BOX_PROMPT #language en-US "NEST_BIT check box" + #language fr-FR "NEST_BIT check box" #string STR_CHECK_BOX_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 "=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." --=20 1.9.5.msysgit.1 --===============0048130975599519945== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel --===============0048130975599519945==--