StandaloneMmCoreEntryPoint.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /** @file
  2. Entry point to the Standalone MM Foundation when initialized during the SEC
  3. phase on ARM platforms
  4. Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __STANDALONEMMCORE_ENTRY_POINT_H__
  8. #define __STANDALONEMMCORE_ENTRY_POINT_H__
  9. #include <Library/PeCoffLib.h>
  10. #include <Library/FvLib.h>
  11. #define CPU_INFO_FLAG_PRIMARY_CPU 0x00000001
  12. typedef struct {
  13. UINT8 Type; /* type of the structure */
  14. UINT8 Version; /* version of this structure */
  15. UINT16 Size; /* size of this structure in bytes */
  16. UINT32 Attr; /* attributes: unused bits SBZ */
  17. } EFI_PARAM_HEADER;
  18. typedef struct {
  19. UINT64 Mpidr;
  20. UINT32 LinearId;
  21. UINT32 Flags;
  22. } EFI_SECURE_PARTITION_CPU_INFO;
  23. typedef struct {
  24. EFI_PARAM_HEADER Header;
  25. UINT64 SpMemBase;
  26. UINT64 SpMemLimit;
  27. UINT64 SpImageBase;
  28. UINT64 SpStackBase;
  29. UINT64 SpHeapBase;
  30. UINT64 SpNsCommBufBase;
  31. UINT64 SpSharedBufBase;
  32. UINT64 SpImageSize;
  33. UINT64 SpPcpuStackSize;
  34. UINT64 SpHeapSize;
  35. UINT64 SpNsCommBufSize;
  36. UINT64 SpPcpuSharedBufSize;
  37. UINT32 NumSpMemRegions;
  38. UINT32 NumCpus;
  39. EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
  40. } EFI_SECURE_PARTITION_BOOT_INFO;
  41. typedef
  42. EFI_STATUS
  43. (*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (
  44. IN UINTN EventId,
  45. IN UINTN CpuNumber,
  46. IN UINTN NsCommBufferAddr
  47. );
  48. typedef struct {
  49. PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr;
  50. } ARM_TF_CPU_DRIVER_EP_DESCRIPTOR;
  51. typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
  52. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  53. IN UINT64 Length
  54. );
  55. /**
  56. Privileged firmware assigns RO & Executable attributes to all memory occupied
  57. by the Boot Firmware Volume. This function sets the correct permissions of
  58. sections in the Standalone MM Core module to be able to access RO and RW data
  59. and make further progress in the boot process.
  60. @param [in] ImageContext Pointer to PE/COFF image context
  61. @param [in] ImageBase Base of image in memory
  62. @param [in] SectionHeaderOffset Offset of PE/COFF image section header
  63. @param [in] NumberOfSections Number of Sections
  64. @param [in] TextUpdater Function to change code permissions
  65. @param [in] ReadOnlyUpdater Function to change RO permissions
  66. @param [in] ReadWriteUpdater Function to change RW permissions
  67. **/
  68. EFI_STATUS
  69. EFIAPI
  70. UpdateMmFoundationPeCoffPermissions (
  71. IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
  72. IN EFI_PHYSICAL_ADDRESS ImageBase,
  73. IN UINT32 SectionHeaderOffset,
  74. IN CONST UINT16 NumberOfSections,
  75. IN REGION_PERMISSION_UPDATE_FUNC TextUpdater,
  76. IN REGION_PERMISSION_UPDATE_FUNC ReadOnlyUpdater,
  77. IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
  78. );
  79. /**
  80. Privileged firmware assigns RO & Executable attributes to all memory occupied
  81. by the Boot Firmware Volume. This function locates the section information of
  82. the Standalone MM Core module to be able to change permissions of the
  83. individual sections later in the boot process.
  84. @param [in] TeData Pointer to PE/COFF image data
  85. @param [in, out] ImageContext Pointer to PE/COFF image context
  86. @param [out] ImageBase Pointer to ImageBase variable
  87. @param [in, out] SectionHeaderOffset Offset of PE/COFF image section header
  88. @param [in, out] NumberOfSections Number of Sections
  89. **/
  90. EFI_STATUS
  91. EFIAPI
  92. GetStandaloneMmCorePeCoffSections (
  93. IN VOID *TeData,
  94. IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
  95. OUT EFI_PHYSICAL_ADDRESS *ImageBase,
  96. IN OUT UINT32 *SectionHeaderOffset,
  97. IN OUT UINT16 *NumberOfSections
  98. );
  99. /**
  100. Privileged firmware assigns RO & Executable attributes to all memory occupied
  101. by the Boot Firmware Volume. This function locates the Standalone MM Core
  102. module PE/COFF image in the BFV and returns this information.
  103. @param [in] BfvAddress Base Address of Boot Firmware Volume
  104. @param [in, out] TeData Pointer to address for allocating memory
  105. for PE/COFF image data
  106. @param [in, out] TeDataSize Pointer to size of PE/COFF image data
  107. **/
  108. EFI_STATUS
  109. EFIAPI
  110. LocateStandaloneMmCorePeCoffData (
  111. IN EFI_FIRMWARE_VOLUME_HEADER *BfvAddress,
  112. IN OUT VOID **TeData,
  113. IN OUT UINTN *TeDataSize
  114. );
  115. /**
  116. Use the boot information passed by privileged firmware to populate a HOB list
  117. suitable for consumption by the MM Core and drivers.
  118. @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
  119. @param [in] PayloadBootInfo Boot information passed by privileged
  120. firmware
  121. **/
  122. VOID *
  123. EFIAPI
  124. CreateHobListFromBootInfo (
  125. IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
  126. IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
  127. );
  128. /**
  129. The entry point of Standalone MM Foundation.
  130. @param [in] SharedBufAddress Pointer to the Buffer between SPM and SP.
  131. @param [in] SharedBufSize Size of the shared buffer.
  132. @param [in] cookie1 Cookie 1
  133. @param [in] cookie2 Cookie 2
  134. **/
  135. VOID
  136. EFIAPI
  137. _ModuleEntryPoint (
  138. IN VOID *SharedBufAddress,
  139. IN UINT64 SharedBufSize,
  140. IN UINT64 cookie1,
  141. IN UINT64 cookie2
  142. );
  143. /**
  144. Auto generated function that calls the library constructors for all of the module's dependent libraries.
  145. This function must be called by _ModuleEntryPoint().
  146. This function calls the set of library constructors for the set of library instances
  147. that a module depends on. This includes library instances that a module depends on
  148. directly and library instances that a module depends on indirectly through other
  149. libraries. This function is auto generated by build tools and those build tools are
  150. responsible for collecting the set of library instances, determine which ones have
  151. constructors, and calling the library constructors in the proper order based upon
  152. each of the library instances own dependencies.
  153. @param ImageHandle The image handle of the DXE Core.
  154. @param SystemTable A pointer to the EFI System Table.
  155. **/
  156. VOID
  157. EFIAPI
  158. ProcessLibraryConstructorList (
  159. IN EFI_HANDLE ImageHandle,
  160. IN EFI_MM_SYSTEM_TABLE *MmSystemTable
  161. );
  162. /**
  163. Auto generated function that calls a set of module entry points.
  164. This function must be called by _ModuleEntryPoint().
  165. This function calls the set of module entry points.
  166. This function is auto generated by build tools and those build tools are responsible
  167. for collecting the module entry points and calling them in a specified order.
  168. @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
  169. **/
  170. VOID
  171. EFIAPI
  172. ProcessModuleEntryPointList (
  173. IN VOID *HobStart
  174. );
  175. #endif