[edk2] [Patch] FDF spec: Add flexible PCD value format into spec

Yonghong Zhu posted 1 patch 6 years, 9 months ago
Failed in applying to current master (apply log)
2_fdf_design_discussion/24_[fd]_sections.md       |  6 ---
2_fdf_design_discussion/25_[fv]_sections.md       |  6 ---
2_fdf_design_discussion/26_[capsule]_sections.md  |  6 ---
3_edk_ii_fdf_file_format/32_fdf_definition.md     | 62 +++++++++++++++++++----
3_edk_ii_fdf_file_format/34_[defines]_section.md  |  4 +-
3_edk_ii_fdf_file_format/35_[fd]_sections.md      |  9 ++--
3_edk_ii_fdf_file_format/36_[fv]_sections.md      |  2 +-
3_edk_ii_fdf_file_format/37_[capsule]_sections.md |  2 +-
8 files changed, 60 insertions(+), 37 deletions(-)
[edk2] [Patch] FDF spec: Add flexible PCD value format into spec
Posted by Yonghong Zhu 6 years, 9 months ago
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Kevin W Shaw <kevin.w.shaw@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 2_fdf_design_discussion/24_[fd]_sections.md       |  6 ---
 2_fdf_design_discussion/25_[fv]_sections.md       |  6 ---
 2_fdf_design_discussion/26_[capsule]_sections.md  |  6 ---
 3_edk_ii_fdf_file_format/32_fdf_definition.md     | 62 +++++++++++++++++++----
 3_edk_ii_fdf_file_format/34_[defines]_section.md  |  4 +-
 3_edk_ii_fdf_file_format/35_[fd]_sections.md      |  9 ++--
 3_edk_ii_fdf_file_format/36_[fv]_sections.md      |  2 +-
 3_edk_ii_fdf_file_format/37_[capsule]_sections.md |  2 +-
 8 files changed, 60 insertions(+), 37 deletions(-)

diff --git a/2_fdf_design_discussion/24_[fd]_sections.md b/2_fdf_design_discussion/24_[fd]_sections.md
index d55b793..2e1facb 100644
--- a/2_fdf_design_discussion/24_[fd]_sections.md
+++ b/2_fdf_design_discussion/24_[fd]_sections.md
@@ -155,16 +155,10 @@ The following is an example of the `SET` statement:
 `SET gFlashDevicePkgTokenSpaceGuid.PcdEfiMemoryMapped = TRUE`
 
 The `VALUE` specified must match the PCD's datum type and must be the content
 data.
 
-For a PCD that has a datum type of `VOID`*, the data can be a Unicode string,
-as in `L"text"`, a valid C data array (it must be either a C format GUID or a
-hex byte array), as in `{0x20, 0x01, 0x50, 0x00, 0x32, 0xFF, 0x00, 0xAA, {0xFF, 0xF0, 0x00, 0x00, 0x00}}.`
-For other PCD datum types, the value may be a boolean or a hex value, as in
-`0x0000000F,` with a value that is consistent with the PCD's datum type.
-
 The value may also be a macro or it may be computed, using arithmetic
 operations, arithmetic expressions and or logical expressions. The value
 portion of the `SET` statement, when using any of these computations are in-fix
 expressions that are evaluated left to right, with items within parenthesis
 evaluated before the outer expressions are evaluated. Use of parenthesis is
diff --git a/2_fdf_design_discussion/25_[fv]_sections.md b/2_fdf_design_discussion/25_[fv]_sections.md
index 7b50017..343e252 100644
--- a/2_fdf_design_discussion/25_[fv]_sections.md
+++ b/2_fdf_design_discussion/25_[fv]_sections.md
@@ -130,16 +130,10 @@ The following is an example of the `SET` statement:
 `SET gEfiMyTokenSpaceGuid.PcdDisableOnboardVideo = TRUE`
 
 The `VALUE` specified must match the Pcd's datum type and must be the content
 data.
 
-For a PCD that has a datum type of `VOID`*, the data can be a Unicode string,
-as in `L"text"`, a valid C data array (it must be either a C format GUID or a
-hex byte array), as in `{0x20, 0x00, 0x20, 0x00, 0x32, 0xFF, 0x00, 0xAA, {0xFF, 0xF0, 0x00, 0x00, 0x00}}.`
-Other PCD datum types are either boolean values or a hex value, as in
-`0x0000000F`, with a value that is consistent with the PCD's datum type
-
 The value may also be a macro or it may be computed, using arithmetic
 operations, arithmetic expressions and or logical expressions. The value
 portion of the `SET` statement, when using any of these computations are in-fix
 expressions that are evaluated left to right, with items within parenthesis
 evaluated before the outer expressions are evaluated. Use of parenthesis is
diff --git a/2_fdf_design_discussion/26_[capsule]_sections.md b/2_fdf_design_discussion/26_[capsule]_sections.md
index ba93268..d0b956a 100644
--- a/2_fdf_design_discussion/26_[capsule]_sections.md
+++ b/2_fdf_design_discussion/26_[capsule]_sections.md
@@ -97,16 +97,10 @@ The following is an example of the `SET` statement.
 `SET gEfiMyTokenSpaceGuid.PcdSecStartLocalApicTimer = TRUE`
 
 The `VALUE` specified must match the PCD's datum type and must be the content
 data.
 
-For a PCD that has a datum type of `VOID`*, the data can be a Unicode string,
-as in `L"text"`, a valid C data array (it must be either a C format GUID or a
-hex Byte array), as in `{0x20002000, 0x32FF, 0x00AA, {0xFF, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xEF, 0x1A, 0x55}}.`
-Other PCD datum types are either boolean values or a hex value, as in
-`0x0000000F`, with a value that is consistent with the PCD's datum type.
-
 ### 2.6.3 Capsule Data
 
 `EFI_CAPSULE_DATA` follows the `EFI_CAPSULE_HEADER` token definitions in the
 `[Capsule]` section or sub-sections. The content consists of one or more files,
 FD UiName, FV UiName or the following.
diff --git a/3_edk_ii_fdf_file_format/32_fdf_definition.md b/3_edk_ii_fdf_file_format/32_fdf_definition.md
index 1379db4..0eb9108 100644
--- a/3_edk_ii_fdf_file_format/32_fdf_definition.md
+++ b/3_edk_ii_fdf_file_format/32_fdf_definition.md
@@ -96,15 +96,16 @@ The following are common definitions used by multiple section types.
 <Digit>                ::= (0-9)
 <NonDigit>             ::= (a-zA-Z_)
 <Identifier>           ::= <NonDigit> <Chars>*
 <CName>                ::= <Identifier> # A valid C variable name.
 <AsciiChars>           ::= (0x21 - 0x7E)
-<CChars>               ::= [{0x21} {(0x23 - 0x5B)} {(0x5D - 0x7E)}
-                           {<EscapeSequence>}]*
+<CChars>               ::= [{0x21} {(0x23 - 0x26)} {(0x28 - 0x5B)}
+                           {(0x5D - 0x7E)} {<EscapeSequence>}]*
 <DblQuote>             ::= 0x22
+<SglQuote>             ::= 0x27
 <EscapeSequence>       ::= "\" {"n"} {"t"} {"f"} {"r"} {"b"} {"0"}
-                           {"\"} {<DblQuote>}
+                           {"\"} {<DblQuote>} {<SglQuote>}
 <TabSpace>             ::= {<Tab>} {<Space>}
 <TS>                   ::= <TabSpace>*
 <MTS>                  ::= <TabSpace>+
 <Tab>                  ::= 0x09
 <Space>                ::= 0x20
@@ -122,15 +123,16 @@ The following are common definitions used by multiple section types.
 <AsciiString>          ::= [ <TS>* <AsciiChars>* ]*
 <EmptyString>          ::= <DblQuote> <DblQuote>
 <CFlags>               ::= <AsciiString>
 <PrintChars>           ::= {<TS>} {<CChars>}
 <QuotedString>         ::= <DblQuote> <PrintChars>* <DblQuote>
-<CString>              ::= ["L"] <QuotedString>
+<SglQuotedString>      ::= <SglQuote> <PrintChars>* <SglQuote>
+<CString>              ::= {<QuotedString>} {<SglQuotedString>}
 <NormalizedString>     ::= <DblQuote> [{<Word>} {<Space>}]+ <DblQuote>
 <GlobalComment>        ::= <WS> "#" [<AsciiString>] <EOL>+
 <Comment>              ::= "#" <AsciiString> <EOL>+
-<UnicodeString>        ::= "L" <QuotedString>
+<UnicodeString>        ::= "L" {<QuotedString>} {<SglQuotedString>}
 <HexDigit>             ::= (a-fA-F0-9)
 <HexByte>              ::= {"0x"} {"0X"} [<HexDigit>] <HexDigit>
 <HexNumber>            ::= {"0x"} {"0X"} <HexDigit>+
 <HexVersion>           ::= "0x" [0]* <Major> <Minor>
 <Major>                ::= <HexDigit>? <HexDigit>? <HexDigit>?
@@ -169,11 +171,12 @@ The following are common definitions used by multiple section types.
 <NumNz>                ::= (1-18446744073709551615)
 <GZ>                   ::= {<NumNz>} {<HexNz>}
 <TRUE>                 ::= {"TRUE"} {"true"} {"True"} {"0x1"}
                            {"0x01"} {"1"}
 <FALSE>                ::= {"FALSE"} {"false"} {"False"} {"0x0"} {"0x00"} {"0"}
-<BoolType>             ::= {<TRUE>} {<FALSE>}
+<BoolVal>              ::= {<TRUE>} {<FALSE>}
+<BoolType>             ::= {<BoolVal>} {"{"<BoolVal>"}"}
 <MACRO>                ::= (A-Z)(A-Z0-9_)*
 <MACROVAL>             ::= "$(" <MACRO> ")"
 <PcdName>              ::= <TokenSpaceGuidCName> "." <PcdCName>
 <PcdCName>             ::= <CName>
 <TokenSpaceGuidCName>  ::= <CName>
@@ -195,14 +198,45 @@ The following are common definitions used by multiple section types.
                            <HexDigit> <HexDigit>
 <ShortNum>             ::= (0-255)
 <IntNum>               ::= (0-65535)
 <LongNum>              ::= (0-4294967295)
 <LongLongNum>          ::= (0-18446744073709551615)
-<NumValUint8>          ::= {<ShortNum>} {<UINT8>}
-<NumValUint16>         ::= {<IntNum>} {<UINT16>}
-<NumValUint32>         ::= {<LongNum>} {<UINT32>}
-<NumValUint64>         ::= {<LongLongNum>} {<UINT64>}
+<ValUint8>             ::= {<ShortNum>} {<UINT8>} {<BoolVal>}
+                           {<CString>} {<UnicodeString>}
+<ValUint16>            ::= {<IntNum>} {<UINT16>} {<BoolVal>}
+                           {<CString>} {<UnicodeString>}
+<ValUint32>            ::= {<LongNum>} {<UINT32>} {<BoolVal>}
+                           {<CString>} {<UnicodeString>}
+<ValUint64>            ::= {<LongLongNum>} {<UINT64>} {<BoolVal>}
+                           {<CString>} {<UnicodeString>}
+<NumValUint8>          ::= {<ValUint8>} {"{"<ValUint8>"}"}
+<NumValUint16>         ::= {<ValUint16>}
+                           {"{"<ValUint16> [<CommaSpace> <ValUint16>]*"}"}
+<NumValUint32>         ::= {<ValUint32>}
+                           {"{"<ValUint32> [<CommaSpace> <ValUint32>]*"}"}
+<NumValUint64>         ::= {<ValUint64>}
+                           {"{"<ValUint64> [<CommaSpace> <ValUint64>]*"}"}
+<StringVal>            ::= {<UnicodeString>} {<CString>} {<Array>}
+<Array>                ::= "{"[<Lable>] <ArrayVal> 
+                            [<CommaSpace> [<Lable>] <ArrayVal>]*"}"
+<ArrayVal>             ::= {<NumArray>} {<GuidStr>} {<DevicePath>} 
+<NumArray>             ::= {<BoolVal>} {<Number>} {<UnicodeString>} {<CString>}
+                           {<Offset>} {<UintMac>}
+<GuidStr>              ::= "GUID(" <GuidVal> ")"
+<GuidVal>              ::= {<DblQuote> <RegistryFormatGUID> <DblQuote>}
+                           {<CFormatGUID>} {<CName>}
+<DevicePath>           ::= "DEVICE_PATH(" <DevicePathStr> ")"
+<DevicePathStr>        ::= A double quoted string that follow the device path
+                           as string format defined in UEFI Specification 2.6
+                           Section 9.6
+<UintMac>              ::= {<Uint8Mac>} {<Uint16Mac>} {<Uint32Mac>} {<Uint64Mac>}
+<Uint8Mac>             ::= "UINT8(" <NumArray> ")"
+<Uint16Mac>            ::= "UINT16(" <NumArray> ")"
+<Uint32Mac>            ::= "UINT32(" <NumArray> ")"
+<Uint64Mac>            ::= "UINT64(" <NumArray> ")"
+<Lable>                ::= "LABEL(" <CName> ")"
+<Offset>               ::= "OFFSET_OF(" <CName> ")"
 <ModuleType>           ::= {"BASE"} {"SEC"} {"PEI_CORE"} {"PEIM"}
                            {"DXE_CORE"} {"DXE_DRIVER"} {"SMM_CORE"}
                            {"DXE_RUNTIME_DRIVER"} {"DXE_SAL_DRIVER"}
                            {"DXE_SMM_DRIVER"} {"UEFI_DRIVER"}
                            {"UEFI_APPLICATION"} {"USER_DEFINED"}
@@ -231,10 +265,18 @@ The following are common definitions used by multiple section types.
                            {"256K"} {"512K"} {"1M"} {"2M"} {"4M"} {"8M"}
                            {"16M"}
 ```
 
 **********
+**Note:** When using CString, UnicodeString or byte array format as
+UINT8/UINT16/UINT32/UINT64 values, please make sure they fit in the
+target type's size, otherwise tool would report failure.
+**********
+**Note:** LABEL() macro in byte arrays to tag the byte offset of a
+location in a byte array. OFFSET_OF() macro in byte arrays that returns
+the byte offset of a LABEL() declared in a byte array.
+**********
 **Note:** When using the characters "|" or "||" in an expression, the
 expression must be encapsulated in open "(" and close ")" parenthesis.
 **********
 **Note:** Comments may appear anywhere within a FDF file, provided they follow
 the rules that a comment may not be enclosed within Section headers, and that
diff --git a/3_edk_ii_fdf_file_format/34_[defines]_section.md b/3_edk_ii_fdf_file_format/34_[defines]_section.md
index 7011db8..5bbb890 100644
--- a/3_edk_ii_fdf_file_format/34_[defines]_section.md
+++ b/3_edk_ii_fdf_file_format/34_[defines]_section.md
@@ -60,12 +60,12 @@ Conditional statements may be used anywhere within this section.
                  [<TS> "FDF_VERSION" <Eq> <DecimalVersion> <EOL>] <DefStmts>*
 <DefStmts>   ::= {<MacroDefinition>} {<SetStmts>} {<IncludeStatement>}
 <UiNameType> ::= <AsciiString>
 <SpecVer>    ::= {<HexVersion>} {(0-9)+ "." (0-9)+}
 <SetStmts>   ::= <TS> "SET" <MTS> <PcdName> <Eq> [<VALUE>] <EOL>
-<VALUE>      ::= {<Number>} {<Boolean>} {<GUID>} {<CArray>}
-                 {<CString>} {<UnicodeString>} {<Expression>}
+<VALUE>      ::= {<Number>} {<BoolVal>} {<Array>} {<UnicodeString>}
+                 {<CString>} {<Expression>}
 ```
 
 #### Parameters
 
 **_Expression_**
diff --git a/3_edk_ii_fdf_file_format/35_[fd]_sections.md b/3_edk_ii_fdf_file_format/35_[fd]_sections.md
index 6c87ebd..8558e7e 100644
--- a/3_edk_ii_fdf_file_format/35_[fd]_sections.md
+++ b/3_edk_ii_fdf_file_format/35_[fd]_sections.md
@@ -65,11 +65,11 @@ Conditional statements may be used anywhere within this section.
 <SetPcd>           ::= <FS> <PcdName>
 <BlockStatements>  ::= <TS> "BlockSize" <Eq> <UINT32> [<SetPcd>]
                        <EOL>
                        [<TS> "NumBlocks" <Eq> <UINT32> <EOL>]
 <SetStatements>    ::= <TS> "SET" <PcdName> <Eq> <VALUE> <EOL>
-<VALUE>            ::= {<Number>} {<Boolean>} {<GUID>} {<CArray>}
+<VALUE>            ::= {<Number>} {<BoolVal>} {<Array>}
                        {<CString>} {<UnicodeString>} {<Expression>}
 <RegionLayout>     ::= <TS> <Offset> <FS> <Size> <EOL>
                        [<TS> <PcdOffset> [<FS> <PcdSize>] <EOL>]
                        [<RegionType>]
 <Offset>           ::= {<HexNumber>} {<Expression>}
@@ -149,14 +149,13 @@ in this the file.
 The `FvUiName` must be specified in a `[FV]` section header defined in this the
 file.
 
 **_PcdValue_**
 
-The PCD Value may be a specific numeric value, an array of numeric bytes, a
-GUID, a quoted string, an L quoted string (representing a unicode string), an
-arithmetic expression, a logic expression or a macro from a previously defined
-macro statement.
+The PCD Value may be a specific numeric value, an byte array, a quoted
+string, an L quoted string (representing a unicode string), an expression
+or a macro from a previously defined macro statement.
 
 **_Expression_**
 
 Refer to the EDK II Expression Syntax Specification for more information.
 
diff --git a/3_edk_ii_fdf_file_format/36_[fv]_sections.md b/3_edk_ii_fdf_file_format/36_[fv]_sections.md
index b4f292a..63e877e 100644
--- a/3_edk_ii_fdf_file_format/36_[fv]_sections.md
+++ b/3_edk_ii_fdf_file_format/36_[fv]_sections.md
@@ -85,11 +85,11 @@ Conditional statements may be used anywhere within this section.
 <GlobalStmts>       ::= {<MacroDefinition>} {<IncludeStatement>}
 <BlockStatements>   ::= <FixedBlocks>
 <FixedBlocks>       ::= [<TS> "BlockSize" <Eq> <UINT32> <EOL>]
                         [<TS> "NumBlocks" <Eq> <UINT32> <EOL>]
 <SetStatements>     ::= <TS> "SET" <MTS> <PcdName> <Eq> <VALUE> <EOL>
-<VALUE>             ::= {<Number>} {<Boolean>} {<GUID>} {<CArray>}
+<VALUE>             ::= {<Number>} {<BoolVal>} {<Array>}
                         {<CString>} {<UnicodeString>} {<Expression>}
 <FvAlignment>       ::= [<TS> "FvBaseAddress" <Eq> <UINT64> <EOL>]
                         [<TS> "FvForceRebase" <Eq> <TrueFalse> <EOL>]
                         <TS> "FvAlignment" <Eq>
                         <FvAlignmentValues> <EOL>
diff --git a/3_edk_ii_fdf_file_format/37_[capsule]_sections.md b/3_edk_ii_fdf_file_format/37_[capsule]_sections.md
index 6606d56..673cb37 100644
--- a/3_edk_ii_fdf_file_format/37_[capsule]_sections.md
+++ b/3_edk_ii_fdf_file_format/37_[capsule]_sections.md
@@ -48,11 +48,11 @@ Conditional statements may be used anywhere within this section.
 <Capsule>           ::= "[Capsule" <UiCapsuleName> "]" <EOL>
                         <UefiTokens>
                         <CapsuleStmts>*
 <UiCapsuleName>     ::= "." <Word>
 <SetStatements>     ::= <TS> "SET" <MTS> <PcdName> <Eq> <VALUE> <EOL>
-<VALUE>             ::= {<Number>} {<Boolean>} {<GUID>} {<CArray>}
+<VALUE>             ::= {<Number>} {<BoolVal>} {<Array>}
                         {<CString>} {<UnicodeString>} {<Expression>}
 <UefiTokens>        ::= <TS> "CAPSULE_GUID" <Eq> <GuidValue> <EOL>
                         [<TS> "CAPSULE_HEADER_SIZE" <Eq> <Bytes> <EOL>] [<TS>
                         "CAPSULE_FLAGS" <Eq> <Flags> <EOL>]
                         [<TS> "CAPSULE_HEADER_INIT_VERSION" <Eq> <Hex2> <EOL>]
-- 
2.6.1.windows.1

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