]> git.proxmox.com Git - mirror_edk2.git/blob - StandaloneMmPkg/Library/StandaloneMmCoreHobLib/X64/StandaloneMmCoreHobLib.c
StandaloneMmPkg: Change OPTIONAL keyword usage style
[mirror_edk2.git] / StandaloneMmPkg / Library / StandaloneMmCoreHobLib / X64 / StandaloneMmCoreHobLib.c
1 /** @file
2 HOB Library implementation for Standalone MM Core.
3
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include <PiMm.h>
12
13 #include <Library/HobLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/BaseMemoryLib.h>
16
17 #include <Guid/MemoryAllocationHob.h>
18
19 /**
20 Builds a HOB for a loaded PE32 module.
21
22 This function builds a HOB for a loaded PE32 module.
23 It can only be invoked during PEI phase;
24 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
25
26 If ModuleName is NULL, then ASSERT().
27 If there is no additional space for HOB creation, then ASSERT().
28
29 @param ModuleName The GUID File Name of the module.
30 @param MemoryAllocationModule The 64 bit physical address of the module.
31 @param ModuleLength The length of the module in bytes.
32 @param EntryPoint The 64 bit physical address of the module entry point.
33
34 **/
35 VOID
36 EFIAPI
37 BuildModuleHob (
38 IN CONST EFI_GUID *ModuleName,
39 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
40 IN UINT64 ModuleLength,
41 IN EFI_PHYSICAL_ADDRESS EntryPoint
42 )
43 {
44 //
45 // PEI HOB is read only for MM phase
46 //
47 ASSERT (FALSE);
48 }
49
50 /**
51 Builds a HOB that describes a chunk of system memory.
52
53 This function builds a HOB that describes a chunk of system memory.
54 It can only be invoked during PEI phase;
55 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
56
57 If there is no additional space for HOB creation, then ASSERT().
58
59 @param ResourceType The type of resource described by this HOB.
60 @param ResourceAttribute The resource attributes of the memory described by this HOB.
61 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
62 @param NumberOfBytes The length of the memory described by this HOB in bytes.
63
64 **/
65 VOID
66 EFIAPI
67 BuildResourceDescriptorHob (
68 IN EFI_RESOURCE_TYPE ResourceType,
69 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
70 IN EFI_PHYSICAL_ADDRESS PhysicalStart,
71 IN UINT64 NumberOfBytes
72 )
73 {
74 //
75 // PEI HOB is read only for MM phase
76 //
77 ASSERT (FALSE);
78 }
79
80 /**
81 Builds a customized HOB tagged with a GUID for identification and returns
82 the start address of GUID HOB data.
83
84 This function builds a customized HOB tagged with a GUID for identification
85 and returns the start address of GUID HOB data so that caller can fill the customized data.
86 The HOB Header and Name field is already stripped.
87 It can only be invoked during PEI phase.
88 For MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
89
90 If Guid is NULL, then ASSERT().
91 If there is no additional space for HOB creation, then ASSERT().
92 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
93 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
94
95 @param Guid The GUID to tag the customized HOB.
96 @param DataLength The size of the data payload for the GUID HOB.
97
98 @retval NULL The GUID HOB could not be allocated.
99 @retval others The start address of GUID HOB data.
100
101 **/
102 VOID *
103 EFIAPI
104 BuildGuidHob (
105 IN CONST EFI_GUID *Guid,
106 IN UINTN DataLength
107 )
108 {
109 //
110 // PEI HOB is read only for MM phase
111 //
112 ASSERT (FALSE);
113 return NULL;
114 }
115
116 /**
117 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
118 data field, and returns the start address of the GUID HOB data.
119
120 This function builds a customized HOB tagged with a GUID for identification and copies the input
121 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
122 invoked during PEI phase; for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
123 The HOB Header and Name field is already stripped.
124 It can only be invoked during PEI phase.
125 For MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
126
127 If Guid is NULL, then ASSERT().
128 If Data is NULL and DataLength > 0, then ASSERT().
129 If there is no additional space for HOB creation, then ASSERT().
130 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
131 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
132
133 @param Guid The GUID to tag the customized HOB.
134 @param Data The data to be copied into the data field of the GUID HOB.
135 @param DataLength The size of the data payload for the GUID HOB.
136
137 @retval NULL The GUID HOB could not be allocated.
138 @retval others The start address of GUID HOB data.
139
140 **/
141 VOID *
142 EFIAPI
143 BuildGuidDataHob (
144 IN CONST EFI_GUID *Guid,
145 IN VOID *Data,
146 IN UINTN DataLength
147 )
148 {
149 //
150 // PEI HOB is read only for MM phase
151 //
152 ASSERT (FALSE);
153 return NULL;
154 }
155
156 /**
157 Builds a Firmware Volume HOB.
158
159 This function builds a Firmware Volume HOB.
160 It can only be invoked during PEI phase;
161 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
162
163 If there is no additional space for HOB creation, then ASSERT().
164 If the FvImage buffer is not at its required alignment, then ASSERT().
165
166 @param BaseAddress The base address of the Firmware Volume.
167 @param Length The size of the Firmware Volume in bytes.
168
169 **/
170 VOID
171 EFIAPI
172 BuildFvHob (
173 IN EFI_PHYSICAL_ADDRESS BaseAddress,
174 IN UINT64 Length
175 )
176 {
177 //
178 // PEI HOB is read only for MM phase
179 //
180 ASSERT (FALSE);
181 }
182
183 /**
184 Builds a EFI_HOB_TYPE_FV2 HOB.
185
186 This function builds a EFI_HOB_TYPE_FV2 HOB.
187 It can only be invoked during PEI phase;
188 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
189
190 If there is no additional space for HOB creation, then ASSERT().
191 If the FvImage buffer is not at its required alignment, then ASSERT().
192
193 @param BaseAddress The base address of the Firmware Volume.
194 @param Length The size of the Firmware Volume in bytes.
195 @param FvName The name of the Firmware Volume.
196 @param FileName The name of the file.
197
198 **/
199 VOID
200 EFIAPI
201 BuildFv2Hob (
202 IN EFI_PHYSICAL_ADDRESS BaseAddress,
203 IN UINT64 Length,
204 IN CONST EFI_GUID *FvName,
205 IN CONST EFI_GUID *FileName
206 )
207 {
208 ASSERT (FALSE);
209 }
210
211 /**
212 Builds a EFI_HOB_TYPE_FV3 HOB.
213
214 This function builds a EFI_HOB_TYPE_FV3 HOB.
215 It can only be invoked during PEI phase;
216 for MM phase, it will ASSERT() since PEI HOB is read-only for MM phase.
217
218 If there is no additional space for HOB creation, then ASSERT().
219 If the FvImage buffer is not at its required alignment, then ASSERT().
220
221 @param BaseAddress The base address of the Firmware Volume.
222 @param Length The size of the Firmware Volume in bytes.
223 @param AuthenticationStatus The authentication status.
224 @param ExtractedFv TRUE if the FV was extracted as a file within
225 another firmware volume. FALSE otherwise.
226 @param FvName The name of the Firmware Volume.
227 Valid only if IsExtractedFv is TRUE.
228 @param FileName The name of the file.
229 Valid only if IsExtractedFv is TRUE.
230
231 **/
232 VOID
233 EFIAPI
234 BuildFv3Hob (
235 IN EFI_PHYSICAL_ADDRESS BaseAddress,
236 IN UINT64 Length,
237 IN UINT32 AuthenticationStatus,
238 IN BOOLEAN ExtractedFv,
239 IN CONST EFI_GUID *FvName OPTIONAL,
240 IN CONST EFI_GUID *FileName OPTIONAL
241 )
242 {
243 ASSERT (FALSE);
244 }
245
246 /**
247 Builds a HOB for the CPU.
248
249 This function builds a HOB for the CPU.
250 It can only be invoked during PEI phase;
251 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
252
253 If there is no additional space for HOB creation, then ASSERT().
254
255 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
256 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
257
258 **/
259 VOID
260 EFIAPI
261 BuildCpuHob (
262 IN UINT8 SizeOfMemorySpace,
263 IN UINT8 SizeOfIoSpace
264 )
265 {
266 //
267 // PEI HOB is read only for MM phase
268 //
269 ASSERT (FALSE);
270 }
271
272 /**
273 Builds a HOB for the memory allocation.
274
275 This function builds a HOB for the memory allocation.
276 It can only be invoked during PEI phase;
277 for MM phase, it will ASSERT() because PEI HOB is read-only for MM phase.
278
279 If there is no additional space for HOB creation, then ASSERT().
280
281 @param BaseAddress The 64 bit physical address of the memory.
282 @param Length The length of the memory allocation in bytes.
283 @param MemoryType Type of memory allocated by this HOB.
284
285 **/
286 VOID
287 EFIAPI
288 BuildMemoryAllocationHob (
289 IN EFI_PHYSICAL_ADDRESS BaseAddress,
290 IN UINT64 Length,
291 IN EFI_MEMORY_TYPE MemoryType
292 )
293 {
294 //
295 // PEI HOB is read only for MM phase
296 //
297 ASSERT (FALSE);
298 }