summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include')
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmCoreData.h127
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmFvDispatch.h33
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h56
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MpInformation.h35
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h216
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/FvLib.h104
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmCoreEntryPoint.h95
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h134
-rw-r--r--src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/StandaloneMm.h29
9 files changed, 829 insertions, 0 deletions
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmCoreData.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmCoreData.h
new file mode 100644
index 00000000..6c33b4be
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmCoreData.h
@@ -0,0 +1,127 @@
+/** @file
+ MM Core data.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018 - 2021, Arm Limited. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __MM_CORE_DATA_H__
+#define __MM_CORE_DATA_H__
+
+#define MM_CORE_DATA_HOB_GUID \
+ { 0xa160bf99, 0x2aa4, 0x4d7d, { 0x99, 0x93, 0x89, 0x9c, 0xb1, 0x2d, 0xf3, 0x76 }}
+
+extern EFI_GUID gMmCoreDataHobGuid;
+
+typedef struct {
+ //
+ // Address pointer to MM_CORE_PRIVATE_DATA
+ //
+ EFI_PHYSICAL_ADDRESS Address;
+} MM_CORE_DATA_HOB_DATA;
+
+
+///
+/// Define values for the communications buffer used when gEfiEventDxeDispatchGuid is
+/// event signaled. This event is signaled by the DXE Core each time the DXE Core
+/// dispatcher has completed its work. When this event is signaled, the MM Core
+/// if notified, so the MM Core can dispatch MM drivers. If COMM_BUFFER_MM_DISPATCH_ERROR
+/// is returned in the communication buffer, then an error occurred dispatching MM
+/// Drivers. If COMM_BUFFER_MM_DISPATCH_SUCCESS is returned, then the MM Core
+/// dispatched all the drivers it could. If COMM_BUFFER_MM_DISPATCH_RESTART is
+/// returned, then the MM Core just dispatched the MM Driver that registered
+/// the MM Entry Point enabling the use of MM Mode. In this case, the MM Core
+/// should be notified again to dispatch more MM Drivers using MM Mode.
+///
+#define COMM_BUFFER_MM_DISPATCH_ERROR 0x00
+#define COMM_BUFFER_MM_DISPATCH_SUCCESS 0x01
+#define COMM_BUFFER_MM_DISPATCH_RESTART 0x02
+
+///
+/// Signature for the private structure shared between the MM IPL and the MM Core
+///
+#define MM_CORE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('m', 'm', 'i', 'c')
+
+///
+/// Private structure that is used to share information between the MM IPL and
+/// the MM Core. This structure is allocated from memory of type EfiRuntimeServicesData.
+/// Since runtime memory types are converted to available memory when a legacy boot
+/// is performed, the MM Core must not access any fields of this structure if a legacy
+/// boot is performed. As a result, the MM IPL must create an event notification
+/// for the Legacy Boot event and notify the MM Core that a legacy boot is being
+/// performed. The MM Core can then use this information to filter accesses to
+/// thos structure.
+///
+typedef struct {
+ UINT64 Signature;
+
+ ///
+ /// The number of MMRAM ranges passed from the MM IPL to the MM Core. The MM
+ /// Core uses these ranges of MMRAM to initialize the MM Core memory manager.
+ ///
+ UINT64 MmramRangeCount;
+
+ ///
+ /// A table of MMRAM ranges passed from the MM IPL to the MM Core. The MM
+ /// Core uses these ranges of MMRAM to initialize the MM Core memory manager.
+ ///
+ EFI_PHYSICAL_ADDRESS MmramRanges;
+
+ ///
+ /// The MM Foundation Entry Point. The MM Core fills in this field when the
+ /// MM Core is initialized. The MM IPL is responsbile for registering this entry
+ /// point with the MM Configuration Protocol. The MM Configuration Protocol may
+ /// not be available at the time the MM IPL and MM Core are started, so the MM IPL
+ /// sets up a protocol notification on the MM Configuration Protocol and registers
+ /// the MM Foundation Entry Point as soon as the MM Configuration Protocol is
+ /// available.
+ ///
+ EFI_PHYSICAL_ADDRESS MmEntryPoint;
+
+ ///
+ /// Boolean flag set to TRUE while an MMI is being processed by the MM Core.
+ ///
+ BOOLEAN MmEntryPointRegistered;
+
+ ///
+ /// Boolean flag set to TRUE while an MMI is being processed by the MM Core.
+ ///
+ BOOLEAN InMm;
+
+ ///
+ /// This field is set by the MM Core then the MM Core is initialized. This field is
+ /// used by the MM Base 2 Protocol and MM Communication Protocol implementations in
+ /// the MM IPL.
+ ///
+ EFI_PHYSICAL_ADDRESS Mmst;
+
+ ///
+ /// This field is used by the MM Communication Protocol to pass a buffer into
+ /// a software MMI handler and for the software MMI handler to pass a buffer back to
+ /// the caller of the MM Communication Protocol.
+ ///
+ EFI_PHYSICAL_ADDRESS CommunicationBuffer;
+
+ ///
+ /// This field is used by the MM Communication Protocol to pass the size of a buffer,
+ /// in bytes, into a software MMI handler and for the software MMI handler to pass the
+ /// size, in bytes, of a buffer back to the caller of the MM Communication Protocol.
+ ///
+ UINT64 BufferSize;
+
+ ///
+ /// This field is used by the MM Communication Protocol to pass the return status from
+ /// a software MMI handler back to the caller of the MM Communication Protocol.
+ ///
+ UINT64 ReturnStatus;
+
+ EFI_PHYSICAL_ADDRESS MmCoreImageBase;
+ UINT64 MmCoreImageSize;
+ EFI_PHYSICAL_ADDRESS MmCoreEntryPoint;
+
+ EFI_PHYSICAL_ADDRESS StandaloneBfvAddress;
+} MM_CORE_PRIVATE_DATA;
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmFvDispatch.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmFvDispatch.h
new file mode 100644
index 00000000..162a3890
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmFvDispatch.h
@@ -0,0 +1,33 @@
+/** @file
+ GUIDs for MM Event.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __MM_FV_DISPATCH_H__
+#define __MM_FV_DISPATCH_H__
+
+#define MM_FV_DISPATCH_GUID \
+ { 0xb65694cc, 0x9e3, 0x4c3b, { 0xb5, 0xcd, 0x5, 0xf4, 0x4d, 0x3c, 0xdb, 0xff }}
+
+extern EFI_GUID gMmFvDispatchGuid;
+
+#pragma pack(1)
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS Address;
+ UINT64 Size;
+} EFI_MM_COMMUNICATE_FV_DISPATCH_DATA;
+
+typedef struct {
+ EFI_GUID HeaderGuid;
+ UINTN MessageLength;
+ EFI_MM_COMMUNICATE_FV_DISPATCH_DATA Data;
+} EFI_MM_COMMUNICATE_FV_DISPATCH;
+#pragma pack()
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h
new file mode 100644
index 00000000..1d98d601
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h
@@ -0,0 +1,56 @@
+/** @file
+ Definition of GUIDed HOB for reserving MMRAM regions.
+
+ This file defines:
+ * the GUID used to identify the GUID HOB for reserving MMRAM regions.
+ * the data structure of MMRAM descriptor to describe MMRAM candidate regions
+ * values of state of MMRAM candidate regions
+ * the GUID specific data structure of HOB for reserving MMRAM regions.
+ This GUIDed HOB can be used to convey the existence of the T-SEG reservation and H-SEG usage
+
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ GUIDs defined in MmCis spec version 0.9.
+
+**/
+
+#ifndef _EFI_MM_PEI_MMRAM_MEMORY_RESERVE_H_
+#define _EFI_MM_PEI_MMRAM_MEMORY_RESERVE_H_
+
+#define EFI_MM_PEI_MMRAM_MEMORY_RESERVE \
+ { \
+ 0x0703f912, 0xbf8d, 0x4e2a, {0xbe, 0x07, 0xab, 0x27, 0x25, 0x25, 0xc5, 0x92 } \
+ }
+
+/**
+* GUID specific data structure of HOB for reserving MMRAM regions.
+*
+* Inconsistent with specification here:
+* EFI_HOB_MMRAM_DESCRIPTOR_BLOCK has been changed to EFI_MMRAM_HOB_DESCRIPTOR_BLOCK.
+* This inconsistency is kept in code in order for backward compatibility.
+**/
+typedef struct {
+ ///
+ /// Designates the number of possible regions in the system
+ /// that can be usable for MMRAM.
+ ///
+ /// Inconsistent with specification here:
+ /// In Framework MM CIS 0.91 specification, it defines the field type as UINTN.
+ /// However, HOBs are supposed to be CPU neutral, so UINT32 should be used instead.
+ ///
+ UINT32 NumberOfMmReservedRegions;
+ ///
+ /// Used throughout this protocol to describe the candidate
+ /// regions for MMRAM that are supported by this platform.
+ ///
+ EFI_MMRAM_DESCRIPTOR Descriptor[1];
+} EFI_MMRAM_HOB_DESCRIPTOR_BLOCK;
+
+extern EFI_GUID gEfiMmPeiSmramMemoryReserveGuid;
+
+#endif
+
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MpInformation.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MpInformation.h
new file mode 100644
index 00000000..d3d0e992
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Guid/MpInformation.h
@@ -0,0 +1,35 @@
+/** @file
+ EFI MP information protocol provides a lightweight MP_SERVICES_PROTOCOL.
+
+ MP information protocol only provides static information of MP processor.
+
+ Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MP_INFORMATION_H_
+#define _MP_INFORMATION_H_
+
+#include <Protocol/MpService.h>
+#include <PiPei.h>
+#include <Ppi/SecPlatformInformation.h>
+
+#define MP_INFORMATION_GUID \
+ { \
+ 0xba33f15d, 0x4000, 0x45c1, {0x8e, 0x88, 0xf9, 0x16, 0x92, 0xd4, 0x57, 0xe3} \
+ }
+
+#pragma pack(1)
+typedef struct {
+ UINT64 NumberOfProcessors;
+ UINT64 NumberOfEnabledProcessors;
+ EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer[];
+} MP_INFORMATION_HOB_DATA;
+#pragma pack()
+
+extern EFI_GUID gMpInformationHobGuid;
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
new file mode 100644
index 00000000..d13b0665
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
@@ -0,0 +1,216 @@
+/** @file
+ Entry point to the Standalone MM Foundation when initialized during the SEC
+ phase on ARM platforms
+
+Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __STANDALONEMMCORE_ENTRY_POINT_H__
+#define __STANDALONEMMCORE_ENTRY_POINT_H__
+
+#include <Library/PeCoffLib.h>
+#include <Library/FvLib.h>
+
+#define CPU_INFO_FLAG_PRIMARY_CPU 0x00000001
+
+typedef struct {
+ UINT8 Type; /* type of the structure */
+ UINT8 Version; /* version of this structure */
+ UINT16 Size; /* size of this structure in bytes */
+ UINT32 Attr; /* attributes: unused bits SBZ */
+} EFI_PARAM_HEADER;
+
+typedef struct {
+ UINT64 Mpidr;
+ UINT32 LinearId;
+ UINT32 Flags;
+} EFI_SECURE_PARTITION_CPU_INFO;
+
+typedef struct {
+ EFI_PARAM_HEADER Header;
+ UINT64 SpMemBase;
+ UINT64 SpMemLimit;
+ UINT64 SpImageBase;
+ UINT64 SpStackBase;
+ UINT64 SpHeapBase;
+ UINT64 SpNsCommBufBase;
+ UINT64 SpSharedBufBase;
+ UINT64 SpImageSize;
+ UINT64 SpPcpuStackSize;
+ UINT64 SpHeapSize;
+ UINT64 SpNsCommBufSize;
+ UINT64 SpPcpuSharedBufSize;
+ UINT32 NumSpMemRegions;
+ UINT32 NumCpus;
+ EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
+} EFI_SECURE_PARTITION_BOOT_INFO;
+
+typedef
+EFI_STATUS
+(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (
+ IN UINTN EventId,
+ IN UINTN CpuNumber,
+ IN UINTN NsCommBufferAddr
+ );
+
+typedef struct {
+ PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr;
+} ARM_TF_CPU_DRIVER_EP_DESCRIPTOR;
+
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ );
+
+/**
+ Privileged firmware assigns RO & Executable attributes to all memory occupied
+ by the Boot Firmware Volume. This function sets the correct permissions of
+ sections in the Standalone MM Core module to be able to access RO and RW data
+ and make further progress in the boot process.
+
+ @param [in] ImageContext Pointer to PE/COFF image context
+ @param [in] ImageBase Base of image in memory
+ @param [in] SectionHeaderOffset Offset of PE/COFF image section header
+ @param [in] NumberOfSections Number of Sections
+ @param [in] TextUpdater Function to change code permissions
+ @param [in] ReadOnlyUpdater Function to change RO permissions
+ @param [in] ReadWriteUpdater Function to change RW permissions
+
+**/
+EFI_STATUS
+EFIAPI
+UpdateMmFoundationPeCoffPermissions (
+ IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_PHYSICAL_ADDRESS ImageBase,
+ IN UINT32 SectionHeaderOffset,
+ IN CONST UINT16 NumberOfSections,
+ IN REGION_PERMISSION_UPDATE_FUNC TextUpdater,
+ IN REGION_PERMISSION_UPDATE_FUNC ReadOnlyUpdater,
+ IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
+ );
+
+
+/**
+ Privileged firmware assigns RO & Executable attributes to all memory occupied
+ by the Boot Firmware Volume. This function locates the section information of
+ the Standalone MM Core module to be able to change permissions of the
+ individual sections later in the boot process.
+
+ @param [in] TeData Pointer to PE/COFF image data
+ @param [in, out] ImageContext Pointer to PE/COFF image context
+ @param [out] ImageBase Pointer to ImageBase variable
+ @param [in, out] SectionHeaderOffset Offset of PE/COFF image section header
+ @param [in, out] NumberOfSections Number of Sections
+
+**/
+EFI_STATUS
+EFIAPI
+GetStandaloneMmCorePeCoffSections (
+ IN VOID *TeData,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_PHYSICAL_ADDRESS *ImageBase,
+ IN OUT UINT32 *SectionHeaderOffset,
+ IN OUT UINT16 *NumberOfSections
+ );
+
+
+/**
+ Privileged firmware assigns RO & Executable attributes to all memory occupied
+ by the Boot Firmware Volume. This function locates the Standalone MM Core
+ module PE/COFF image in the BFV and returns this information.
+
+ @param [in] BfvAddress Base Address of Boot Firmware Volume
+ @param [in, out] TeData Pointer to address for allocating memory
+ for PE/COFF image data
+ @param [in, out] TeDataSize Pointer to size of PE/COFF image data
+
+**/
+EFI_STATUS
+EFIAPI
+LocateStandaloneMmCorePeCoffData (
+ IN EFI_FIRMWARE_VOLUME_HEADER *BfvAddress,
+ IN OUT VOID **TeData,
+ IN OUT UINTN *TeDataSize
+ );
+
+
+/**
+ Use the boot information passed by privileged firmware to populate a HOB list
+ suitable for consumption by the MM Core and drivers.
+
+ @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
+ @param [in] PayloadBootInfo Boot information passed by privileged
+ firmware
+
+**/
+VOID *
+EFIAPI
+CreateHobListFromBootInfo (
+ IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
+ IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
+ );
+
+
+/**
+ The entry point of Standalone MM Foundation.
+
+ @param [in] SharedBufAddress Pointer to the Buffer between SPM and SP.
+ @param [in] SharedBufSize Size of the shared buffer.
+ @param [in] cookie1 Cookie 1
+ @param [in] cookie2 Cookie 2
+
+**/
+VOID
+EFIAPI
+_ModuleEntryPoint (
+ IN VOID *SharedBufAddress,
+ IN UINT64 SharedBufSize,
+ IN UINT64 cookie1,
+ IN UINT64 cookie2
+ );
+
+
+/**
+ Auto generated function that calls the library constructors for all of the module's dependent libraries.
+
+ This function must be called by _ModuleEntryPoint().
+ This function calls the set of library constructors for the set of library instances
+ that a module depends on. This includes library instances that a module depends on
+ directly and library instances that a module depends on indirectly through other
+ libraries. This function is auto generated by build tools and those build tools are
+ responsible for collecting the set of library instances, determine which ones have
+ constructors, and calling the library constructors in the proper order based upon
+ each of the library instances own dependencies.
+
+ @param ImageHandle The image handle of the DXE Core.
+ @param SystemTable A pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *MmSystemTable
+ );
+
+
+/**
+ Auto generated function that calls a set of module entry points.
+
+ This function must be called by _ModuleEntryPoint().
+ This function calls the set of module entry points.
+ This function is auto generated by build tools and those build tools are responsible
+ for collecting the module entry points and calling them in a specified order.
+
+ @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
+
+**/
+VOID
+EFIAPI
+ProcessModuleEntryPointList (
+ IN VOID *HobStart
+ );
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/FvLib.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/FvLib.h
new file mode 100644
index 00000000..038fff97
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/FvLib.h
@@ -0,0 +1,104 @@
+/** @file
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FV_LIB_H_
+#define _FV_LIB_H_
+
+#include <Uefi.h>
+#include <Pi/PiFirmwareVolume.h>
+#include <Pi/PiFirmwareFile.h>
+
+/**
+ Given the input file pointer, search for the next matching file in the
+ FFS volume as defined by SearchType. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+ @param SearchType Filter to find only files of this type.
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+ @param FwVolHeader Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+ @param FileHeader Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+
+ @retval EFI_NOT_FOUND No files matching the search criteria were found
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+FfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ );
+
+/**
+ Given the input file pointer, search for the next matching section in the
+ FFS volume.
+
+ @param SearchType Filter to find only sections of this type.
+ @param FfsFileHeader Pointer to the current file to search.
+ @param SectionHeader Pointer to the Section matching SectionType in FfsFileHeader.
+ NULL if section not found
+
+ @retval EFI_NOT_FOUND No files matching the search criteria were found
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+FfsFindSection (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT EFI_COMMON_SECTION_HEADER **SectionHeader
+ );
+
+/**
+ Locates a section within a series of sections
+ with the specified section type.
+
+ @param[in] Sections The sections to search
+ @param[in] SizeOfSections Total size of all sections
+ @param[in] SectionType The section type to locate
+ @param[out] FoundSection The FFS section if found
+
+ @retval EFI_SUCCESS The file and section was found
+ @retval EFI_NOT_FOUND The file and section was not found
+ @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted
+**/
+EFI_STATUS
+EFIAPI
+FindFfsSectionInSections (
+ IN VOID *Sections,
+ IN UINTN SizeOfSections,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT EFI_COMMON_SECTION_HEADER **FoundSection
+ );
+
+/**
+ Given the input file pointer, search for the next matching section in the
+ FFS volume.
+
+ @param SearchType Filter to find only sections of this type.
+ @param FfsFileHeader Pointer to the current file to search.
+ @param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
+ NULL if section not found
+ @param SectionDataSize The size of SectionData
+
+ @retval EFI_NOT_FOUND No files matching the search criteria were found
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+FfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ OUT VOID **SectionData,
+ OUT UINTN *SectionDataSize
+ );
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmCoreEntryPoint.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmCoreEntryPoint.h
new file mode 100644
index 00000000..0e2c663e
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmCoreEntryPoint.h
@@ -0,0 +1,95 @@
+/** @file
+ Module entry point library for STANDALONE MM core.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __MODULE_ENTRY_POINT_H__
+#define __MODULE_ENTRY_POINT_H__
+
+///
+/// Global variable that contains a pointer to the Hob List passed into the STANDALONE MM Core entry point.
+///
+extern VOID *gHobList;
+
+
+/**
+ The entry point of PE/COFF Image for the STANDALONE MM Core.
+
+ This function is the entry point for the STANDALONE MM Core. This function is required to call
+ ProcessModuleEntryPointList() and ProcessModuleEntryPointList() is never expected to return.
+ The STANDALONE MM Core is responsible for calling ProcessLibraryConstructorList() as soon as the EFI
+ System Table and the image handle for the STANDALONE MM Core itself have been established.
+ If ProcessModuleEntryPointList() returns, then ASSERT() and halt the system.
+
+ @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
+
+**/
+VOID
+EFIAPI
+_ModuleEntryPoint (
+ IN VOID *HobStart
+ );
+
+
+/**
+ Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
+
+ This function is required to call _ModuleEntryPoint() passing in HobStart.
+
+ @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
+
+**/
+VOID
+EFIAPI
+EfiMain (
+ IN VOID *HobStart
+ );
+
+
+/**
+ Auto generated function that calls the library constructors for all of the module's dependent libraries.
+
+ This function must be called by _ModuleEntryPoint().
+ This function calls the set of library constructors for the set of library instances
+ that a module depends on. This includes library instances that a module depends on
+ directly and library instances that a module depends on indirectly through other
+ libraries. This function is auto generated by build tools and those build tools are
+ responsible for collecting the set of library instances, determine which ones have
+ constructors, and calling the library constructors in the proper order based upon
+ each of the library instances own dependencies.
+
+ @param ImageHandle The image handle of the STANDALONE MM Core.
+ @param SystemTable A pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *MmSystemTable
+ );
+
+
+/**
+ Autogenerated function that calls a set of module entry points.
+
+ This function must be called by _ModuleEntryPoint().
+ This function calls the set of module entry points.
+ This function is auto generated by build tools and those build tools are responsible
+ for collecting the module entry points and calling them in a specified order.
+
+ @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
+
+**/
+VOID
+EFIAPI
+ProcessModuleEntryPointList (
+ IN VOID *HobStart
+ );
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
new file mode 100644
index 00000000..20b0c0c8
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
@@ -0,0 +1,134 @@
+/** @file
+ Provides services for MM Memory Operation.
+
+ The MM Mem Library provides function for checking if buffer is outside MMRAM and valid.
+ It also provides functions for copy data from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
+ from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
+
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MM_MEM_LIB_H_
+#define _MM_MEM_LIB_H_
+
+/**
+ This function check if the buffer is valid per processor architecture and not overlap with MMRAM.
+
+ @param Buffer The buffer start address to be checked.
+ @param Length The buffer length to be checked.
+
+ @retval TRUE This buffer is valid per processor architecture and not overlap with MMRAM.
+ @retval FALSE This buffer is not valid per processor architecture or overlap with MMRAM.
+**/
+BOOLEAN
+EFIAPI
+MmIsBufferOutsideMmValid (
+ IN EFI_PHYSICAL_ADDRESS Buffer,
+ IN UINT64 Length
+ );
+
+/**
+ Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
+
+ This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
+ It checks if source buffer is valid per processor architecture and not overlap with MMRAM.
+ If the check passes, it copies memory and returns EFI_SUCCESS.
+ If the check fails, it return EFI_SECURITY_VIOLATION.
+ The implementation must be reentrant.
+
+ @param DestinationBuffer The pointer to the destination buffer of the memory copy.
+ @param SourceBuffer The pointer to the source buffer of the memory copy.
+ @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
+
+ @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.
+ @retval EFI_SUCCESS Memory is copied.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCopyMemToMmram (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).
+
+ This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
+ It checks if destination buffer is valid per processor architecture and not overlap with MMRAM.
+ If the check passes, it copies memory and returns EFI_SUCCESS.
+ If the check fails, it returns EFI_SECURITY_VIOLATION.
+ The implementation must be reentrant.
+
+ @param DestinationBuffer The pointer to the destination buffer of the memory copy.
+ @param SourceBuffer The pointer to the source buffer of the memory copy.
+ @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
+
+ @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with MMRAM.
+ @retval EFI_SUCCESS Memory is copied.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCopyMemFromMmram (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Copies a source buffer (NON-MMRAM) to a destination buffer (NON-MMRAM).
+
+ This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
+ It checks if source buffer and destination buffer are valid per processor architecture and not overlap with MMRAM.
+ If the check passes, it copies memory and returns EFI_SUCCESS.
+ If the check fails, it returns EFI_SECURITY_VIOLATION.
+ The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.
+
+ @param DestinationBuffer The pointer to the destination buffer of the memory copy.
+ @param SourceBuffer The pointer to the source buffer of the memory copy.
+ @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
+
+ @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with MMRAM.
+ @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.
+ @retval EFI_SUCCESS Memory is copied.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCopyMem (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Fills a target buffer (NON-MMRAM) with a byte value.
+
+ This function fills a target buffer (non-MMRAM) with a byte value.
+ It checks if target buffer is valid per processor architecture and not overlap with MMRAM.
+ If the check passes, it fills memory and returns EFI_SUCCESS.
+ If the check fails, it returns EFI_SECURITY_VIOLATION.
+
+ @param Buffer The memory to set.
+ @param Length The number of bytes to set.
+ @param Value The value with which to fill Length bytes of Buffer.
+
+ @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with MMRAM.
+ @retval EFI_SUCCESS Memory is set.
+
+**/
+EFI_STATUS
+EFIAPI
+MmSetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+#endif
diff --git a/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/StandaloneMm.h b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/StandaloneMm.h
new file mode 100644
index 00000000..ed8849d5
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/StandaloneMmPkg/Include/StandaloneMm.h
@@ -0,0 +1,29 @@
+/** @file
+ Standalone MM.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _STANDALONE_MM_H_
+#define _STANDALONE_MM_H_
+
+#include <PiMm.h>
+
+typedef
+EFI_STATUS
+(EFIAPI *MM_IMAGE_ENTRY_POINT) (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *MmSystemTable
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *STANDALONE_MM_FOUNDATION_ENTRY_POINT) (
+ IN VOID *HobStart
+ );
+
+#endif