2 HOB Library implementation for Standalone MM Core.
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/HobLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/BaseMemoryLib.h>
17 #include <Guid/MemoryAllocationHob.h>
20 Builds a HOB for a loaded PE32 module.
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.
26 If ModuleName is NULL, then ASSERT().
27 If there is no additional space for HOB creation, then ASSERT().
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.
38 IN CONST EFI_GUID
*ModuleName
,
39 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
40 IN UINT64 ModuleLength
,
41 IN EFI_PHYSICAL_ADDRESS EntryPoint
45 // PEI HOB is read only for MM phase
51 Builds a HOB that describes a chunk of system memory.
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.
57 If there is no additional space for HOB creation, then ASSERT().
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.
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
75 // PEI HOB is read only for MM phase
81 Builds a customized HOB tagged with a GUID for identification and returns
82 the start address of GUID HOB data.
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.
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.
95 @param Guid The GUID to tag the customized HOB.
96 @param DataLength The size of the data payload for the GUID HOB.
98 @retval NULL The GUID HOB could not be allocated.
99 @retval others The start address of GUID HOB data.
105 IN CONST EFI_GUID
*Guid
,
110 // PEI HOB is read only for MM phase
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.
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.
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.
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.
137 @retval NULL The GUID HOB could not be allocated.
138 @retval others The start address of GUID HOB data.
144 IN CONST EFI_GUID
*Guid
,
150 // PEI HOB is read only for MM phase
157 Builds a Firmware Volume HOB.
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.
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().
166 @param BaseAddress The base address of the Firmware Volume.
167 @param Length The size of the Firmware Volume in bytes.
173 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
178 // PEI HOB is read only for MM phase
184 Builds a EFI_HOB_TYPE_FV2 HOB.
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.
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().
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.
202 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
204 IN CONST EFI_GUID
*FvName
,
205 IN CONST EFI_GUID
*FileName
212 Builds a EFI_HOB_TYPE_FV3 HOB.
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.
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().
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.
235 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
237 IN UINT32 AuthenticationStatus
,
238 IN BOOLEAN ExtractedFv
,
239 IN CONST EFI_GUID
*FvName OPTIONAL
,
240 IN CONST EFI_GUID
*FileName OPTIONAL
247 Builds a HOB for the CPU.
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.
253 If there is no additional space for HOB creation, then ASSERT().
255 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
256 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
262 IN UINT8 SizeOfMemorySpace
,
263 IN UINT8 SizeOfIoSpace
267 // PEI HOB is read only for MM phase
273 Builds a HOB for the memory allocation.
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.
279 If there is no additional space for HOB creation, then ASSERT().
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.
288 BuildMemoryAllocationHob (
289 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
291 IN EFI_MEMORY_TYPE MemoryType
295 // PEI HOB is read only for MM phase