-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Protocol Stack
In the C-based code provided, a PROTOCOL_STACK acts as a common ground for the host and application for sharing data. This is particularly useful for configuring another application based on the data provided.
Struct: PROTOCOL
struct PROTOCOL
{
GUID Guid;
UINT16 Revision;
UINT8 DataFlags;
UINT8 Reserved;
UINT32 DataLength;
CHAR8 Data[0];
};Each protocol is identified by a unique guideline identifier GUID.
The Revision value ensures that each new version of a protocol is backward compatible.
DataFlags is used to set specific flags for the data.
The Reserved value is kept for future use and must be 0.
The DataLength field is the length of data payload followed by the actual Data.
Struct: PROTOCOL_STACK
struct PROTOCOL_STACK
{
UINTN Count;
CHAR8 Protocols[0];
};The PROTOCOL_STACK holds the count and list of protocols the host has provided to the application.
API Prototypes
Several utility functions are provided for work with protocol stack:
PrintProtocolStack: Prints the protocol stack.IterateProtocolStack: Iteratively accesses each protocol within the stack.GetProtocol: Retrieves a specific protocol based on the given GUID.GetProtocolData: Retrieves the data of a specific protocol based on the given GUID.
Implementation Use
The protocol stack is being used in the main function as a means to facilitate data synchronization between the host and the application. Three protocols are defined:
COMMAND_LINE_PROTOCOL_GUID: This Protocol captures the command line arguments.ENVIRONMENT_VARIABLE_PROTOCOL_GUID: This Protocol captures the environment variables.APPLICATION_IMAGE_PROTOCOL_GUID: This protocol holds information about the image of the application.
The Protocols are iteratively added to the Protocol stack in the main implementation. The data for each Protocol is then accessed, interpreted and used based on its GUID.
Future Utilization
The PROTOCOL structure has a reserved field which might be used for an additional layer of functionality or information in the future. As the protocol and its stack revolves around the host-application data transfer architecture, its future would highly depend on how such an architecture evolves. It can be extended to incorporate new types of data communication paradigms or configurations as the communication needs between application and host evolve.