--- /dev/null
+/** @file\r
+ Entry point to the Standalone MM Foundation when initialized during the SEC\r
+ phase on ARM platforms\r
+\r
+Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __STANDALONEMMCORE_ENTRY_POINT_H__\r
+#define __STANDALONEMMCORE_ENTRY_POINT_H__\r
+\r
+#include <Library/PeCoffLib.h>\r
+#include <Library/FvLib.h>\r
+\r
+#define CPU_INFO_FLAG_PRIMARY_CPU 0x00000001\r
+\r
+typedef struct {\r
+ UINT8 Type; /* type of the structure */\r
+ UINT8 Version; /* version of this structure */\r
+ UINT16 Size; /* size of this structure in bytes */\r
+ UINT32 Attr; /* attributes: unused bits SBZ */\r
+} EFI_PARAM_HEADER;\r
+\r
+typedef struct {\r
+ UINT64 Mpidr;\r
+ UINT32 LinearId;\r
+ UINT32 Flags;\r
+} EFI_SECURE_PARTITION_CPU_INFO;\r
+\r
+typedef struct {\r
+ EFI_PARAM_HEADER Header;\r
+ UINT64 SpMemBase;\r
+ UINT64 SpMemLimit;\r
+ UINT64 SpImageBase;\r
+ UINT64 SpStackBase;\r
+ UINT64 SpHeapBase;\r
+ UINT64 SpNsCommBufBase;\r
+ UINT64 SpSharedBufBase;\r
+ UINT64 SpImageSize;\r
+ UINT64 SpPcpuStackSize;\r
+ UINT64 SpHeapSize;\r
+ UINT64 SpNsCommBufSize;\r
+ UINT64 SpPcpuSharedBufSize;\r
+ UINT32 NumSpMemRegions;\r
+ UINT32 NumCpus;\r
+ EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;\r
+} EFI_SECURE_PARTITION_BOOT_INFO;\r
+\r
+typedef\r
+EFI_STATUS\r
+(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (\r
+ IN UINTN EventId,\r
+ IN UINTN CpuNumber,\r
+ IN UINTN NsCommBufferAddr\r
+ );\r
+\r
+typedef struct {\r
+ PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr;\r
+} ARM_TF_CPU_DRIVER_EP_DESCRIPTOR;\r
+\r
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
+ IN UINT64 Length\r
+ );\r
+\r
+/**\r
+ Privileged firmware assigns RO & Executable attributes to all memory occupied\r
+ by the Boot Firmware Volume. This function sets the correct permissions of\r
+ sections in the Standalone MM Core module to be able to access RO and RW data\r
+ and make further progress in the boot process.\r
+\r
+ @param [in] ImageContext Pointer to PE/COFF image context\r
+ @param [in] ImageBase Base of image in memory\r
+ @param [in] SectionHeaderOffset Offset of PE/COFF image section header\r
+ @param [in] NumberOfSections Number of Sections\r
+ @param [in] TextUpdater Function to change code permissions\r
+ @param [in] ReadOnlyUpdater Function to change RO permissions\r
+ @param [in] ReadWriteUpdater Function to change RW permissions\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UpdateMmFoundationPeCoffPermissions (\r
+ IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
+ IN EFI_PHYSICAL_ADDRESS ImageBase,\r
+ IN UINT32 SectionHeaderOffset,\r
+ IN CONST UINT16 NumberOfSections,\r
+ IN REGION_PERMISSION_UPDATE_FUNC TextUpdater,\r
+ IN REGION_PERMISSION_UPDATE_FUNC ReadOnlyUpdater,\r
+ IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater\r
+ );\r
+\r
+\r
+/**\r
+ Privileged firmware assigns RO & Executable attributes to all memory occupied\r
+ by the Boot Firmware Volume. This function locates the section information of\r
+ the Standalone MM Core module to be able to change permissions of the\r
+ individual sections later in the boot process.\r
+\r
+ @param [in] TeData Pointer to PE/COFF image data\r
+ @param [in, out] ImageContext Pointer to PE/COFF image context\r
+ @param [out] ImageBase Pointer to ImageBase variable\r
+ @param [in, out] SectionHeaderOffset Offset of PE/COFF image section header\r
+ @param [in, out] NumberOfSections Number of Sections\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetStandaloneMmCorePeCoffSections (\r
+ IN VOID *TeData,\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageBase,\r
+ IN OUT UINT32 *SectionHeaderOffset,\r
+ IN OUT UINT16 *NumberOfSections\r
+ );\r
+\r
+\r
+/**\r
+ Privileged firmware assigns RO & Executable attributes to all memory occupied\r
+ by the Boot Firmware Volume. This function locates the Standalone MM Core\r
+ module PE/COFF image in the BFV and returns this information.\r
+\r
+ @param [in] BfvAddress Base Address of Boot Firmware Volume\r
+ @param [in, out] TeData Pointer to address for allocating memory\r
+ for PE/COFF image data\r
+ @param [in, out] TeDataSize Pointer to size of PE/COFF image data\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LocateStandaloneMmCorePeCoffData (\r
+ IN EFI_FIRMWARE_VOLUME_HEADER *BfvAddress,\r
+ IN OUT VOID **TeData,\r
+ IN OUT UINTN *TeDataSize\r
+ );\r
+\r
+\r
+/**\r
+ Use the boot information passed by privileged firmware to populate a HOB list\r
+ suitable for consumption by the MM Core and drivers.\r
+\r
+ @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint\r
+ @param [in] PayloadBootInfo Boot information passed by privileged\r
+ firmware\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+CreateHobListFromBootInfo (\r
+ IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,\r
+ IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo\r
+ );\r
+\r
+\r
+/**\r
+ The entry point of Standalone MM Foundation.\r
+\r
+ @param [in] SharedBufAddress Pointer to the Buffer between SPM and SP.\r
+ @param [in] SharedBufSize Size of the shared buffer.\r
+ @param [in] cookie1 Cookie 1\r
+ @param [in] cookie2 Cookie 2\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN VOID *SharedBufAddress,\r
+ IN UINT64 SharedBufSize,\r
+ IN UINT64 cookie1,\r
+ IN UINT64 cookie2\r
+ );\r
+\r
+\r
+/**\r
+ Auto generated function that calls the library constructors for all of the module's dependent libraries.\r
+\r
+ This function must be called by _ModuleEntryPoint().\r
+ This function calls the set of library constructors for the set of library instances\r
+ that a module depends on. This includes library instances that a module depends on\r
+ directly and library instances that a module depends on indirectly through other\r
+ libraries. This function is auto generated by build tools and those build tools are\r
+ responsible for collecting the set of library instances, determine which ones have\r
+ constructors, and calling the library constructors in the proper order based upon\r
+ each of the library instances own dependencies.\r
+\r
+ @param ImageHandle The image handle of the DXE Core.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryConstructorList (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_MM_SYSTEM_TABLE *MmSystemTable\r
+ );\r
+\r
+\r
+/**\r
+ Auto generated function that calls a set of module entry points.\r
+\r
+ This function must be called by _ModuleEntryPoint().\r
+ This function calls the set of module entry points.\r
+ This function is auto generated by build tools and those build tools are responsible\r
+ for collecting the module entry points and calling them in a specified order.\r
+\r
+ @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+ IN VOID *HobStart\r
+ );\r
+\r
+#endif\r