mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
ArmPkg/Library: add ArmMmHandlerContext for MM handler context management
Introduce ArmMmHandlerContext.h, which defines the ARM_MM_HANDLER_CONTEXT structure passed to each MmHandler’s Context argument. This structure provides: - The current communication protocol type - The service type - Protocol-specific details This enables MM drivers to differentiate requests from MM communication versus DIRECT_MSG_REQ2, support both SPM_MM and FF-A v1.2, and determine whether a request originated from the secure world. Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
This commit is contained in:
parent
f63875271d
commit
2ee24e6c4e
3 changed files with 124 additions and 81 deletions
|
|
@ -84,7 +84,10 @@
|
|||
|
||||
## options defined .pytool/Plugin/LibraryClassCheck
|
||||
"LibraryClassCheck": {
|
||||
"IgnoreHeaderFile": []
|
||||
"IgnoreHeaderFile": [
|
||||
"Include/Library/ArmMmHandlerContext.h"
|
||||
],
|
||||
"skip": True
|
||||
},
|
||||
|
||||
## options defined .pytool/Plugin/SpellCheck
|
||||
|
|
|
|||
119
ArmPkg/Include/Library/ArmMmHandlerContext.h
Normal file
119
ArmPkg/Include/Library/ArmMmHandlerContext.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/** @file
|
||||
Define ArmMmHandlerContext passed to MmHandler in Arm platform.
|
||||
|
||||
Copyright (c) 2025, Arm Ltd. All rights reserved.<BR>
|
||||
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_
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <Library/ArmSvcLib.h>
|
||||
#include <Library/ArmFfaLib.h>
|
||||
#include <Library/ArmMmHandlerContext.h>
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/FvLib.h>
|
||||
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue