[edk2] [edk2-BuildSpecification PATCH V2] Add EBNF for --pcd flag command line flag

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=523

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 
---
 README.md   |  3 ++-
 appendix_d_buildexe_command/d4_usage.md | 32 
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 16fcc4a..00fd89d 100644
--- a/README.md
+++ b/README.md
@@ -200,7 +200,7 @@ Copyright (c) 2008-2017, Intel Corporation. All rights 
reserved.
 || Remove Unicode file storage requirement; refer to the 
Multi-String UNI File Format Specification instead. 


  |   |
 || Clarify BUILDRULEORDER  



|   |
 || Add support for INF statement in an FD region.  



|   |
-| 1.27   | Convert to Gitbook  



| April 2017|
+| 1.27   | Convert to Gitbook  



| May 2017  |
 || [#471](https://bugzilla.tianocore.org/show_bug.cgi?id=471) 
Build spec: only copy the "TianoCore" Userextension section into "As Built" INF 


 |   |
 || [#472](https://bugzilla.tianocore.org/show_bug.cgi?id=472) 
[Build Spec] Extend macro usage in the !include statements for DSC/FDF files


 |   |
 || [#483](https://bugzilla.tianocore.org/show_bug.cgi?id=483) 
Build Spec: add description for merge Pre-build and Post-build into build 
process 

   |   |
@@ -212,3 +212,4 @@ Copyright (c) 2008-2017, Intel Corporation. All rights 
reserved.
 || [#504](https://bugzilla.tianocore.org/show_bug.cgi?id=504) 
Update build report to support -Y HASH option   


 |   |
 || [#508](https://bugzilla.tianocore.org/show_bug.cgi?id=508) 
Build Spec: Add sections to PCD report for PCDs only used in conditions PCDs 
that are not used anywhere  

|   |
 || [#480](https://bugzilla.tianocore.org/show_bug.cgi?id=480) 
Build spec: add description for Override PCD value on the command line  


 |   |
+|| [#523

[edk2] [edk2-BuildSpecification PATCH V2] Add EBNF for --pcd flag command line flag

2017-05-27 Thread Michael Kinney
Changes in V2
* Section D.4.3 - Change INC to INF
* Support both hexidecimal and decimal PCD values on command line
* Support both 0x and 0X prefix for hexidecimal PCD values
* Add missing  EBNF defintion

https://bugzilla.tianocore.org/show_bug.cgi?id=523

GitHub branch for review:

* 
https://github.com/mdkinney/edk2-BuildSpecification/tree/Bugzilla_523_EbnfPcdCommandLineOption_V2

GitHub word diff view of the patches in this series:

* [1/1] 
https://github.com/mdkinney/edk2-BuildSpecification/commit/5a7c79736539e1c5acd90665280c592b91f773c4?w=1

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 

Michael Kinney (1):
  Add EBNF for --pcd flag command line flag

 README.md   |  3 ++-
 appendix_d_buildexe_command/d4_usage.md | 32 
 2 files changed, 34 insertions(+), 1 deletion(-)

-- 
2.6.3.windows.1

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


[edk2] [edk2-DscSpecification PATCH] Allow mixed PCD access methods

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=521

GitHub branch for review:

* 
https://github.com/mdkinney/edk2-DscSpecification/tree/Bugzilla_521_AllowMixedPcdAccessTypes

GitHub word diff view of the patches in this series:

* [1/1] 
https://github.com/mdkinney/edk2-DscSpecification/commit/fa580dd7bd1a0aae86e821b382d0865e467ec744?w=1

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 

Michael Kinney (1):
  Allow mixed PCD access methods

 2_dsc_overview/28_pcd_section_processing.md  | 12 ++--
 3_edk_ii_dsc_file_format/310_pcd_sections.md | 15 +++
 README.md|  5 +++--
 3 files changed, 24 insertions(+), 8 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [edk2-DscSpecification PATCH] Allow mixed PCD access methods

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=521

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 
---
 2_dsc_overview/28_pcd_section_processing.md  | 12 ++--
 3_edk_ii_dsc_file_format/310_pcd_sections.md | 15 +++
 README.md|  5 +++--
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/2_dsc_overview/28_pcd_section_processing.md 
b/2_dsc_overview/28_pcd_section_processing.md
index 60e7de7..0969b41 100644
--- a/2_dsc_overview/28_pcd_section_processing.md
+++ b/2_dsc_overview/28_pcd_section_processing.md
@@ -103,10 +103,18 @@ of three categories:
 **Note:** For the dynamic types of PCDs, using an `$(Arch)` extension other
 than `common` in the section header is not valid.
 **
-**Warning:** A PCD can only use one type for all modules. It is not permissible
-to list a PCD in a PcdsFixedAtBuild section and also list it in a
+**Warning:** A PCD can only use one type for all source modules. It is not
+permissible to list a PCD in a PcdsFixedAtBuild section and also list it in a
 PcdsPatchableInModule section.
 **
+**Note:** Binary modules included in a platform build are permitted to use the
+PatchableInModule or DynamicEx access methods (the Binary module must specify
+which of these two methods were used to create the binary module) regardless of
+the method used for a given PCD in modules built from source. The build 
supports
+binary modules that use the same or different PCD access method than the source
+modules or other binary modules. The build parser must break with an error if a
+PCD is listed as FixedAtBuild or Dynamic (not DynamicEx) in the Binary INF.
+**
 
 Datum Types for PCD values are either Boolean (`BOOLEAN` - 1 byte), numeric
 (`UINT8` - 1 byte, `UINT16` - 2 bytes, `UINT32` - 4 bytes or `UINT64` - 8
diff --git a/3_edk_ii_dsc_file_format/310_pcd_sections.md 
b/3_edk_ii_dsc_file_format/310_pcd_sections.md
index bf20cc5..c061e5b 100644
--- a/3_edk_ii_dsc_file_format/310_pcd_sections.md
+++ b/3_edk_ii_dsc_file_format/310_pcd_sections.md
@@ -75,10 +75,17 @@ value specified in the INF file or the default value listed 
in the DEC file
 (for modules that do not list a preferred value). This same rule applies to
 `FeatureFlag` PCDs.
 
-If the INF values differ (or are not listed) and the access methods are
-different, then the build must break. A PCD can only use a single method of
-access for the platform and all modules in the platform that use the PCD must
-use the same access method.
+If the Source INF values differ (or are not listed) and the access methods are
+different, then the build must break. All source modules in a platform must use
+the same PCD same access method.
+
+Binary modules included in a platform build are permitted to use the
+PatchableInModule or DynamicEx access methods (the Binary module must specify
+which of these two methods were used to create the binary module) regardless of
+the method used for a given PCD in modules built from source. The build 
supports
+binary modules that use the same or different PCD access method than the source
+modules or other binary modules. The build parser must break with an error if a
+PCD is listed as FixedAtBuild or Dynamic (not DynamicEx) in the Binary INF.
 
 If no value is entered in the DSC file, and no INF files provide a preferred
 value, then the DEC file's default value must be used.
diff --git a/README.md b/README.md
index 1d1f99c..eb6966f 100644
--- a/README.md
+++ b/README.md
@@ -176,7 +176,8 @@ Copyright (c) 2006-2017, Intel Corporation. All rights 
reserved.
 || Update the DSC_SPECIFICATION version to 0x0001001A  


 ||
 || Revised WORKSPACE wording for updated build system that can 
handle packages located outside of the WORKSPACE directory tree (refer to the 
TianoCore.org/ EDKII website for additional instructions on setting up a 
development environment). | 
   |
 || Added new system environment variables used by the build 
system. 

|   
 |
-| 1.27   | Convert to GitBooks 


 | April 2017 |
+| 1.27   | C

[edk2] [edk2-DscSpecification PATCH] Update Precedence of PCD Values

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=519

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 
---
 2_dsc_overview/28_pcd_section_processing.md | 56 ++---
 README.md   |  5 +--
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/2_dsc_overview/28_pcd_section_processing.md 
b/2_dsc_overview/28_pcd_section_processing.md
index 60e7de7..3736cde 100644
--- a/2_dsc_overview/28_pcd_section_processing.md
+++ b/2_dsc_overview/28_pcd_section_processing.md
@@ -312,45 +312,45 @@ string plus 1 byte for the null terminator, for L"string" 
entries to be the
 length of the UCS-2 character string plus 2 bytes for the null terminator and
 the exact length of a byte array.
 
-Precedence for determining PCD values (high to low, last in position) is as
-follows:
+The values that are assigned to individual PCDs required by a build may come
+from different locations and different meta-data files. The following provides
+the precedence (high to low) to assign a value to a PCD.
 
-* A PCD value defined by a MACRO, ("MacroName" in this example), and the Macro
-  is defined on the command-line using -D MacroName=Value
+* Command-line, `--pcd` flags (left most has higher priority)
 
-* A PCD value defined in the FDF file SET statements
+* DSC file, p FeatureFlag, PatchableInModule or FixedAtBuild PCD value defined
+  in the `[Components]` INF scoping `` section statements
 
-* A PCD value defined positionally in the FDF file
+* FDF file, grammar describing automatic assignment of PCD values
 
-* A FeatureFlag, PatchableInModule or FixedAtBuild PCD value defined in the
-  `[Components]` INF scoping section
+* FDF file, SET statements within a section
 
-* A FeatureFlag, PatchableInModule or FixedAtBuild PCD value defined in a PCD
-  access method section with an architectural modifier (the access method for a
-  PCD in a section with an architectural modifier takes precedence over any
-  other access method)
+* FDF file, SET statement in the [Defines] section
 
-In this example, modules built for IA32 architecture, the PCD will use
-PatchableInModule access, while modules built for all other architectures, the
-PCD will use the FixedAtBuild access method:
+* DSC file, a FeatureFlag, PatchableInModule or FixedAtBuild PCD value defined
+  in a PCD access method section with an architectural modifier.
 
-```ini
-[PcdsFixedAtBuild.common]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
+  In this example, modules built for IA32 architecture, the PCD will use
+  PatchableInModule access, while modules built for all other architectures, 
the
+  PCD will use the FixedAtBuild access method:
 
-[PcdsPatchableInModule.IA32]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-```
+  ```ini
+  [PcdsFixedAtBuild.common]
+gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
+gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
+
+  [PcdsPatchableInModule.IA32]
+gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
+gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
+  ```
 
-* A PCD value defined in a PCD access method (item type) section for common
-  architectures
+* DSC file, A PCD value defined in a PCD access method (item type) global
+  `[Pcd*]` section for common architectures.
 
-* A PCD value defined in an INF (provided all INF files have defined the same
-  value)
+* INF file, PCD sections, Default Values (provided all INF files have defined
+  the same value)
 
-* A PCD default value defined in the DEC file that declares the PCD.
+* DEC file, PCD sections, Default Values
 
 **
 **Note:** Dynamic or DynamicEx PCD sections with architectural modifiers is not
diff --git a/README.md b/README.md
index 1d1f99c..3bec3b3 100644
--- a/README.md
+++ b/README.md
@@ -176,7 +176,8 @@ Copyright (c) 2006-2017, Intel Corporation. All rights 
reserved.
 || Update the DSC_SPECIFICATION version to 0x0001001A  


 ||
 || Revised WORKSPACE wording for updated build system that can 
handle packages located outside of the WORKSPACE directory tree (refer to the 
TianoCore.org/ EDKII website for additional instructions on setting up a 
development environment). | 
   |
 || Added new system environment variables used by the build 
system. 
   

[edk2] [edk2-DscSpecification PATCH] Update Precedence of PCD Values

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=519

GitHub branch for review:

* 
https://github.com/mdkinney/edk2-DscSpecification/tree/Bugzilla_519_UpdatePrecedenceOfPcdValues

GitHub word diff view of the patches in this series:

* [1/1] 
https://github.com/mdkinney/edk2-DscSpecification/commit/ca3ca4fbff09a59954cb80b571b836e6cf15e19e?w=1

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 

Michael Kinney (1):
  Update Precedence of PCD Values

 2_dsc_overview/28_pcd_section_processing.md | 56 ++---
 README.md   |  5 +--
 2 files changed, 31 insertions(+), 30 deletions(-)

-- 
2.6.3.windows.1

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


[edk2] [edk2-FdfSpecification PATCH] Update Precedence of PCD Values

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=520

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 
---
 2_fdf_design_discussion/21_processing_overview.md | 26 +++
 README.md |  3 ++-
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/2_fdf_design_discussion/21_processing_overview.md 
b/2_fdf_design_discussion/21_processing_overview.md
index ddef010..7a045dd 100644
--- a/2_fdf_design_discussion/21_processing_overview.md
+++ b/2_fdf_design_discussion/21_processing_overview.md
@@ -105,13 +105,31 @@ warning message on the PCD defined in the DSC file. 
Default values from DEC
 files are not permitted in the EDK II build system for PCDs specified in the
 FDF file.
 
-PCD values set in this file override PCD settings in other EDK II meta-data
-files. Note that PCDs settings are positional within the FDF file.
-
-Additionally, the PCDs used in the FDF file must be specified as:
+The PCDs used in the FDF file must be specified as:
 
 `PcdTokenSpaceGuidCName.PcdCName`
 
+### 2.1.2 Precedence of PCD Values
+
+The values that are assigned to individual PCDs required by a build may come
+from different locations and different meta-data files. The following provides
+the precedence (high to low) to assign a value to a PCD.
+
+* Command-line, `--pcd` flags (left most has higher priority)
+* DSC file, Component INF `` section statements
+* FDF file, grammar describing automatic assignment of PCD values
+* FDF file, SET statements within a section
+* FDF file, SET statement in the [Defines] section
+* DSC file, global [Pcd*] sections
+* INF file, PCD sections, Default Values
+* DEC file, PCD sections, Default Values
+
+In addition to the above precedence rules, PCDs set in sections with
+architectural modifiers take precedence over PCD sections that are common to
+all architectures.
+
+If a PCD is listed in the same section multiple times, the last one is used.
+
  PCD RULES
 
 There are no PCD sections defined for the FDF file. PCD values are assigned in
diff --git a/README.md b/README.md
index 131246d..bad0930 100644
--- a/README.md
+++ b/README.md
@@ -194,7 +194,7 @@ Copyright (c) 2006-2017, Intel Corporation. All rights 
reserved.
 || PACKAGES_PATH and EDK_TOOLS_BIN, used by the build system.  

   |   |
 || Allow INF statements in FD regions. 

   |   |
 || Clarified [UserExtensions] content in chapter 2 (to match 
implementation) 
 |   |
-| 1.28   | Convert to GitBooks 

   | April 2017|
+| 1.28   | Convert to GitBooks 

   | May 2017  |
 || [#426](https://bugzilla.tianocore.org/show_bug.cgi?id=426) 
IMAGE_TYPE_ID must be provided with value, FDF should mark it as required 
section   |   |
 || [#373](https://bugzilla.tianocore.org/show_bug.cgi?id=373) 
Conditional statement examples incorrect
|   |
 || [#461](https://bugzilla.tianocore.org/show_bug.cgi?id=461) FDF 
Spec: add a super script number for the
|   |
@@ -206,3 +206,4 @@ Copyright (c) 2006-2017, Intel Corporation. All rights 
reserved.
 || [#142](https://bugzilla.tianocore.org/show_bug.cgi?id=142) 
Update EDK II FDF Specification to allow sections in any order  
|   |
 || [#478](https://bugzilla.tianocore.org/show_bug.cgi?id=478) FDF 
spec: extend the  to support  and  
|   |
 || [#353](https://bugzilla.tianocore.org/show_bug.cgi?id=353) 
Build spec: Allow nested includes in DSC and FDF files  
|   |
+|| [#520](https://bugzilla.tianocore.org/show_bug.cgi?id=520) FDF 
spec: Update Precedence of PCD Values   
|   |
-- 
2.6.3.windows.1

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

[edk2] [edk2-FdfSpecification PATCH] Update Precedence of PCD Values

2017-05-27 Thread Michael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=520

GitHub branch for review:

* 
https://github.com/mdkinney/edk2-FdfSpecification/tree/Bugzilla_520_UpdatePrecedenceOfPcdValues

GitHub word diff view of the patches in this series:

* [1/1] 
https://github.com/mdkinney/edk2-FdfSpecification/commit/c1dfd77016b27d76d1f574974ff59a3edcce324a?w=1

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 

Michael Kinney (1):
  Update Precedence of PCD Values

 2_fdf_design_discussion/21_processing_overview.md | 26 +++
 README.md |  3 ++-
 2 files changed, 24 insertions(+), 5 deletions(-)

-- 
2.6.3.windows.1

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


Re: [edk2] [Patch] SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate symbol

2017-05-27 Thread Ard Biesheuvel
On 26 May 2017 at 23:06, Kinney, Michael D  wrote:
> Felix,
>
> Yes.  I agree.  I will work on a Bugzilla issue for this topic
> and I prefer the idea of updating Base.h to check _MSC_VER value.
>
> The one challenge is that 'static' could be added in front of
> GLOBAL_REMOVE_IF_UNREFERENCED, and it will build correctly with
> VS2012 and newer, but would fail with older VS versions that
> require __declspec(selectany) for size optimization.
>

As has been pointed out already in this thread (by Laszlo, I think),
STATIC may trigger 'unused symbol' warnings that break the build under
our warnings-as-errors policy, since the compiler can infer that no
external references exist. So while STATIC is absolutely the way
forward, #define'ing it in a way that affects existing code is likely
to cause problems.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] BaseTools/Scripts: discard .gnu.hash section in GCC builds

2017-05-27 Thread Gao, Liming
Ard:
  I just run BaseTools\Scripts\PatchCheck.py to check the latest patches. It 
reports one issue in this patch. Could you fix it?

The commit message format passed all checks.
Code format is not valid:
 * Line ending ('\n') is not CRLF
   File: BaseTools/Scripts/GccBase.lds
   Line: *(.hash .gnu.hash)

Thanks
Liming
> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Wednesday, May 24, 2017 9:13 PM
> To: Gao, Liming 
> Cc: edk2-devel@lists.01.org; leif.lindh...@linaro.org; Zhu, Yonghong 
> 
> Subject: Re: [PATCH] BaseTools/Scripts: discard .gnu.hash section in GCC 
> builds
> 
> On 21 May 2017 at 21:05, Gao, Liming  wrote:
> > Reviewed-by: Liming Gao 
> >
> 
> Thanks. Pushed as 00b00cc57bfe0fca54c904d4dd44a263e243c88b
> 
> >>-Original Message-
> >>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> >>Sent: Friday, May 19, 2017 6:48 PM
> >>To: edk2-devel@lists.01.org
> >>Cc: leif.lindh...@linaro.org; Zhu, Yonghong ; Gao,
> >>Liming ; Ard Biesheuvel 
> >>Subject: [PATCH] BaseTools/Scripts: discard .gnu.hash section in GCC builds
> >>
> >>Some builds of GCC/binutils will default to using the GNU flavor of
> >>the symbol hash table, and will emit it into a section called .gnu.hash
> >>rather than .hash. We have no use for its contents, and GenFw ignores
> >>it anyway, so it shouldn't really matter what we do with it.
> >>
> >>However, due to a workaround for AARCH64 we have in GenFw to deal with
> >>older GCCs that corrupt section-based relocations when merging sections
> >>during the final link, we need the ELF and PE/COFF views of the binary
> >>to be identical. Since we don't place the .gnu.hash section explicitly,
> >>it may end up at the beginning of the ELF binary, causing other sections
> >>to be shifted in the ELF view but not in the PE/COFF view.
> >>
> >>So let's add .gnu.hash to the GCC linker script. We don't care about its
> >>contents so add it to the /DISCARD/ section.
> >>
> >>Contributed-under: TianoCore Contribution Agreement 1.0
> >>Signed-off-by: Ard Biesheuvel 
> >>---
> >> BaseTools/Scripts/GccBase.lds | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds
> >>index 41e5c0b4a769..a43e0072f2b4 100644
> >>--- a/BaseTools/Scripts/GccBase.lds
> >>+++ b/BaseTools/Scripts/GccBase.lds
> >>@@ -78,7 +78,7 @@ SECTIONS {
> >> *(.dynsym)
> >> *(.dynstr)
> >> *(.dynamic)
> >>-*(.hash)
> >>+*(.hash .gnu.hash)
> >> *(.comment)
> >> *(COMMON)
> >>   }
> >>--
> >>2.9.3
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [RFC V2 1/5] BaseTool/VfrCompiler: Support Bit fields in EFI/Buffer VarStore

2017-05-27 Thread Dandan Bi
Enhance VfrCompiler to parse following case:
1. EFI/Buffer VarStore can contain bit fields in their structure.
2. For question Oneof/Checkbox/numeric, their storage can be
   bit fields of an EFI VarStore/Buffer VarStore.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 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 +-
 7 files changed, 920 insertions(+), 144 deletions(-)

diff --git a/BaseTools/Source/C/Include/Common/MdeModuleHii.h 
b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
index 21c8387..866a855 100644
--- a/BaseTools/Source/C/Include/Common/MdeModuleHii.h
+++ b/BaseTools/Source/C/Include/Common/MdeModuleHii.h
@@ -42,10 +42,20 @@
 #define EFI_IFR_EXTEND_OP_TIMEOUT 0x2
 #define EFI_IFR_EXTEND_OP_CLASS   0x3
 #define EFI_IFR_EXTEND_OP_SUBCLASS0x4
 
 ///
+/// EDKII implementation extension flags, used to indaicate the disply style 
and bit width for bit filed storage.
+///
+#define EFI_IFR_DISPLAY_BIT0xC0
+#define EFI_IFR_DISPLAY_INT_DEC_BIT0x00
+#define EFI_IFR_DISPLAY_UINT_DEC_BIT   0x40
+#define EFI_IFR_DISPLAY_UINT_HEX_BIT   0x80
+
+#define EFI_IFR_NUMERIC_SIZE_BIT   0x3F
+
+///
 /// Label opcode.
 ///
 typedef struct _EFI_IFR_GUID_LABEL {
   EFI_IFR_OP_HEADER   Header;
   ///
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp 
b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index 285e175..0f8f7dd 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -1,10 +1,10 @@
 /** @file
   
   VfrCompiler error handler.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php 
   

   
@@ -44,10 +44,11 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
   { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error, the valid value is in 
(0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr" },
   { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
   { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with 
different value"},
   { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
   { VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR, ": Varstore name is defined by 
more than one varstores, it can't be referred as varstore, only varstore 
strucure name could be used."},
+  { VFR_RETURN_BIT_WIDTH_ERROR, ": bit width must be <= sizeof (type) * 8 and 
the max width can not > 32" },
   { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
 };
 
 static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = {
   { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with 
different value"},
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h 
b/BaseTools/Source/C/VfrCompile/VfrError.h
index 4dbc54c..8bae049 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.h
+++ b/BaseTools/Source/C/VfrCompile/VfrError.h
@@ -1,10 +1,10 @@
 /** @file
   
   VfrCompiler Error definition
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php 
   

   
@@ -42,10 +42,11 @@ typedef enum {
   VFR_RETURN_ERROR_ARRARY_NUM,
   VFR_RETURN_DATA_STRING_ERROR,
   VFR_RETURN_DEFAULT_VALUE_REDEFINED,
   VFR_RETURN_CONSTANT_ONLY,
   VFR_RETURN_VARSTORE_NAME_REDEFINED_ERROR,
+  VFR_RETURN_BIT_WIDTH_ERROR,
   VFR_RETURN_CODEUNDEFINED
 } EFI_VFR_RETURN_CODE;
 
 typedef enum {
   VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0,
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 17ab14c..3ed6748 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTo

[edk2] [RFC V2 2/5] MdeModulePkg: Add guid/flags to implement BitFiled support

2017-05-27 Thread Dandan Bi
Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Include/Guid/MdeModuleHii.h | 19 ++-
 MdeModulePkg/MdeModulePkg.dec|  4 
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Guid/MdeModuleHii.h 
b/MdeModulePkg/Include/Guid/MdeModuleHii.h
index 81821da..45cac9f 100644
--- a/MdeModulePkg/Include/Guid/MdeModuleHii.h
+++ b/MdeModulePkg/Include/Guid/MdeModuleHii.h
@@ -1,9 +1,9 @@
 /** @file
   EDKII extented HII IFR guid opcodes.
 
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
 The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php.

 
@@ -209,12 +209,29 @@ typedef struct _EFI_IFR_GUID_VAREQNAME {
   /// The the Unicode String will be used as a EFI Variable Name.
   ///
   UINT16  NameId;
 } EFI_IFR_GUID_VAREQNAME;
 
+///
+/// GUIDed opcodes defined for EDKII implementation.
+///
+#define EFI_IFR_BITVARSTORE_GUID \
+  {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 0xA8, 0xFD, 0x60,0xA7, 0x1D}}
+
+///
+/// EDKII implementation extension flags, used to indaicate the disply style 
and bit width for bit filed storage.
+///
+#define EFI_IFR_DISPLAY_BIT0xC0
+#define EFI_IFR_DISPLAY_INT_DEC_BIT0x00
+#define EFI_IFR_DISPLAY_UINT_DEC_BIT   0x40
+#define EFI_IFR_DISPLAY_UINT_HEX_BIT   0x80
+
+#define EFI_IFR_NUMERIC_SIZE_BIT   0x3F
+
 #pragma pack()
 
 extern EFI_GUID gEfiIfrTianoGuid;
 extern EFI_GUID gEfiIfrFrameworkGuid;
+extern EFI_GUID gEfiIfrBitvarstoreGuid;
 
 #endif
 
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 593bff3..8ffc475 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -182,10 +182,14 @@
 
   ## Guid for EDKII implementation GUIDed opcodes
   #  Include/Guid/MdeModuleHii.h
   gEfiIfrTianoGuid  = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 
0x8c, 0x38, 0xaf, 0x48, 0xce }}
 
+  ## Guid for EDKII implementation GUIDed opcodes
+  #  Include/Guid/MdeModuleHii.h
+  gEfiIfrBitvarstoreGuid  = {0x82DDD68B, 0x9163, 0x4187, {0x9B, 0x27, 0x20, 
0xA8, 0xFD, 0x60,0xA7, 0x1D}}
+
   ## Guid for Framework vfr GUIDed opcodes.
   #  Include/Guid/MdeModuleHii.h
   gEfiIfrFrameworkGuid  = { 0x31ca5d1a, 0xd511, 0x4931, { 0xb7, 0x82, 0xae, 
0x6b, 0x2b, 0x17, 0x8c, 0xd7 }}
 
   ## Guid to specify the System Non Volatile FV
-- 
1.9.5.msysgit.1

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


[edk2] [RFC V2 3/5] MdeModulePkg/SetupBrowser: Handle questions with Bit VarStore

2017-05-27 Thread Dandan Bi
For oneof/numeric/CheckBox(storage can be Bit VarStore)
If we want question value can be updated and shown correctly
in UI page, we need do enhancements in following cases:
1. Parse the Ifr data to get the bit VarStore info correctly.
2. Set/get value to/from bit VarStore correctly.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c  | 140 -
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 108 +++-
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.h |   3 +
 .../Universal/SetupBrowserDxe/SetupBrowserDxe.inf  |   1 +
 4 files changed, 214 insertions(+), 38 deletions(-)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 6b3e5e0..0de1144 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -15,10 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include "Setup.h"
 
 UINT16   mStatementIndex;
 UINT16   mExpressionOpCodeIndex;
 EFI_QUESTION_ID  mUsedQuestionId;
+BOOLEAN  mQuestionReferBitVar = FALSE;
+
 extern LIST_ENTRY  gBrowserStorageList;
 /**
   Initialize Statement header members.
 
   @param  OpCodeData Pointer of the raw OpCode data.
@@ -57,10 +59,11 @@ CreateStatement (
 
   Statement->Signature = FORM_BROWSER_STATEMENT_SIGNATURE;
 
   Statement->Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
   Statement->OpCode  = (EFI_IFR_OP_HEADER *) OpCodeData;
+  Statement->QuestionReferToBitFields = FALSE;
 
   StatementHdr = (EFI_IFR_STATEMENT_HEADER *) (OpCodeData + sizeof 
(EFI_IFR_OP_HEADER));
   CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_ID));
   CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID));
 
@@ -1312,10 +1315,12 @@ ParseOpCodes (
   BOOLEAN InUnknownScope;
   UINT8   UnknownDepth;
   FORMSET_DEFAULTSTORE*PreDefaultStore;
   LIST_ENTRY  *DefaultLink;
   BOOLEAN HaveInserted;
+  UINT16  ByteWidth;
+  UINT16  BitWidth;
 
   SuppressForQuestion  = FALSE;
   SuppressForOption= FALSE;
   InScopeDisable   = FALSE;
   DepthOfDisable   = 0;
@@ -1978,47 +1983,103 @@ ParseOpCodes (
   ASSERT(CurrentStatement != NULL);
 
   CurrentStatement->Flags = ((EFI_IFR_ONE_OF *) OpCodeData)->Flags;
   Value = &CurrentStatement->HiiValue;
 
-  switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) {
-  case EFI_IFR_NUMERIC_SIZE_1:
-CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u8.MinValue;
-CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u8.MaxValue;
-CurrentStatement->Step= ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u8.Step;
-CurrentStatement->StorageWidth = (UINT16) sizeof (UINT8);
-Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
-break;
+  if (mQuestionReferBitVar) {
+mQuestionReferBitVar = FALSE;
+CurrentStatement->StorageBitWidth = CurrentStatement->Flags & 
EFI_IFR_NUMERIC_SIZE_BIT;
+CurrentStatement->QuestionReferToBitFields = TRUE;
+CurrentStatement->VarBitOffset = 
CurrentStatement->VarStoreInfo.VarOffset;
+CurrentStatement->VarStoreInfo.VarOffset = 
CurrentStatement->VarBitOffset / 8;
+BitWidth = CurrentStatement->VarBitOffset - 
(CurrentStatement->VarStoreInfo.VarOffset * 8) +  
CurrentStatement->StorageBitWidth;
+ByteWidth = BitWidth / 8;
+CurrentStatement->StorageWidth = (BitWidth % 8 == 0? ByteWidth: 
ByteWidth + 1);
+CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u32.MinValue;
+CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u32.MaxValue;
+CurrentStatement->Step= ((EFI_IFR_NUMERIC *) 
OpCodeData)->data.u32.Step;
+if (Operand == EFI_IFR_NUMERIC_OP) {
+  switch (CurrentStatement->StorageWidth) {
+case 1:
+  ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &= EFI_IFR_DISPLAY_BIT;
+  ((EFI_IFR_NUMERIC *) OpCodeData)->Flags >>= 2;
+  ((EFI_IFR_NUMERIC *) OpCodeData)->Flags |= 
EFI_IFR_TYPE_NUM_SIZE_8;
+  ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue = 
(UINT8)CurrentStatement->Minimum;
+  ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue = 
(UINT8)CurrentStatement->Maximum;
+  ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step = 
(UINT8)CurrentStatement->Step;
+  Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+  break;
+case 2:
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags &= EFI_IFR_DISPLAY_BIT;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->Flags >>= 2;
+ ((EFI_IFR_NUMERIC *) OpCodeData)->

[edk2] [RFC V2 5/5] MdeModulePkg/DriverSample: Add sample questions with bit VarStore

2017-05-27 Thread Dandan Bi
1.Construct EFI/Buffer 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 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../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 
 5 files changed, 268 insertions(+)

diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c 
b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index f103b9c..6bc3605 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -18,10 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #define DISPLAY_ONLY_MY_ITEM  0x0002
 
 CHAR16 VariableName[] = L"MyIfrNVData";
 CHAR16 MyEfiVar[] = L"MyEfiVar";
+CHAR16 MyBitVar[] = L"MyBitVar";
 EFI_HANDLE  DriverHandle[2] = {NULL, NULL};
 DRIVER_SAMPLE_PRIVATE_DATA  *mPrivateData = NULL;
 EFI_EVENT   mEvent;
 
 HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath0 = {
@@ -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 = Request;
 //
@@ -883,10 +888,13 @@ RouteConfig (
   // through hii database, not support in this path.
   //
   if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiVar)) 
{
 return EFI_UNSUPPORTED;
   }
+  if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyBitVar)) 
{
+return EFI_UNSUPPORTED;
+  }
 
   //
   // Get Buffer Storage data from EFI variable
   //
   BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
@@ -1292,10 +1300,14 @@ DriverCallback (
 for (Index = 0; Index < 3; Index ++) {
   SetArrayData (Value, EFI_IFR_TYPE_NUM_SIZE_8, Index, BufferValue--);
 }
   break;
 
+  case 0x:
+  Value->u8 = 12;
+break;
+
   default:
 Status = EFI_UNSUPPORTED;
   break;
   }
 }
@@ -1306,10 +1318,14 @@ DriverCallback (
   switch (QuestionId) {
   case 0x1240:
 Value->u8 = DEFAULT_CLASS_MANUFACTURING_VALUE;
   break;
 
+  case 0x:
+Value->u8 = 13;
+  break;
+
   default:
 Status = EFI_UNSUPPORTED;  
   break;
   }
 }
@@ -1683,10 +1699,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;
 
   //
   // Initialize the local variables.
@@ -1962,10 +1979,57 @@ DriverSampleInit (
   return EFI_INVALID_PARAMETER;
 }
   }
   FreePool (ConfigRequestHdr);
 
+  //
+  // Initialize Bits efi varstore configuration data
+  //
+  BitsVarStoreConfig = &mPrivateData->BitsVarStoreConfig;
+  ZeroMem (BitsVarStoreConfig, sizeof (MY_BITS_VARSTORE_DATA));
+
+  ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, 
MyBitVar, DriverHandle[0]);
+  ASSERT (ConfigRequestHdr != NULL);
+
+  BufferSize = sizeof (MY_BITS_VARSTORE_DATA);
+  Status = gRT->GetVariable (MyBitVar, &gDriverSampleFormSetGuid, NULL, 
&BufferSize, BitsVarStoreConfig);
+  if (EFI_ERROR (Status)) {
+//
+// Store zero data to EFI variable Storage.
+//
+Status = gRT->SetVariable(
+MyBitVar,
+&gDriverSampleFormSetGuid,
+EFI_VARIABLE_NON_VOLATILE | 
EFI_VARIABLE_BOOTSERVICE_ACCESS,
+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 variable
+// based on default values stored in IFR
+//
+ActionFlag = HiiSetToDefaults (ConfigRequestHdr, 
EFI_HII_DEFAULT_CLASS_STANDARD);
+if (!ActionFlag) {
+  DriverSampleUnload (ImageHandle);
+  return EFI_INVALID_PARAMETER;
+}
+  } else {
+//
+// EFI variable does exist and Vali

[edk2] [RFC V2 4/5] MdeModulePkg/HiiDatabase: Handle questions with Bit VarStore

2017-05-27 Thread Dandan Bi
For oneof/numeric/checkbox, their storage may be bit field.
When generating  string to get default value
for these questions, we need to parse the Ifr data to get
the bit Varstore info,and then generating the correct
 string.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../Universal/HiiDatabaseDxe/ConfigRouting.c   | 194 +++--
 .../Universal/HiiDatabaseDxe/HiiDatabase.h |   4 +
 .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf|   1 +
 3 files changed, 186 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index c9ff1cf..bf8296e 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -13,10 +13,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 
 #include "HiiDatabase.h"
 extern HII_DATABASE_PRIVATE_DATA mPrivate;
+BOOLEAN  mQuestionReferBitVar = FALSE;
 
 /**
   Calculate the number of Unicode characters of the incoming Configuration 
string,
   not including NULL terminator.
 
@@ -1223,19 +1224,19 @@ InsertBlockData (
   // Insert block data in its Offset and Width order.
   //
   for (Link = BlockLink->ForwardLink; Link != BlockLink; Link = 
Link->ForwardLink) {
 BlockArray = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
 if (BlockArray->Offset == BlockSingleData->Offset) {
-  if (BlockArray->Width > BlockSingleData->Width) {
+  if ((BlockArray->Width > BlockSingleData->Width) || 
(BlockSingleData->IsBitVar && BlockArray->Width == BlockSingleData->Width)) {
 //
 // Insert this block data in the front of block array
 //
 InsertTailList (Link, &BlockSingleData->Entry);
 return;
   }
 
-  if (BlockArray->Width == BlockSingleData->Width) {
+  if ((!BlockSingleData->IsBitVar) && BlockArray->Width == 
BlockSingleData->Width) {
 //
 // The same block array has been added.
 //
 if (BlockSingleData != BlockArray) {
   FreePool (BlockSingleData);
@@ -1991,20 +1992,25 @@ IsThisOpcodeRequired (
   IN IFR_BLOCK_DATA   *RequestBlockArray,
   IN EFI_HII_HANDLE   HiiHandle,
   IN OUT IFR_VARSTORAGE_DATA  *VarStorageData,
   IN EFI_IFR_OP_HEADER*IfrOpHdr,
   IN UINT16   VarWidth,
-  OUTIFR_BLOCK_DATA   **ReturnData
+  OUTIFR_BLOCK_DATA   **ReturnData,
+  IN BOOLEAN  IsBitVar
   )
 {
   IFR_BLOCK_DATA   *BlockData;
   UINT16   VarOffset;
   EFI_STRING_IDNameId;
   EFI_IFR_QUESTION_HEADER  *IfrQuestionHdr;
+  UINT16   BitOffset;
+  UINT16   BitWidth;
+  UINT16   BitVarWidth;
 
   NameId= 0;
   VarOffset = 0;
+  BitVarWidth = 0;
   IfrQuestionHdr = (EFI_IFR_QUESTION_HEADER  *)((CHAR8 *) IfrOpHdr + sizeof 
(EFI_IFR_OP_HEADER));
 
   if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) {
 NameId = IfrQuestionHdr->VarStoreInfo.VarName;
 
@@ -2016,11 +2022,19 @@ IsThisOpcodeRequired (
   // This question is not in the requested string. Skip it.
   //
   return EFI_NOT_FOUND;
 }
   } else {
-VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+if (IsBitVar) {
+   BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+   VarOffset = BitOffset / 8;
+   BitVarWidth = VarWidth;
+   BitWidth  = BitOffset - (VarOffset * 8) + BitVarWidth;
+   VarWidth  = (BitWidth % 8 == 0 ? BitWidth / 8: BitWidth / 8 + 1);
+} else {
+  VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+}
 
 //
 // Check whether this question is in requested block array.
 //
 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, 
HiiHandle)) {
@@ -2051,10 +2065,13 @@ IsThisOpcodeRequired (
 
   BlockData->Width  = VarWidth;
   BlockData->QuestionId = IfrQuestionHdr->QuestionId;
   BlockData->OpCode = IfrOpHdr->OpCode;
   BlockData->Scope  = IfrOpHdr->Scope;
+  BlockData->IsBitVar   = IsBitVar;
+  BlockData->BitOffset  = IfrQuestionHdr->VarStoreInfo.VarOffset;
+  BlockData->BitWidth   = BitVarWidth;
   InitializeListHead (&BlockData->DefaultValueEntry);
   //
   // Add Block Data into VarStorageData BlockEntry
   //
   InsertBlockData (&VarStorageData->BlockEntry, &BlockData);
@@ -2124,10 +2141,11 @@ ParseIfrData (
   EFI_HII_PACKAGE_HEADER   *PackageHeader;
   EFI_VARSTORE_ID  VarStoreId;
   UINT16   SmallestDefaultId;
   BOOLEAN  SmallestIdFromFlag;
   BOOLEAN  FromOtherDefaultOpcode;
+  BOOLEAN  IsBitVar;
 
   Status   = EFI_SUCCESS;
   BlockData= NULL;
   DefaultDataPtr   = NULL;
   FirstOneOfOption = FALSE;
@@ -2135,10 +2153,11 @@ ParseIfrData (
   First

[edk2] [RFC V2 0/5] Support Bit fields in EFI/Buffer VarStore

2017-05-27 Thread Dandan Bi
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;
  UINT8Field8;
  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,
  >024B: 5F 92 8B D6 DD 82 63 91 87 41 9B 27 20 A8 FD 60 A7 1D  (Guid 
opcode)
  >025D: 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,
  >0283: 5B 09 00 00 02 05 00 00 00 
  default = 6, defaultstore = MyManufactureDefault,
  >028C: 5B 09 01 00 02 06 00 00 00
  endnumeric;
  >0295: 29 02 (end of numeric opcode)
  >0297: 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 
Contribu

Re: [edk2] [edk2-BuildSpecification PATCH] Add EBNF for --pcd flag command line flag

2017-05-27 Thread Zhu, Yonghong
Hi Mike,

Some comment, please check it. thanks.
1. How about change the PcdValue as below since we also support the integer 
value.
::= {} {} {} {}
  ::= {} {}
::= {(0-9)} {(1-9)(0-9)+}

2. How about change HexNumber to support the upper case "0X" ?
::= {"0x"} {"0X"} (a-fA-F0-9){1,16}

3. No  definition. How about add this one ?
::= {"0x"} {"0X"} (a-fA-F0-9){1,2}

4. A typo error (it is INF, not INC) in sentence " command-line take precedence 
over PCD provided in DSC, FDF, INC, and DEC files".


Best Regards,
Zhu Yonghong

-Original Message-
From: Kinney, Michael D 
Sent: Saturday, May 27, 2017 12:41 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zhu, Yonghong ; 
Shaw, Kevin W 
Subject: [edk2-BuildSpecification PATCH] Add EBNF for --pcd flag command line 
flag

https://bugzilla.tianocore.org/show_bug.cgi?id=523

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Kinney 
---
 README.md   |  3 ++-
 appendix_d_buildexe_command/d4_usage.md | 29 +
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 16fcc4a..00fd89d 100644
--- a/README.md
+++ b/README.md
@@ -200,7 +200,7 @@ Copyright (c) 2008-2017, Intel Corporation. All rights 
reserved.
 || Remove Unicode file storage requirement; refer to the 
Multi-String UNI File Format Specification instead. 


  |   |
 || Clarify BUILDRULEORDER  



|   |
 || Add support for INF statement in an FD region.  



|   |
-| 1.27   | Convert to Gitbook  



| April 2017|
+| 1.27   | Convert to Gitbook  



| May 2017  |
 || [#471](https://bugzilla.tianocore.org/show_bug.cgi?id=471) 
Build spec: only copy the "TianoCore" Userextension section into "As Built" INF 


 |   |
 || [#472](https://bugzilla.tianocore.org/show_bug.cgi?id=472) 
[Build Spec] Extend macro usage in the !include statements for DSC/FDF files


 |   |
 || [#483](https://bugzilla.tianocore.org/show_bug.cgi?id=483) 
Build Spec: add description for merge Pre-build and Post-build into build 
process 

   |   |
@@ -212,3 +212,4 @@ Copyright (c) 2008-2017, Intel Corporation. All rights 
reserved.
 || [#504](https://bugzilla.tianocore.org/show_bug.cgi?id=504) 
Update build report to support -Y HASH option   


 |