[edk2] [Patch] INF 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)
There is a newer version of this series
.../32_component_inf_definition.md                 | 71 +++++++++++++++++-----
3_edk_ii_inf_file_format/38_pcd_sections.md        | 39 +++++++-----
2 files changed, 79 insertions(+), 31 deletions(-)
[edk2] [Patch] INF 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>
---
 .../32_component_inf_definition.md                 | 71 +++++++++++++++++-----
 3_edk_ii_inf_file_format/38_pcd_sections.md        | 39 +++++++-----
 2 files changed, 79 insertions(+), 31 deletions(-)

diff --git a/3_edk_ii_inf_file_format/32_component_inf_definition.md b/3_edk_ii_inf_file_format/32_component_inf_definition.md
index 72bcf2c..7af9072 100644
--- a/3_edk_ii_inf_file_format/32_component_inf_definition.md
+++ b/3_edk_ii_inf_file_format/32_component_inf_definition.md
@@ -111,15 +111,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
@@ -137,15 +138,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" <Major> <Minor>
 <Major>              ::= <HexDigit>? <HexDigit>? <HexDigit>?
@@ -181,14 +183,14 @@ The following are common definitions used by multiple section types.
 <Number>              ::= {<Integer>} {<HexNumber>}
 <HexNz>               ::= (\x1 - \xFFFFFFFFFFFFFFFF)
 <NumNz>               ::= (1-18446744073709551615)
 <GZ>                  ::= {<NumNz>} {<HexNz>}
 <TRUE>                ::= {"TRUE"} {"true"} {"True"} {"0x1"} {"0x01"} {"1"}
-                          {<GZ>}
 <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>
@@ -209,14 +211,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"}
@@ -233,10 +266,18 @@ The following are common definitions used by multiple section types.
                           {"SMM_CORE"} {"DXE_SMM_DRIVER"}
                           {"UEFI_DRIVER"} {"UEFI_APPLICATION"}
 ```
 
 **********
+**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 INF file, provided they follow
 the rules that a comment may not be enclosed within Section headers, and that
@@ -252,14 +293,14 @@ in line comments must appear at the end of a statement.
 Expression syntax is defined the _EDK II Expression Syntax Specification_.
 
 **_Unicode String_**
 
 When the `<UnicodeString>` element (these characters are string literals as
-defined by the C99 specification: L"string", not actual Unicode characters) is
-included in a value, the build tools may be required to expand the ASCII string
-between the quotation marks into a valid UCS-2 character encoded string. The
-build tools parser must treat all content between the field separators
+defined by the C99 specification: L"string"/L'string', not actual Unicode
+characters) is included in a value, the build tools may be required to expand
+the ASCII string between the quotation marks into a valid UCS-2 character encoded
+string. The build tools parser must treat all content between the field separators
 (excluding white space characters around the field separators) as ASCII literal
 content when generating the `AutoGen.c` and `AutoGen.h` files.
 
 **_Comments_**
 
diff --git a/3_edk_ii_inf_file_format/38_pcd_sections.md b/3_edk_ii_inf_file_format/38_pcd_sections.md
index cef87a8..82636d5 100644
--- a/3_edk_ii_inf_file_format/38_pcd_sections.md
+++ b/3_edk_ii_inf_file_format/38_pcd_sections.md
@@ -124,34 +124,41 @@ content.
 <ValuePcd>            ::= <TS> <PcdName> <FS> <ValUse>
 <ValUse>              ::= <AsBuiltValue> <TailCmt>
 <ValueOffsetPcd>      ::= [<NUsageBlock>]
                           <TS> <PcdName> <FS> <ValOffUse>
 <ValOffUse>           ::= <AsBuiltValue> <Offset> <TailCmt>
-<Offset>              ::= <FS> <NumValUint32>
+<Offset>              ::= <FS> {<LongNum>} {<UINT32>}
 <AsBuiltByteArray>    ::= "{" <NList> "}"
 <AsBuiltValue>        ::= if (pcddatumtype == "BOOLEAN"):
-                          {"0x00"} {"0x01"} elif (pcddatumtype == "UINT8"):
-                          <UINT8z> elif (pcddatumtype == "UINT16"):
-                          <UINT16z> elif (pcddatumtype == "UINT32"): <UINT32z>
+                            {"0x00"} {"0x01"} 
+                          elif (pcddatumtype == "UINT8"):
+                            <UINT8z> 
+                          elif (pcddatumtype == "UINT16"):
+                            <UINT16z>
+                          elif (pcddatumtype == "UINT32"): 
+                            <UINT32z>
                           elif (pcddatumtype == "UINT64"):
-                          <UINT64z> else:
-                          <AsBuiltByteArray>
+                            <UINT64z> 
+                          else:
+                            <AsBuiltByteArray>
 <PcdEntries>          ::= [<NUsageBlock>]
                           <TS> <PcdName> [<PField1>] <TailCmt>
 <PField1>             ::= <FS> [<Value>] [<FFE>]
 <Value>               ::= if (pcddatumtype == "BOOLEAN"):
-                          <Boolean> elif (pcddatumtype == "UINT8"):
-                          <NumValUint8> elif (pcddatumtype == "UINT16"):
-                          <NumValUint16> elif (pcddatumtype == "UINT32"):
-                          <NumValUint32> elif (pcddatumtype == "UINT64"):
-                          <NumValUint64> else:
-                          <StringVal>
-<StringVal>           ::= {<StringType>} {<CArray>}
-<StringType>          ::= {<UnicodeString>} {<CString>}
+                            <Boolean>
+                          elif (pcddatumtype == "UINT8"):
+                            {<NumValUint8>} {<Expression>}
+                          elif (pcddatumtype == "UINT16"):
+                            {<NumValUint16>} {<Expression>}
+                          elif (pcddatumtype == "UINT32"):
+                            {<NumValUint32>} {<Expression>}
+                          elif (pcddatumtype == "UINT64"):
+                            {<NumValUint64>} {<Expression>}
+                          else:
+                            {<StringVal>} {<Expression>}
 <FFE>                 ::= <FS> <FeatureFlagExpress>
-                          <1
-UsageBlock>           ::= <CommentBlock>
+<1UsageBlock>         ::= <CommentBlock>
 <NUsageBlock>         ::= <CommentBlock>+
 <FeatureFlagExpress>  ::= <Boolean>
 <CommentBlock>        ::= <TS> ["##" <TS> <Usage>] <TS> <CmtOrEol>
 <CmtOrEol>            ::= {<Comment>} {<EOL>}
 <Usage>               ::= {"CONSUMES"} {"SOMETIMES_CONSUMES"}
-- 
2.6.1.windows.1

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