diff --git a/ArmPkg/ArmPkg.ci.yaml b/ArmPkg/ArmPkg.ci.yaml
index f896608234..2da2d92455 100644
--- a/ArmPkg/ArmPkg.ci.yaml
+++ b/ArmPkg/ArmPkg.ci.yaml
@@ -84,7 +84,10 @@
## options defined .pytool/Plugin/LibraryClassCheck
"LibraryClassCheck": {
- "IgnoreHeaderFile": []
+ "IgnoreHeaderFile": [
+ "Include/Library/ArmMmHandlerContext.h"
+ ],
+ "skip": True
},
## options defined .pytool/Plugin/SpellCheck
diff --git a/ArmPkg/Include/Library/ArmMmHandlerContext.h b/ArmPkg/Include/Library/ArmMmHandlerContext.h
new file mode 100644
index 0000000000..291e4a2e57
--- /dev/null
+++ b/ArmPkg/Include/Library/ArmMmHandlerContext.h
@@ -0,0 +1,119 @@
+/** @file
+ Define ArmMmHandlerContext passed to MmHandler in Arm platform.
+
+ Copyright (c) 2025, Arm Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef ARM_MM_HANDLER_CONTEXT_H_
+#define ARM_MM_HANDLER_CONTEXT_H_
+
+/*
+ * Communication ABI protocol to communicate between normal/secure partition.
+ */
+typedef enum {
+ /// Unknown Communication ABI protocol
+ CommProtocolUnknown,
+
+ /// Communicate via SPM_MM ABI protocol
+ CommProtocolSpmMm,
+
+ /// Communicate via FF-A ABI protocol
+ CommProtocolFfa,
+
+ CommProtocolMax,
+} COMM_PROTOCOL;
+
+/** When using FF-A ABI, there are ways to request service to StandaloneMm
+ - FF-A with MmCommunication protocol.
+ - FF-A service with each specification.
+ MmCommunication Protocol can use FFA_MSG_SEND_DIRECT_REQ or REQ2,
+ Other FF-A services should use FFA_MSG_SEND_DIRECT_REQ2.
+ In case of FF-A with MmCommunication protocol via FFA_MSG_SEND_DIRECT_REQ,
+ register x3 saves Communication Buffer with gEfiMmCommunication2ProtocolGuid.
+ In case of FF-A with MmCommunication protocol via FFA_MSG_SEND_DIRECT_REQ2,
+ register x2/x3 save gEfiMmCommunication2ProtocolGuid and
+ register x4 saves Communication Buffer with Service Guid.
+
+ Other FF-A services (ServiceTypeMisc) delivers register values according to
+ there own service specification.
+ That means it doesn't use MmCommunication Buffer with MmCommunication Header
+ format.
+ (i.e) Tpm service via FF-A or Firmware Update service via FF-A.
+ To support latter services by StandaloneMm, it defines SERVICE_TYPE_MISC.
+ So that StandaloneMmEntryPointCore.c generates MmCommunication Header
+ with delivered register values to dispatch service provided StandaloneMmCore.
+ So that service handler can get proper information from delivered register.
+
+ In case of SPM_MM Abi, it only supports MmCommunication service.
+ */
+typedef enum {
+ /// Unknown
+ ServiceTypeUnknown,
+
+ /// MmCommunication services
+ ServiceTypeMmCommunication,
+
+ /// Misc services
+ ServiceTypeMisc,
+
+ ServiceTypeMax,
+} SERVICE_TYPE;
+
+/** Direct message request/response version
+ */
+typedef enum {
+ /// Direct message version 1. Use FFA_DIRECT_MSG_REQ/RESP
+ DirectMsgV1,
+
+ /// Direct message version 2. Use FFA_DIRECT_MSG_REQ2/RESP2
+ DirectMsgV2,
+
+ DirectMsgMax,
+} DIRECT_MSG_VERSION;
+
+/**
+ * SPM_MM ABI data
+ */
+typedef struct {
+ /// Service Type
+ SERVICE_TYPE ServiceType;
+
+ /// Secure Request
+ BOOLEAN SecureRequest;
+} SPM_MM_MSG_INFO;
+
+/** Ffa Abi data used in FFA_MSG_SEND_DIRECT_RESP/RESP2.
+ */
+typedef struct FfaMsgInfo {
+ /// Source partition id
+ UINT16 SourcePartId;
+
+ /// Destination partition id
+ UINT16 DestPartId;
+
+ /// Direct Message version
+ DIRECT_MSG_VERSION DirectMsgVersion;
+
+ /// Service Type
+ SERVICE_TYPE ServiceType;
+} FFA_MSG_INFO;
+
+typedef union {
+ /// SPM_MM message info
+ SPM_MM_MSG_INFO SpmMmInfo;
+
+ /// FF-A message info
+ FFA_MSG_INFO FfaMsgInfo;
+} ARM_MM_HANDLER_CTX_DATA;
+
+typedef struct {
+ /// Communication Protocol
+ COMM_PROTOCOL CommProtocol;
+
+ /// Context Data according to CommProtocol
+ ARM_MM_HANDLER_CTX_DATA CtxData;
+} ARM_MM_HANDLER_CONTEXT;
+
+#endif // ARM_MM_HANDLER_CONTEXT_H_
diff --git a/ArmPkg/Include/Library/ArmStandaloneMmCoreEntryPoint.h b/ArmPkg/Include/Library/ArmStandaloneMmCoreEntryPoint.h
index 1549211613..8c86bf0d15 100644
--- a/ArmPkg/Include/Library/ArmStandaloneMmCoreEntryPoint.h
+++ b/ArmPkg/Include/Library/ArmStandaloneMmCoreEntryPoint.h
@@ -25,6 +25,7 @@
#include
#include
+#include
#include
#include
@@ -40,70 +41,6 @@
#define MMRAM_DESC_IDX_HEAP 3
#define MMRAM_DESC_MIN_COUNT 4
-/*
- * Communication ABI protocol to communicate between normal/secure partition.
- */
-typedef enum {
- /// Unknown Communication ABI protocol
- CommProtocolUnknown,
-
- /// Communicate via SPM_MM ABI protocol
- CommProtocolSpmMm,
-
- /// Communicate via FF-A ABI protocol
- CommProtocolFfa,
-
- CommProtocolMax,
-} COMM_PROTOCOL;
-
-/** When using FF-A ABI, there're ways to request service to StandaloneMm
- - FF-A with MmCommunication protocol.
- - FF-A service with each specification.
- MmCommunication Protocol can use FFA_MSG_SEND_DIRECT_REQ or REQ2,
- Other FF-A services should use FFA_MSG_SEND_DIRECT_REQ2.
- In case of FF-A with MmCommunication protocol via FFA_MSG_SEND_DIRECT_REQ,
- register x3 saves Communication Buffer with gEfiMmCommunication2ProtocolGuid.
- In case of FF-A with MmCommunication protocol via FFA_MSG_SEND_DIRECT_REQ2,
- register x2/x3 save gEfiMmCommunication2ProtocolGuid and
- register x4 saves Communication Buffer with Service Guid.
-
- Other FF-A services (ServiceTypeMisc) delivers register values according to
- there own service specification.
- That means it doesn't use MmCommunication Buffer with MmCommunication Header
- format.
- (i.e) Tpm service via FF-A or Firmware Update service via FF-A.
- To support latter services by StandaloneMm, it defines SERVICE_TYPE_MISC.
- So that StandaloneMmEntryPointCore.c generates MmCommunication Header
- with delivered register values to dispatch service provided StandaloneMmCore.
- So that service handler can get proper information from delivered register.
-
- In case of SPM_MM Abi, it only supports MmCommunication service.
- */
-typedef enum {
- /// Unknown
- ServiceTypeUnknown,
-
- /// MmCommunication services
- ServiceTypeMmCommunication,
-
- /// Misc services
- ServiceTypeMisc,
-
- ServiceTypeMax,
-} SERVICE_TYPE;
-
-/** Direct message request/response version
- */
-typedef enum {
- /// Direct message version 1. Use FFA_DIRECT_MSG_REQ/RESP
- DirectMsgV1,
-
- /// Direct message version 2. Use FFA_DIRECT_MSG_REQ2/RESP2
- DirectMsgV2,
-
- DirectMsgMax,
-} DIRECT_MSG_VERSION;
-
/** Service table entry to return service type matched with service guid
*/
typedef struct ServiceTableEntry {
@@ -114,22 +51,6 @@ typedef struct ServiceTableEntry {
SERVICE_TYPE ServiceType;
} SERVICE_TABLE_ENTRY;
-/** Ffa Abi data used in FFA_MSG_SEND_DIRECT_RESP/RESP2.
- */
-typedef struct FfaMsgInfo {
- /// Source partition id
- UINT16 SourcePartId;
-
- /// Destination partition id
- UINT16 DestPartId;
-
- /// Direct Message version
- DIRECT_MSG_VERSION DirectMsgVersion;
-
- /// Service Type
- SERVICE_TYPE ServiceType;
-} FFA_MSG_INFO;
-
/** MmCommunication Header for Misc service.
Misc service doesn't use MmCommunication Buffer.
This structure is used to dispatch Misc services by StandaloneMm.