]> git.proxmox.com Git - mirror_edk2.git/blob - PrmPkg/Include/PrmExportDescriptor.h
PrmPkg: Replace PcdPrmPlatformGuid with EDKII_DSC_PLATFORM_GUID
[mirror_edk2.git] / PrmPkg / Include / PrmExportDescriptor.h
1 /** @file
2
3 Definitions for the Platform Runtime Mechanism (PRM) export descriptor structures.
4
5 Copyright (c) Microsoft Corporation
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef PRM_EXPORT_DESCRIPTOR_H_
11 #define PRM_EXPORT_DESCRIPTOR_H_
12
13 #include <Prm.h>
14
15 #define PRM_MODULE_EXPORT_DESCRIPTOR_NAME PrmModuleExportDescriptor
16 #define PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE SIGNATURE_64 ('P', 'R', 'M', '_', 'M', 'E', 'D', 'T')
17 #define PRM_MODULE_EXPORT_REVISION 0x0
18
19 //
20 // Platform Runtime Mechanism (PRM) Export Descriptor Structures
21 //
22 #pragma pack(push, 1)
23
24 typedef struct {
25 GUID PrmHandlerGuid;
26 CHAR8 PrmHandlerName[PRM_HANDLER_NAME_MAXIMUM_LENGTH];
27 } PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT;
28
29 typedef struct {
30 UINT64 Signature;
31 UINT16 Revision;
32 UINT16 NumberPrmHandlers;
33 GUID PlatformGuid;
34 GUID ModuleGuid;
35 } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER;
36
37 typedef struct {
38 PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header;
39 PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[1];
40 } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT;
41
42 #pragma pack(pop)
43
44 #if defined(_MSC_VER)
45 #define PRM_PACKED_STRUCT(definition) \
46 __pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop))
47 #elif defined (__GNUC__) || defined (__clang__)
48 #define PRM_PACKED_STRUCT(definition) \
49 typedef struct __attribute__((packed)) definition
50 #endif
51
52 /**
53 A macro that declares a PRM Handler Export Descriptor for a PRM Handler.
54
55 This macro is intended to be used once per PRM Handler to describe the handler when the
56 module description is defined. It should be provided as an argument to PRM_MODULE_EXPORT.
57
58 @param Guid The GUID of the PRM Handler being exported.
59
60 @param Name The name of the PRM Handler being exported. This string should exactly
61 match the function name.
62
63 **/
64 #define PRM_HANDLER_EXPORT_ENTRY(Guid, Name) \
65 { \
66 Guid, \
67 PRM_STRING_(Name) \
68 } \
69
70 /**
71 A macro that returns the count of the number of variable-length arguments given.
72
73 @param VariableArgumentList A variable argument list of elements that will be included
74 in the return value of the list count.
75 **/
76 #define VA_ARG_COUNT(...) (sizeof((PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT[]){__VA_ARGS__})/sizeof(PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT))
77
78 /**
79 A macro that declares the PRM Module Export Descriptor for a PRM Module.
80
81 This macro is intended to be used once in a PRM Module after all of the PRM Handler definitions
82 to describe the PRM Handlers being exported in the module.
83
84 @param PrmHandlerExportEntries A variable argument list of PRM_HANDLER_EXPORT_ENTRY values.
85 This list should include all PRM Handlers being exported by
86 this module.
87
88 **/
89 #define PRM_MODULE_EXPORT(...) \
90 PRM_PACKED_STRUCT( \
91 { \
92 PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header; \
93 PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[VA_ARG_COUNT(__VA_ARGS__)]; \
94 } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ \
95 ); \
96 \
97 PRM_EXPORT_API PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ PRM_MODULE_EXPORT_DESCRIPTOR_NAME = { \
98 { \
99 PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE, \
100 PRM_MODULE_EXPORT_REVISION, \
101 VA_ARG_COUNT(__VA_ARGS__), \
102 EDKII_DSC_PLATFORM_GUID, \
103 EFI_CALLER_ID_GUID \
104 }, \
105 { __VA_ARGS__ } \
106 } \
107
108 #endif