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 <eric.d...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Cc: Dandan Bi <dandan...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>

Dandan Bi (4):
  BaseTool/VfrCompiler: Support bit fields in EFI Variable Storage
  MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore
  MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore
  MdeModulePkg/DriverSample: Add example questions with bit VarStore

 BaseTools/Source/C/VfrCompile/VfrFormPkg.h         |  14 +-
 BaseTools/Source/C/VfrCompile/VfrSyntax.g          | 505 +++++++++++++++++----
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp    | 406 ++++++++++++++++-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.h      |  25 +-
 .../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 +
 .../Universal/HiiDatabaseDxe/ConfigRouting.c       | 197 +++++++-
 .../Universal/HiiDatabaseDxe/HiiDatabase.h         |   3 +
 MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c  | 137 ++++--
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.c     | 106 ++++-
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.h     |   3 +
 14 files changed, 1372 insertions(+), 177 deletions(-)

-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to