This article describes how to create a new protocol or PPI definition in SecureCore-Tiano or AwardCore-Tiano. It assumes you already know the name and definition of the protocol or PPI, but just need to know where to put it and what files to create.
- For each protocol, there should be one header file and one source file. The header file contains the protocol definition, the protocol GUID definition, the extern to the GUID declaration, and any related data structures and constants. The source file contains the GUID declaration and the GUID description.
- The name of the source file, the name of the header file, the name of the variable for the GUID declaration and the directory name where the source and header file are located are all derived from the protocol's "shortcut" name. The "shortcut" name is derived from the protocol's name, as follows:
A. Each protocol name is composed of "segments" separated by the '_' character. In the shortcut name, each segment starts with a capital letter and all subsequent letters are lower-case.
B. All '_' characters are removed.
C. "Phoenix" is abbreviated as "Ph"
Here are some examples.
|
Protocol Name |
Shortcut Name |
|
PHOENIX_SW_SMI_PROTOCOL |
PhSwSmiProtocol |
|
EFI_ACPI_TABLE_PROTOCOL |
EfiAcpiTableProtocol |
|
EFI_SMM_BASE_PROTOCOL |
EfiSmmBaseProtocol |
- Now, using this shortcut, you can create the EFI GUID in the protocol's header and source file.
A. In the header file, the GUID extern appears at the end, just before the #endif:
extern EFI_GUID g<shortcut>Guid;
For example:
extern EFI_GUID gPhSwSmiProtocolGuid;
B. In the source file, the GUID definition appears at the end of the file:
EFI_GUID g<shortcut>Guid = <protocol-name>_GUID;
EFI_GUID_DEFINITION(&<shortcut>Guid,"<shortcut>",\
"long protocol description");
For example:
EFI_GUID gPhSwSmiProtocolGuid = \
PHOENIX_SW_SMI_PROTOCOL_GUID;
EFI_GUID_DEFINITION(&gPhSwSmiProtocolGuid,"Software SMI Allocator",\
"Phoenix Software SMI Command Value Allocator");
- There is a second form of the shortcut ("shortcut2") which is used for the file and directory names. Starting with the "shortcut" name, do the following:
A. Remove the segment "Protocol" or "Ppi" from the end.
B. Remove the segment "Efi" from the beginning. If "Efi" was followed by "Dxe" or "Pei", remove that segment also.
For example:
|
Shortcut |
Shortcut Name |
|
PhSwSmiProtocol |
PhSwSmi |
|
EfiAcpiTableProtocol |
AcpiTable |
|
EfiSmmBaseProtocol |
SmmBase |
- Now use this "shortcut2" to create the directory and file name, as follows:
A. The header file will have the name <shortcut2>.h
B. The source file will have the name <shortcut2>.c or <shortcut2>.cpp
C. The directory will have the name <shortcut2>
- For protocols, the directory will be placed in the "Protocol" library in the component. Typical locations are:
Phoenix\Core\Protocol\<shortcut2>
Phoenix\Core\Efi\Protocol\<shortcut2>
Phoenix\Feature\feature-name\Protocol\<shortcut2>
Silicon\vendor\[component-type\]component-name\Protocol\<shortcut2>
- For PPIs, the rules are similar, except that "PPI" replaces Protocol, as follows:
Phoenix\Core\Ppi\<shortcut2>
Phoenix\Core\Efi\Ppi\<shortcut2>
Phoenix\Feature\feature-name\Ppi\<shortcut2>
Silicon\vendor\[component-type\]component-name\Ppi\<shortcut2>
- The INF file for the library that contains these directories must be updated to include the source and header file in the [sources.common] section. For example:
PhSwSmiProtocol\PhSwSmiProtocol.c
PhSwSmiProtocol\PhSwSmiProtocol.h
- The name of the library, the name of the header file and the name of the GUID should be in your functional specification.
- You can find many places where older files do not follow this rule. There are many reasons for this. Just follow these rules! They make it easier for everyone to find the definitions they are looking for.