Skip to content

Commit 782dc33

Browse files
committed
edk II C Coding Standard: Updates 4.2 and 4.3 sections
Updates 4.2 Directory names and 4.3 file names for the guidelines of module directory and file naming. PR: https://github.com/tianocore-docs/edk2-CCodingStandardsSpecification/pull/2/files Signed-off-by: Abner Chang <[email protected]> Cc: Ray Ni <[email protected]> Cc: Michael D Kinney <[email protected]> Cc: Sunil V L <[email protected]> Cc: Abdul Lateef Attar <[email protected]> Cc: Leif Lindholm <[email protected]> Acked-by: Sunil V L <[email protected]> Reviewed-by: Abdul Lateef Attar<[email protected]> Reviewed-by: Ray Ni <[email protected]>
1 parent bda6c02 commit 782dc33

File tree

2 files changed

+209
-1
lines changed

2 files changed

+209
-1
lines changed

4_naming_conventions/42_directory_names.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
4.2 Directory Names
33
44
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
5+
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
56
67
Redistribution and use in source (original document form) and 'compiled'
78
forms (converted to PDF, epub, HTML and other formats) with or without
@@ -28,3 +29,103 @@
2829
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2930
3031
-->
32+
33+
## 4.2 Directory Names
34+
Below sections are the directory naming guidelines for EDK II modules. The guidelines are not
35+
just considering the uniformity of directory naming, but they also provide the flexibility of
36+
directory name construction for the scenario of different EDK II module designs; such as the
37+
support for multiple processor architectures and vendors. It may require further discussions
38+
between EDK II maintainers and contributors in order to determine the best naming of the EDK II
39+
module directory.
40+
41+
#### 4.2.1 EDKII package directory
42+
43+
```
44+
<PackageName>Pkg
45+
46+
<PackageName> REQUIRED *
47+
```
48+
49+
#### 4.2.2 EDKII Module directory
50+
51+
* The guideline below is applied to all CPU architectures support, specific CPU architecture and vendors support, or the implementation is shared by certain CPU archs:
52+
```
53+
<Feature><Phase>[<CpuArch>[<Vendor>]]
54+
or
55+
<Feature><Phase>[/<CpuArch>[/<Vendor>]]
56+
57+
<Feature> REQUIRED *
58+
<Phase> REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm, StandaloneMm, Smm,
59+
Uefi.
60+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
61+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
62+
'LoongArch64' | 'Ebc'
63+
<CpuArch> ::= <arch>[<arch>]*
64+
65+
Example: Ia32X64Arm or RiscV64LoongArch64
66+
67+
<Vendor> OPTIONAL *
68+
69+
Example:
70+
- SmbiosDxe/
71+
- CpuDxe/ # First implementation of CpuDxe.
72+
- CpuDxeIa32X64Amd/ # Ia32 and X64 AMD specific implementation.
73+
- CpuDxe/RiscV64/ # RiscV64 specific implementation.
74+
/ # Common files for the RiscV64 and other archs.
75+
- CpuDxe/Ia32X64/Amd/ # Ia32 and X64 AMD specific implementation.
76+
/ # Common files for Ia32 and X64 archs.
77+
/ArmAArch64/ # Arm and AArch64 implementation of CpuDxe.
78+
/ # Common files for the Arm, AArch64, Ia32 and X64.
79+
```
80+
81+
* If the implementation does not have any shared code between phases (e.g.
82+
MdeModulePkg/Universal/PCD). The guideline below is applied to all CPU architectures support, specific CPU architecture and vendors support, or the implementation is shared by certain CPU architectures:
83+
84+
```
85+
<Feature>/<Phase>[/<CpuArch>[/<Vendor>]]
86+
87+
<Feature> REQUIRED *
88+
<Phase> REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm, StandaloneMm, Smm,
89+
Uefi.
90+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
91+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
92+
'LoongArch64' | 'Ebc'
93+
<CpuArch> ::= <arch>[<arch>]*
94+
95+
Example: Ia32X64Arm or RiscV64LoongArch64
96+
<Vendor> OPTIONAL *
97+
Example:
98+
Pcd/Dxe/
99+
```
100+
101+
#### 4.2.2 EDKII Library directory
102+
```
103+
<Phase>[<CpuArch>[<Vendor>]]<LibraryClassName>[<Dependency>]
104+
or
105+
<Phase><LibraryClassName>[<Dependency>]/[<CpuArch>[/<Vendor>]]
106+
107+
<Phase> REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm,
108+
StandaloneMm, Smm, Uefi.
109+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
110+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
111+
'LoongArch64' | 'Ebc'
112+
<CpuArch> ::= <arch>[<arch>]*
113+
114+
Example: Ia32X64Arm or RiscV64LoongArch64
115+
<Vendor> OPTIONAL *
116+
<LibraryClassName> REQUIRED *
117+
<Dependency> OPTIONAL * (Typically name of PPI, Protocol, LibraryClass
118+
that the implementation is layered on top of).
119+
120+
Example:
121+
- BaseXApicLib/
122+
- SmmIa32X64AmdSmmCpuFeaturesLib/
123+
- SmmArmAArch64SmmCpuFeaturesLib/
124+
- BaseMpInitLib/RiscV64/ # RiscV64 specific implementation.
125+
/Ia32X64/ # Ia32 and X64 specific implementation.
126+
/Ia32X64/Amd # Ia32 and X64 AMD specific implementation.
127+
/ArmAArch64/ # Arm and AAch64 specific implementation.
128+
/LoongArch64/ # LoongArch64 specific implementation.
129+
/ # Common files for RiscV64, Ia32, X64, Arm, AArch64 and
130+
LoongArch64.
131+
```

4_naming_conventions/43_file_names.md

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!--- @file
22
4.3 File Names
33
4-
Copyright (c) 2006-2017, Intel Corporation. All rights reserved.<BR>
4+
Copyright (c) 2006-2022, Intel Corporation. All rights reserved.<BR>
5+
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
56
67
Redistribution and use in source (original document form) and 'compiled'
78
forms (converted to PDF, epub, HTML and other formats) with or without
@@ -58,3 +59,109 @@ regular expression:
5859

5960
That is, a letter followed by zero, or more, letters, underscores, dashes, or
6061
digits followed by a period followed by one or more letters or digits.
62+
63+
### 4.3.5 File naming guidelines for modules
64+
65+
Below sections are the file naming guidelines for EDK II meta files and source files. The
66+
guidelines are not just considering the the uniformity of file naming, but it also provides
67+
the flexibility of file name construction for the scenario of different EDK II module
68+
designs; such as the support for multiple processor architectures and vendors. It may require the
69+
further discussions between EDK II maintainers and contributors in order to determine the best
70+
naming of the EDK II module file.
71+
72+
#### 4.3.5.1 EDK II meta files within a package
73+
74+
```
75+
<PackageName>Pkg.dec
76+
<PackageName>Pkg.dsc
77+
78+
<PackageName> REQUIRED *
79+
```
80+
81+
#### 4.3.5.2 EDK II INF file within a Module instance
82+
* If the implementation is for all CPU architectures, specific CPU architectures, CPU vendors or the implementation is shared by certain CPU archs:
83+
```
84+
<Feature><Phase>[<CpuArch>][<Vendor>].inf
85+
86+
<Feature> REQUIRED *
87+
<Phase> REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm, StandaloneMm,
88+
Smm, Uefi.
89+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
90+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
91+
'LoongArch64' | 'Ebc'
92+
<CpuArch> ::= <arch>[<arch>]*
93+
94+
Example: Ia32X64Arm or RiscV64LoongArch64
95+
<Vendor> OPTIONAL *
96+
97+
Example:
98+
- SmbiosDxe.inf
99+
- CpuIo2Dxe.inf
100+
- CpuIo2DxeAmd.inf
101+
- CpuIo2DxeIa32X64.inf
102+
- CpuIo2DxeIa32X64Intel.inf
103+
```
104+
105+
* If the implementation does not have any shared code between phases (e.g., Pcd/Dxe):
106+
107+
```
108+
[<Feature>][<CpuArch>][<Vendor>].inf
109+
110+
<Feature> OPTIONAL *
111+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
112+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
113+
'LoongArch64' | 'Ebc'
114+
<CpuArch> ::= <arch>[<arch>]*
115+
116+
Example: Ia32X64Arm or RiscV64LoongArch64
117+
<Vendor> OPTIONAL *
118+
Example:
119+
Pcd.inf
120+
```
121+
122+
#### 4.3.5.3 EDK II INF file within a Library instance
123+
```
124+
<Phase>[<CpuArch>][<Vendor>]<LibraryClassName>[<Dependency>].inf
125+
<Phase> REQUIRED Base, Sec, Pei, Dxe, DxeRuntime, Mm,
126+
StandaloneMm, Smm, Uefi.
127+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
128+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
129+
'LoongArch64' | 'Ebc'
130+
<CpuArch> ::= <arch>[<arch>]*
131+
132+
Example: Ia32X64Arm or RiscV64LoongArch64
133+
<Vendor> OPTIONAL *
134+
<LibraryClassName> REQUIRED *
135+
<Dependency> OPTIONAL * (Typically name of PPI, Protocol, LibraryClass
136+
that the implementation is layered on top of)
137+
138+
Example:
139+
- SmmAmdSmmCpuFeaturesLib.inf
140+
- SmmIa32X64SmmCpuFeaturesLib.inf
141+
```
142+
143+
#### 4.3.5.4 EDK II source files within a Library/Module instance
144+
145+
In generally, the file name is constructed as below:
146+
```
147+
148+
[<CpuArch>][<Vendor>]<FileName>.*
149+
150+
<CpuArch> OPTIONAL The <CpuArch> is represented with a BNF,
151+
<arch> ::='Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |
152+
'LoongArch64' | 'Ebc'
153+
<CpuArch> ::= <arch>[<arch>]*
154+
155+
Example: Ia32X64Arm or RiscV64LoongArch64
156+
<Vendor> OPTIONAL *
157+
<FileName> REQUIRED Refer to 4.3.1 to 4.3.4 sections for the file
158+
naming format.
159+
160+
Example:
161+
SmmCpuFeatureLib.c
162+
SmmCpuFeatureLibCommon.c
163+
Ia32X64SmmCpuFeaturesLib.c
164+
Ia32X64IntelSmmCpuFeaturesLib.c
165+
AmdSmmCpuFeaturesLib.c
166+
167+
```

0 commit comments

Comments
 (0)