From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B062321A16ECF for ; Sat, 27 May 2017 01:34:23 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2017 01:35:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,400,1491289200"; d="scan'208";a="107265604" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 27 May 2017 01:35:18 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao Date: Sat, 27 May 2017 16:34:15 +0800 Message-Id: <1495874060-331108-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [RFC V2 0/5] Support Bit fields in EFI/Buffer 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: , X-List-Received-Date: Sat, 27 May 2017 08:34:23 -0000 V2: Not only support bit filed for EFI variable storage but also for buffer storage. And add sample questions to refer bit filed in buffer storage. Did some code/logic refining work. Proposal: In VFR file, the storage of some Question may use Bit field in an EFI VarStore. So we propose to update VfrCompiler/SetupBrowser/HiiDatabase to support this usage model as edk2 implementation enhancement. It will allow EFI varstore has Bit fields, and CheckBox/OneOf/Numeric VarId can refer to Bit field. VFR syntax has no changes. VfrCompiler will create Question which refers to Bit field with a specific GUID opcode. If SetupBrowser doesn't recognize the GUID opcode, it will skip those Questions and show other Questions normally. Detail changes: Take the codes in edk2\MdeModulePkg\Universal\DriverSampleDxe as an example. 1.VfrCompiler: (a) Enhance the VfrCompiler to parse the Data structure with Bit fields and record the Offset/With(in bit level ) of the members(Bit Offset/ With). Add data structure with bit fields in NvDataStructure.h file as below: typedef struct { UINT16 Field16; UINT8 Field8; UINT16 MyBits7 : 3; ///< Bits 2:0 UINT16 MyBits8 : 3; ///< Bits 5:3 UINT16 MyBits9 : 1; ///< Bits 6 } MY_BITS_VARSTORE_DATA; (b) Keep the declaration of EFI VarStore with bit fields same with the normal EFI VarStore, no syntax change in .vfr file. In vfr.vfr file, declare the efivarstore with bit fields same with the normal EFI VarStore efivarstore MY_BITS_VARSTORE_DATA, // This is the data structure type attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures name = MyBitVar, // Define referenced name in vfr guid = DRIVER_SAMPLE_FORMSET_GUID; // GUID of this buffer storage So VfrCompiler need to detect whether the data structure of this EFI VarStore(MY_BITS_VARSTORE_DATA) contains bit field, if yes, it's bit EFI VarStore, or it's normal EFI VarStore. (c) For the Question which refer to Bit field of an EFI VarStore, VfrCompiler will generate a GUID opcode to cover this Question. numeric varid = MyBitVar.MyBits7, prompt = STRING_TOKEN(STR_BIT_NUMERIC_PROMPT), help = STRING_TOKEN(STR_NUMERIC_HELP0), minimum = 0, maximum = 7, step = 0, default = 5, defaultstore = MyStandardDefault, // This is standard default value default = 6, defaultstore = MyManufactureDefault, // This is manufacture default value endnumeric; VfrCompiler generate a GUID opcode with a specified GUID value to cover the numeric opcode numeric varid = MyBitVar.MyBits7, >0000024B: 5F 92 8B D6 DD 82 63 91 87 41 9B 27 20 A8 FD 60 A7 1D (Guid opcode) >0000025D: 07 A6 2D 00 37 00 06 00 02 00 48 00 00 13 00 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (numeric opcode) prompt = STRING_TOKEN(0x002D), help = STRING_TOKEN(0x0037), minimum = 0, maximum = 7, step = 0, default = 5, defaultstore = MyStandardDefault, >00000283: 5B 09 00 00 02 05 00 00 00 default = 6, defaultstore = MyManufactureDefault, >0000028C: 5B 09 01 00 02 06 00 00 00 endnumeric; >00000295: 29 02 (end of numeric opcode) >00000297: 29 02 (end of Guid opcode) (d) Save Offset/ With info for Question CheckBox/OneOf/Numeric which refer to Bit EFI VarStore. Record the Bit Offset/ With info, the max Bit Width is 32 CheckBox: Bit width should always be 1 bit(VfrCompiler should report error for other value). Numeric/Oneof: Bit width can be saved in EFI_IFR_NUMERIC.Flags/EFI_IFR_ONE_OF.Flags. Bit Offset can be saved in EFI_IFR_QUESTION_HEADER. VarStoreInfo. VarOffset Data type will be EFI_IFR_TYPE_NUM_SIZE_32 for BIT Numeric/Oneof. 2.SetupBrowserDxe: Need to get/set question value for Bit Questions correctly Parse the Ifr data, if the GUID opcode with specified GUID value, means the following Question's VarId refer to Bit field of an EFI VarStore. Record the bit Offset/ With and the converted byte Offset/ With to generate the ConfigRequest string. When get/set Question value or get question default value, need to set/get the value to/from specified bit offset and width. 3.HiiDatabaseDxe: Need to generate the ConfigAltResp for Bit Questions correctly Parse the Ifr data, if the GUID opcode with specified GUID value, means the following Question's VarId refer to Bit field of an EFI VarStore. Record the bit offset/ with and the converted byte Offset/ With. When generating ConfigAltResp, need to merge the value of the same byte Offset/ With base on the bit Offset/ With. These are the POC codes (verify platform: Nt32). Thanks for your comments. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Dandan Bi (5): BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore MdeModulePkg: Add guid/flags to implement BitFiled support MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore MdeModulePkg/DriverSample: Add sample questions with bit VarStore BaseTools/Source/C/Include/Common/MdeModuleHii.h | 10 + BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 +- BaseTools/Source/C/VfrCompile/VfrError.h | 3 +- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 46 +- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 587 +++++++++++++++++---- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 390 +++++++++++++- BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 25 +- MdeModulePkg/Include/Guid/MdeModuleHii.h | 19 +- MdeModulePkg/MdeModulePkg.dec | 4 + .../Universal/DriverSampleDxe/DriverSample.c | 64 +++ .../Universal/DriverSampleDxe/DriverSample.h | 1 + .../Universal/DriverSampleDxe/NVDataStruc.h | 25 + MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 152 ++++++ .../Universal/DriverSampleDxe/VfrStrings.uni | 26 + .../Universal/HiiDatabaseDxe/ConfigRouting.c | 194 ++++++- .../Universal/HiiDatabaseDxe/HiiDatabase.h | 4 + .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf | 1 + MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 140 +++-- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 108 +++- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 3 + .../Universal/SetupBrowserDxe/SetupBrowserDxe.inf | 1 + 21 files changed, 1610 insertions(+), 196 deletions(-) -- 1.9.5.msysgit.1