Skip to content

Commit 8d6637b

Browse files
author
Yonghong Zhu
committed
Expression spec: update format to support flexible Pcd format
Cc: Liming Gao <[email protected]> Cc: Michael Kinney <[email protected]> Cc: Kevin W Shaw <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <[email protected]> Reviewed-by: Liming Gao <[email protected]>
1 parent 8227eba commit 8d6637b

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

2_expression_overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ directives section do not apply.
102102
13. For the Conditional Operator, the first operand must be scalar, while the
103103
second and third operands must have the same type (i.e., both being scalar,
104104
both being integers, or both being string literals).
105+
106+
14. Array format like "{0x10, 0x20}" can't be a operand of any operator except
107+
Relational and equality operators.

3_expression_format.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ GRACEFULLY._
9595
<HexDigit> ::= (a-fA-F0-9)
9696
<HexPrefix> ::= {"0x"} {"0X"}
9797
<GuidValue> ::= {<RformatGuid>} {<CformatGuid>}
98+
<UINT8> ::= <HexPrefix> (\x0 - \xFF)
99+
<UINT16> ::= <HexPrefix> (\x0 - \xFFFF)
100+
<UINT32> ::= <HexPrefix> (\x0 - \xFFFFFFFF)
101+
<UINT64> ::= <HexPrefix> (\x0 - \xFFFFFFFFFFFFFFFF)
102+
<ShortNum> ::= (0-255)
103+
<IntNum> ::= (0-65535)
104+
<LongNum> ::= (0-4294967295)
105+
<LongLongNum> ::= (0-18446744073709551615)
106+
<GuidStr> ::= "GUID(" <GuidVal> ")"
107+
<GuidVal> ::= {<DblQuote> <RformatGuid> <DblQuote>}
108+
{<CformatGuid>} {<CName>}
98109
Rhex2 ::= [<HexDigit>] <HexDigit>
99110
Rhex4 ::= [<HexDigit>] [<HexDigit>] Rhex2
100111
Rhex8 ::= [<HexDigit>] [<HexDigit>] [<HexDigit>] [<HexDigit>] Rhex4
@@ -113,15 +124,38 @@ Rghex12 ::= <HexDigit> <HexDigit> <HexDigit> <HexDigit> Rghex8
113124
<Part3> ::= <Byte> <CSP> <Byte> <CSP> <Byte> <CSP> <Part4>
114125
<Part4> ::= <Byte> <CSP> <Byte> <CSP> <Byte> <CSP> <Part5>
115126
<Part5> ::= <Byte> [<TSP>]* "}" [<TSP>]* "}"
116-
<Array> ::= {<EmptyArray>} {<Array>}
127+
<Array> ::= {<EmptyArray>} {<NonEmptyArray>}
117128
<EmptyArray> ::= "{" <TSP>* "}"
118-
<ByteArray> ::= "{" <TSP>* <Byte> [<CSP> <Byte>]* "}"
129+
<NonEmptyArray> ::= "{" <TSP>* [<Lable>] <ArrayVal>
130+
[<CSP> [<Lable>] <ArrayVal>]* "}"
131+
<ArrayVal> ::= {<Num8Array>} {<GuidStr>} {<DevicePath>}
132+
<DevicePath> ::= "DEVICE_PATH(" <DevicePathStr> ")"
133+
<DevicePathStr> ::= A double quoted string that follow the device path
134+
as string format defined in UEFI Specification 2.6
135+
Section 9.6
136+
<Lable> ::= "LABEL(" <CName> ")"
137+
<Offset> ::= "OFFSET_OF(" <CName> ")"
119138
<StringLiteral> ::= {<QuotedString>} {"L" <QuotedString>}
139+
{<SglQuotedString>} {"L" <SglQuotedString>}
120140
<DblQuote> ::= 0x22
141+
<SglQuote> ::= 0x27
121142
<QuotedString> ::= <DblQuote> [<CCHAR>]* <DblQuote>
143+
<SglQuotedString> ::= <SglQuote> [<CCHAR>]* <SglQuote>
122144
<CCHAR> ::= {<SingleChars>} {<EscapeCharSeq>}
123-
<SingleChars> ::= {0x20} {0x21} {(0x23 - 0x5B)} {(0x5D - 0x7E)}
124-
<EscapeCharSeq> ::= "\" {"n"} {"r"} {"t"} {"f"} {"b"} {"0"} {"\"} {<DblQuote>}
145+
<SingleChars> ::= {0x21} {(0x23 - 0x26)} {(0x28 - 0x5B)}
146+
{(0x5D - 0x7E)} {<EscapeSequence>}
147+
<EscapeCharSeq> ::= "\" {"n"} {"r"} {"t"} {"f"} {"b"} {"0"} {"\"}
148+
{<DblQuote>} {<SglQuote>}
149+
<NonNumType> ::= {<TrueFalse>} {<StringLiteral>} {<Offset>} {<UintMac>}
150+
<Num8Array> ::= {<NonNumType>} {<ShortNum>} {<UINT8>}
151+
<Num16Array> ::= {<NonNumType>} {<IntNum>} {<UINT16>}
152+
<Num32Array> ::= {<NonNumType>} {<LongNum>} {<UINT32>}
153+
<Num64Array> ::= {<NonNumType>} {<LongLongNum>} {<UINT64>}
154+
<UintMac> ::= {<Uint8Mac>} {<Uint16Mac>} {<Uint32Mac>} {<Uint64Mac>}
155+
<Uint8Mac> ::= "UINT8(" <Num8Array> ")"
156+
<Uint16Mac> ::= "UINT16(" <Num16Array> ")"
157+
<Uint32Mac> ::= "UINT32(" <Num32Array> ")"
158+
<Uint64Mac> ::= "UINT64(" <Num64Array> ")"
125159
<PostFixExpression> ::= {<PrimaryExpression>} {<PcdName>}
126160
<PcdName> ::= <CName> "." <CName>
127161
<UnaryExpression> ::= {<PostFixExpression>} {<UnaryOp> <UnaryExpression>}
@@ -189,9 +223,15 @@ This is the value of the MACRO assigned in a DEFINE statement.
189223

190224
**Expressions**
191225

192-
If the "|" character is used in an expression, the expression must be
226+
If the "|" or "||"character is used in an expression, the expression must be
193227
encapsulated by parenthesis.
194228

229+
**OFFSET_OF()**
230+
231+
LABEL() macro in byte arrays to tag the byte offset of a location in a byte
232+
array. OFFSET_OF() macro in byte arrays that returns the byte offset of a
233+
LABEL() declared in a byte array.
234+
195235
## 3.2 Conditional Directive Expressions
196236

197237
Conditional directive statements are defined in the EDK II Platform Description

0 commit comments

Comments
 (0)