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