From ff04469d33512d29a5b1afa9c99ec3a152795360 Mon Sep 17 00:00:00 2001 From: Hongbin1 Zhang Date: Fri, 31 May 2024 15:26:10 +0800 Subject: [PATCH] MdeModulePkg: Add MM Communication Buffer definition The MM communicate buffer facilitates data sharing between non-MM and MM code. The MM IPL code allocates a "fixed" runtime type memory as the MM communication buffer, and communicates its address and size to MM Core via MmCommBuffer GUIDed HOB. Here, "fixed" implies that the buffer's location remains constant throughout the boot process. Data is exchanged between the MM Communication PPI/Protocol and a software MMI handler using this fixed MM communication buffer. Signed-off-by: Hongbin1 Zhang Co-authored-by: Jiaxin Wu Cc: Liming Gao Co-authored-by: Ray Ni Cc: Star Zeng Cc: Wei6 Xu Cc: Dun Tan Cc: Yuanhao Xie --- MdeModulePkg/Include/Guid/MmCommBuffer.h | 63 ++++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 ++ 2 files changed, 66 insertions(+) create mode 100644 MdeModulePkg/Include/Guid/MmCommBuffer.h diff --git a/MdeModulePkg/Include/Guid/MmCommBuffer.h b/MdeModulePkg/Include/Guid/MmCommBuffer.h new file mode 100644 index 0000000000..df4ea317eb --- /dev/null +++ b/MdeModulePkg/Include/Guid/MmCommBuffer.h @@ -0,0 +1,63 @@ +/** @file + MM Communication buffer data. + +Copyright (c) 2024, Intel Corporation. All rights reserved.
+ +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MM_COMM_BUFFER_H_ +#define MM_COMM_BUFFER_H_ + +/// +/// The GUID of the MM Communication buffer HOB. +/// +#define MM_COMM_BUFFER_HOB_GUID \ + { 0x6c2a2520, 0x0131, 0x4aee, { 0xa7, 0x50, 0xcc, 0x38, 0x4a, 0xac, 0xe8, 0xc6 }} + +/// +/// The MM communicate buffer facilitates data sharing between non-MM and MM code. +/// The MM IPL code allocates a "fixed" runtime type memory as the MM communication buffer, +/// and communicates its address and size to MM Core via MmCommBuffer GUIDed HOB. +/// Here, "fixed" implies that the buffer's location remains constant throughout the boot process. +/// Data is exchanged between the MM Communication PPI/Protocol and a software MMI handler +/// using this fixed MM communication buffer. +/// +typedef struct { + /// + /// The address of the 4-KiB aligned fixed MM communication buffer. + /// + EFI_PHYSICAL_ADDRESS PhysicalStart; + + /// + /// Size of the fixed MM communication buffer, in 4KiB pages. + /// + UINT64 NumberOfPages; + + /// + /// Point to MM_COMM_BUFFER_STATUS structure. + /// + EFI_PHYSICAL_ADDRESS Status; +} MM_COMM_BUFFER; + +typedef struct { + /// + /// Whether the data in the fixed MM communication buffer is valid when entering from non-MM to MM. + /// + BOOLEAN IsCommBufferValid; + + /// + /// The return status when returning from MM to non-MM. + /// + UINT64 ReturnStatus; + + /// + /// The size in bytes of the output buffer when returning from MM to non-MM. + /// + UINT64 ReturnBufferSize; +} MM_COMM_BUFFER_STATUS; + +extern EFI_GUID gMmCommBufferHobGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 693e45911b..e71a4dd5e3 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -485,6 +485,9 @@ ## HOB GUID to get ACPI table after FSP is done. The ACPI table that related SOC will be pass by this HOB. gAcpiTableHobGuid = { 0xf9886b57, 0x8a35, 0x455e, { 0xbb, 0xb1, 0x14, 0x65, 0x5e, 0x7b, 0xe7, 0xec }} + ## Include/Guid/MmCommBuffer.h + gMmCommBufferHobGuid = { 0x6c2a2520, 0x0131, 0x4aee, { 0xa7, 0x50, 0xcc, 0x38, 0x4a, 0xac, 0xe8, 0xc6 }} + [Ppis] ## Include/Ppi/FirmwareVolumeShadowPpi.h gEdkiiPeiFirmwareVolumeShadowPpiGuid = { 0x7dfe756c, 0xed8d, 0x4d77, {0x9e, 0xc4, 0x39, 0x9a, 0x8a, 0x81, 0x51, 0x16 } }