15. Dependency Expression Grammar
15.1. Dependency Expression Grammar
This topic contains an example BNF grammar for a DXE driver dependency expression compiler that converts a dependency expression source file into a dependency section of a DXE driver stored in a firmware volume.
15.2. Example Dependency Expression BNF Grammar
<depex> ::= BEFORE <guid>
| AFTER <guid>
| SOR <bool>
| <bool>
<bool> ::= <bool> AND <term>
| <bool> OR <term>
| <term>
<term> ::= NOT <factor>
| <factor>
<factor> ::= <bool>
| TRUE
| FALSE
| GUID
| END
<guid> ::= ‘{‘ <hex32> ‘,’ <hex16> ‘,’ <hex16> ‘,’
<hex8> ‘,’ <hex8> ‘,’ <hex8> ‘,’ <hex8> ‘,’
<hex8> ‘,’ <hex8> ‘,’ <hex8> ‘,’ <hex8> ’}’
<hex32> ::= <hexprefix> <hexvalue>
<hex16> ::= <hexprefix> <hexvalue>
<hex8> ::= <hexprefix> <hexvalue>
<hexprefix> ::= ‘0’ ‘x’
| ‘0’ ‘X’
<hexvalue> ::= <hexdigit> <hexvalue>
| <hexdigit>
<hexdigit> ::= [0-9]
| [a-f]
| [A-F]
15.3. Sample Dependency Expressions
The following contains three examples of source statements using the BNF grammar from above along with the opcodes, operands, and binary encoding that a dependency expression compiler would generate from these source statements.
//
// Source
//
EFI_CPU_IO_PROTOCOL_GUID AND EFI_CPU_ARCH_PROTOCOL_GUID END
//
// Opcodes, Operands, and Binary Encoding
//
ADDR BINARY MNEMONIC
==== =========================
===============================================
0x00 : 02 PUSH
0x01 : 26 25 73 b0 c8 38 40 4b EFI_CPU_IO_PROTOCOL_GUID
88 77 61 c7 b0 6a ac 45
0x11 : 02 PUSH
0x12 : b1 cc ba 26 42 6f d4 11 EFI_CPU_ARCH_PROTOCOL_GUID
bc e7 00 80 c7 3c 88 81
0x22 : 03 AND
0x23 : 08 END
//
// Source
//
AFTER (EFI_CPU_DRIVER_FILE_NAME_GUID) END
//
// Opcodes, Operands, and Binary Encoding
//
ADDR BINARY MNEMONIC
==== =======================
===============================================
0x00 : 01 AFTER
0x01 : 93 e5 7b 98 43 16 0b 45 EFI_CPU_DRIVER_FILE_NAME_GUID
be 4f 8f 07 66 6e 36 56
0x11 : 08 END
//
// Source
//
SOR EFI_CPU_IO_PROTOCOL_GUID END
//
// Opcodes, Operands and Binary Encoding
//
ADDR BINARY MNEMONIC
==== =======================
===============================================
0x00 : 09 SOR
0x01 : 02 PUSH
0x02 : b1 cc ba 26 42 6f d4 11 EFI_CPU_IO_PROTOCOL_GUID
bc e7 00 80 c7 3c 88 81
0x12 : 03 END