public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [RFC patch 0/4] Support Bit fields in EFI Variable Storage
Date: Tue, 18 Apr 2017 20:46:28 +0800	[thread overview]
Message-ID: <1492519592-173060-1-git-send-email-dandan.bi@intel.com> (raw)

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



             reply	other threads:[~2017-04-18 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 12:46 Dandan Bi [this message]
2017-04-18 12:46 ` [RFC patch 1/4] BaseTool/VfrCompiler: Support bit fields in EFI Variable Storage Dandan Bi
2017-04-18 12:46 ` [RFC patch 2/4] MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore Dandan Bi
2017-04-18 12:46 ` [RFC patch 3/4] MdeModulePkg/HiiDatabase: " Dandan Bi
2017-04-18 12:46 ` [RFC patch 4/4] MdeModulePkg/DriverSample: Add smaple questions with bit VarStore Dandan Bi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492519592-173060-1-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox