diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2020-04-22 18:06:23 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-04-05 00:42:38 +0000 |
commit | a6f8946bc9d1155030fa84f327ac1cbb00a20061 (patch) | |
tree | c8defbe1afe24c60afe6248e0223c7730ca30b48 /PrmPkg/Include | |
parent | e846797662bd968cf9bf67ff04957ad80e5a9c6c (diff) | |
download | edk2-a6f8946bc9d1155030fa84f327ac1cbb00a20061.tar.gz |
PrmPkg: Enable variable growth for the PRM_MODULE_EXPORT macro
The PRM_MODULE_EXPORT parameterized macro allows a caller to produce
a static PRM module export descriptor structure in the binary by
simply passing PRM_HANDLER_EXPORT_ENTRY arguments with each argument
representing a PRM handler to be exported by the module.
Previously, the PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT used in the
PRM_MODULE_EXPORT macro was fixed to a maximum of three handlers.
This change removes that restriction and allows the structure to
grow based on the number of PRM handlers given to the macro. This
means a local type will be customized per PRM module. The reference
type PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT keeps a field at the end
that allows array access to PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT
members.
Cc: Andrew Fish <afish@apple.com>
Cc: Kang Gao <kang.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Liu Yun <yun.y.liu@intel.com>
Cc: Ankit Sinha <ankit.sinha@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Ankit Sinha <ankit.sinha@intel.com>
Diffstat (limited to 'PrmPkg/Include')
-rw-r--r-- | PrmPkg/Include/PrmExportDescriptor.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/PrmPkg/Include/PrmExportDescriptor.h b/PrmPkg/Include/PrmExportDescriptor.h index 95198cef65..fc313fd1ac 100644 --- a/PrmPkg/Include/PrmExportDescriptor.h +++ b/PrmPkg/Include/PrmExportDescriptor.h @@ -31,11 +31,23 @@ typedef struct { UINT16 Revision;
UINT16 NumberPrmHandlers;
GUID ModuleGuid;
- PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[3];
+} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER;
+
+typedef struct {
+ PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header;
+ PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[1];
} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT;
#pragma pack(pop)
+#if defined(_MSC_VER)
+ #define PRM_PACKED_STRUCT(definition) \
+ __pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop))
+#elif defined (__GNUC__) || defined (__clang__)
+ #define PRM_PACKED_STRUCT(definition) \
+ typedef struct __attribute__((packed)) definition
+#endif
+
/**
A macro that declares a PRM Handler Export Descriptor for a PRM Handler.
@@ -73,8 +85,15 @@ typedef struct { this module.
**/
-#define PRM_MODULE_EXPORT(...) \
- PRM_EXPORT_API PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT PRM_MODULE_EXPORT_DESCRIPTOR_NAME = { \
+#define PRM_MODULE_EXPORT(...) \
+ PRM_PACKED_STRUCT( \
+ { \
+ PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header; \
+ PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[VA_ARG_COUNT(__VA_ARGS__)]; \
+ } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ \
+ ); \
+ \
+ PRM_EXPORT_API PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_ PRM_MODULE_EXPORT_DESCRIPTOR_NAME = { \
{ \
PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE, \
PRM_MODULE_EXPORT_REVISION, \
|