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