]> git.proxmox.com Git - mirror_edk2.git/blob - StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
StandaloneMmPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / StandaloneMmPkg / Include / Library / AArch64 / 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 - 2018, 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 ImageContext Pointer to PE/COFF image context
74 @param SectionHeaderOffset Offset of PE/COFF image section header
75 @param NumberOfSections Number of Sections
76 @param TextUpdater Function to change code permissions
77 @param ReadOnlyUpdater Function to change RO permissions
78 @param ReadWriteUpdater Function to change RW permissions
79
80 **/
81 EFI_STATUS
82 EFIAPI
83 UpdateMmFoundationPeCoffPermissions (
84 IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
85 IN UINT32 SectionHeaderOffset,
86 IN CONST UINT16 NumberOfSections,
87 IN REGION_PERMISSION_UPDATE_FUNC TextUpdater,
88 IN REGION_PERMISSION_UPDATE_FUNC ReadOnlyUpdater,
89 IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
90 );
91
92
93 /**
94 Privileged firmware assigns RO & Executable attributes to all memory occupied
95 by the Boot Firmware Volume. This function locates the section information of
96 the Standalone MM Core module to be able to change permissions of the
97 individual sections later in the boot process.
98
99 @param TeData Pointer to PE/COFF image data
100 @param ImageContext Pointer to PE/COFF image context
101 @param SectionHeaderOffset Offset of PE/COFF image section header
102 @param NumberOfSections Number of Sections
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 GetStandaloneMmCorePeCoffSections (
108 IN VOID *TeData,
109 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
110 IN OUT UINT32 *SectionHeaderOffset,
111 IN OUT UINT16 *NumberOfSections
112 );
113
114
115 /**
116 Privileged firmware assigns RO & Executable attributes to all memory occupied
117 by the Boot Firmware Volume. This function locates the Standalone MM Core
118 module PE/COFF image in the BFV and returns this information.
119
120 @param BfvAddress Base Address of Boot Firmware Volume
121 @param TeData Pointer to address for allocating memory for
122 PE/COFF image data
123 @param TeDataSize Pointer to size of PE/COFF image data
124
125 **/
126 EFI_STATUS
127 EFIAPI
128 LocateStandaloneMmCorePeCoffData (
129 IN EFI_FIRMWARE_VOLUME_HEADER *BfvAddress,
130 IN OUT VOID **TeData,
131 IN OUT UINTN *TeDataSize
132 );
133
134
135 /**
136 Use the boot information passed by privileged firmware to populate a HOB list
137 suitable for consumption by the MM Core and drivers.
138
139 @param CpuDriverEntryPoint Address of MM CPU driver entrypoint
140 @param PayloadBootInfo Boot information passed by privileged firmware
141
142 **/
143 VOID *
144 EFIAPI
145 CreateHobListFromBootInfo (
146 IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
147 IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
148 );
149
150
151 /**
152 The entry point of Standalone MM Foundation.
153
154 @param SharedBufAddress Pointer to the Buffer between SPM and SP.
155 @param cookie1.
156 @param cookie2.
157 **/
158 VOID
159 EFIAPI
160 _ModuleEntryPoint (
161 IN VOID *SharedBufAddress,
162 IN UINT64 SharedBufSize,
163 IN UINT64 cookie1,
164 IN UINT64 cookie2
165 );
166
167
168 /**
169 Auto generated function that calls the library constructors for all of the module's dependent libraries.
170
171 This function must be called by _ModuleEntryPoint().
172 This function calls the set of library constructors for the set of library instances
173 that a module depends on. This includes library instances that a module depends on
174 directly and library instances that a module depends on indirectly through other
175 libraries. This function is auto generated by build tools and those build tools are
176 responsible for collecting the set of library instances, determine which ones have
177 constructors, and calling the library constructors in the proper order based upon
178 each of the library instances own dependencies.
179
180 @param ImageHandle The image handle of the DXE Core.
181 @param SystemTable A pointer to the EFI System Table.
182
183 **/
184 VOID
185 EFIAPI
186 ProcessLibraryConstructorList (
187 IN EFI_HANDLE ImageHandle,
188 IN EFI_MM_SYSTEM_TABLE *MmSystemTable
189 );
190
191
192 /**
193 Auto generated function that calls a set of module entry points.
194
195 This function must be called by _ModuleEntryPoint().
196 This function calls the set of module entry points.
197 This function is auto generated by build tools and those build tools are responsible
198 for collecting the module entry points and calling them in a specified order.
199
200 @param HobStart Pointer to the beginning of the HOB List passed in from the PEI Phase.
201
202 **/
203 VOID
204 EFIAPI
205 ProcessModuleEntryPointList (
206 IN VOID *HobStart
207 );
208
209 #endif