2.1 Introduction
Each EDK II Package is a container that includes a set of modules and their related definitions. Each Package is an EDK II distribution unit. It can be used to manage and release the big project to facilitate a user's distribution and reuse. Entire project sources can be split into different packages to reduce the release granularity. The new project can also be made from released packages from different sources.

2.1.1 EDK II Packages

A Package is a directory that organizes a group of modules with a single package declaration file (DEC).
EDK II provides UEFI and PI compliant packages: MdePkg, MdeModulePkg, etc.
The MdePkg contains the complete definitions in EFI1.1, UEFI2.0, UEFI2.1, PI1.0
Specifications and all library classes and instances defined in EDK II MDE (Module Development Environment) Library Specification. UEFI and PI drivers can be developed based solely on this package.
The MdeModulePkg contains a group of cross-platform drivers that conform to UEFI and PI specifications. They can be referred to when developing new UEFI and PI drivers.
Detailed information of EDK II packages can be found in EDK II User Guide, section 2.2 and in the package specification for each package.

2.1.2 The Package Directory

Each package has a unified directory structure that separate the different source files. The root directories in each package are: Include, Library, Application and Drivers.
  • The include directory contains all public header files that are exposed by this package and are used by this package and other packages. Below the Include directory, subdirectories may be created to include Ppi, Protocol, Guid, Industry Standard and library class header files (when these header files become public).
  • The library directory contains directories for each library instance module included.
  • The application directory contains directories for each UEFI applications module included.
  • The driver directory contains directories for each driver group and for each driver.
Each module (library instance, application and driver) has its own directory in which to group its source files. A module may only depend on files under its directory or on public header files. A module is not permitted to depend on source files from another module directory.

2.1.2.1 Sample directories and sub-directories in a package

  • Package.dec Package declaration file
  • Package.dsc Platform Package build description file
  • Include Public header files
    • Protocol Public Protocol header files o Ppi Public PPI header files o Guid Public GUID header files
    • IndustryStandard Public Industry Standard header files o Library Public Library class header files
  • Library Libraries instances
    • NameOneLib Library instance NameOne source files and INF o NameTwoLib\
      Library instance NameTwo source files and INF
  • Application Uefi Applications o NameOneApp Application NameOne source files and INF o NameTwoApp Application NameTwo source files and INF  NameOneDxe Dxe Driver NameOne source files and INF.
  • NameTwoPei Pei Driver NameTwo source files and INF.
If no related source files exist in a package, the corresponding directory may not be created. For example, if no application is provided in a package, a blank Application directory is not required.

2.1.3 Package Declaration File

Each package has a single package declaration file (DEC) to define the package's public interfaces. The public interfaces are the package's public header files, GUIDs, and PCDs.
The DEC has Defines, Includes, LibraryClasses, Guids, Ppis, Protocols and Pcds sections.
The [Defines] section defines the package name and package GUID.
The [Includes] section must list the root directory of public header file directory.
The [LibraryClasses] section contains every library class header file in the Package\Include\Library directory.
The [Guids] section specifies the Guid value for each Guid in the Package\Include\Guid directory.
The [Ppis] section specifies the Guid value for each PPI in the Package\Include\Ppi directory.
The [Protocols] section specifies the Guid for each Protocol in the Package\Include\Protocol directory.
The PCDs are declared in different PCD sections according to their type (FeatureFlag, FixedAtBuild, PatchableInModule, Dynamic, and DynamicEx). If a PCD supports multiple PCD types, it must be declared in all supported type sections. When a PCD is declared, its data type and default value must also be specified.
The following is a sample DEC file, additional package public information may be added.

2.1.3.1 Example: Package.dec

1
[Defines]
2
DEC_SPECIFICATION = 0x00010005
3
PACKAGE_NAME = PackageName
4
PACKAGE_GUID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
5
PACKAGE_VERSION = 0.1
6
7
[Includes]
8
Include #Package Include directory
9
10
[LibraryClasses]
11
## Library class name is same to library header file name
12
OneClassLib|Include/Library/OneClassLib.h
13
14
[Guids]
15
16
#GuidCName = {xxxxxxxx,xxxx,xxxx,{xx,xx,xx,xx,xx,xx,xx,xx}},
17
[Ppis]
18
19
#PpiGuidCName = {xxxxxxxx,xxxx,xxxx,{xx,xx,xx,xx,xx,xx,xx,xx}},
20
[Protocols]
21
22
#ProtocolGuidCName = {xxxxxxxx,xxxx,xxxx,{xx,xx,xx,xx,xx,xx,xx,xx}},
23
[PcdsFeatureFlag] #FeatureFlag PCD is BOOLEAN type, the value is TRUR or FALSE.
24
25
#PcdTokenSpaceCGuidName.PcdName|TRUE|BOOLEAN|TokenNumber
26
#PcdTokenSpaceCGuidName.PcdName|FALSE|BOOLEAN|TokenNumber
27
[PcdsFixedAtBuild]
28
29
#PcdTokenSpaceCGuidName.PcdName|DefaultValue|DataType|TokenNumber
30
[PcdsPatchableInModule]
31
32
#PcdTokenSpaceCGuidName.PcdName|DefaultValue|DataType|TokenNumber
33
[PcdsDynamic]
34
35
#PcdTokenSpaceCGuidName.PcdName|DefaultValue|DataType|TokenNumber
36
[PcdsDynamicEx]
37
#PcdTokenSpaceCGuidName.PcdName|DefaultValue|DataType|TokenNumber
Copied!
Refer to the EDK II DEC File Specification for a detailed description of the DEC file format.

2.1.4 Package DSC File

Each package usually creates another build description file (DSC). All modules can be added into DSC to be compiled and verified. DSC has the following sections:
  • Defines
  • LibraryClass
  • PCD
  • Components.
The [Defines] section sets build related information, such as the build output directory, build target, Guid, and build ARCHs.
The [Components] section lists all modules (Drivers, Application, and Library Instances) in the platform.
The [LibraryClasses] section specifies the chosen library instance for every library class, which is consumed by the drivers and applications in the [Components] section.
The [PCDs] section configures PCD type and value for those PCDs used by the modules in the [Components] section. If the PCD value is same as the default value in DEC, and the PCD type has no specific requirement, the PCD may not be configured in the DSC. Its value and type will be the default setting in DEC. If all PCDs are not required in the DSC file, the [PCDs] section may be not created.
Note: Only the DSC file for the active platform is used in a build.
The following is a sample DSC file. More modules may be added.

2.1.4.1 Example: Package.dsc

1
[Defines]
2
PLATFORM_NAME = PacakgeName
3
PLATFORM_GUID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
4
PLATFORM_VERSION = 0.1
5
DSC_SPECIFICATION = 0x00010005
6
OUTPUT_DIRECTORY = Build/PackageName
7
SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC
8
BUILD_TARGETS = DEBUG|RELEASE
9
SKUID_IDENTIFIER = DEFAULT
10
11
[SkuIds] 0|DEFAULT #The entry: 0|DEFAULT is reserved and required.
12
13
[LibraryClasses]
14
## More library instances need to be added if more library classes are used
15
## by the components in the following [Components] section.
16
## library class name | library instance INF file path from package
17
DebugLib | MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
18
BaseLib | MdePkg/Library/BaseLib/BaseLib.inf
19
BaseMemoryLib | MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
20
......
21
22
##PCDs sections are not specified.
23
##All PCDs value are from their Default value in DEC.
24
##[PcdsFeatureFlag]
25
##[PcdsFixedAtBuild]
26
[Components]
27
# All libraries, drivers and applications are added here to be compiled
28
#
29
# Module INF file path are specified from package directory.
30
PackageNamePkg/Library/NameOneLib/NameOneLib.inf
31
PackageNamePkg/NameOneDxe/NameOneDxe.inf
32
PackageNamePkg/NameTwoPei/NameTwoPei.inf
Copied!
A detailed description of the DSC file form is given in the DSC Specification.
Last modified 1yr ago