]>
Commit | Line | Data |
---|---|---|
380148b6 AB |
1 | /** @file\r |
2 | HOB Library implementation for Standalone MM Core.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
5 | Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>\r | |
6 | Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r | |
7 | \r | |
86094561 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
380148b6 AB |
9 | \r |
10 | **/\r | |
11 | \r | |
12 | #include <PiMm.h>\r | |
13 | \r | |
14 | #include <Library/HobLib.h>\r | |
15 | #include <Library/DebugLib.h>\r | |
16 | #include <Library/BaseMemoryLib.h>\r | |
17 | #include <Library/MmServicesTableLib.h>\r | |
18 | \r | |
19 | //\r | |
20 | // Cache copy of HobList pointer.\r | |
21 | //\r | |
91415a36 | 22 | STATIC VOID *gHobList = NULL;\r |
380148b6 AB |
23 | \r |
24 | /**\r | |
25 | The constructor function caches the pointer to HOB list.\r | |
26 | \r | |
27 | The constructor function gets the start address of HOB list from system configuration table.\r | |
28 | It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r | |
29 | \r | |
30 | @param ImageHandle The firmware allocated handle for the image.\r | |
31 | @param MmSystemTable A pointer to the MM System Table.\r | |
32 | \r | |
33 | @retval EFI_SUCCESS The constructor successfully gets HobList.\r | |
34 | @retval Other value The constructor can't get HobList.\r | |
35 | \r | |
36 | **/\r | |
37 | EFI_STATUS\r | |
38 | EFIAPI\r | |
39 | HobLibConstructor (\r | |
91415a36 MK |
40 | IN EFI_HANDLE ImageHandle,\r |
41 | IN EFI_MM_SYSTEM_TABLE *MmSystemTable\r | |
380148b6 AB |
42 | )\r |
43 | {\r | |
91415a36 | 44 | UINTN Index;\r |
380148b6 AB |
45 | \r |
46 | for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) {\r | |
47 | if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) {\r | |
48 | gHobList = gMmst->MmConfigurationTable[Index].VendorTable;\r | |
49 | break;\r | |
50 | }\r | |
51 | }\r | |
91415a36 | 52 | \r |
380148b6 AB |
53 | return EFI_SUCCESS;\r |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | Returns the pointer to the HOB list.\r | |
58 | \r | |
59 | This function returns the pointer to first HOB in the list.\r | |
60 | If the pointer to the HOB list is NULL, then ASSERT().\r | |
61 | \r | |
62 | @return The pointer to the HOB list.\r | |
63 | \r | |
64 | **/\r | |
65 | VOID *\r | |
66 | EFIAPI\r | |
67 | GetHobList (\r | |
68 | VOID\r | |
69 | )\r | |
70 | {\r | |
91415a36 | 71 | UINTN Index;\r |
380148b6 AB |
72 | \r |
73 | if (gHobList == NULL) {\r | |
74 | for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) {\r | |
75 | if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) {\r | |
76 | gHobList = gMmst->MmConfigurationTable[Index].VendorTable;\r | |
77 | break;\r | |
78 | }\r | |
79 | }\r | |
80 | }\r | |
91415a36 | 81 | \r |
380148b6 AB |
82 | ASSERT (gHobList != NULL);\r |
83 | return gHobList;\r | |
84 | }\r | |
85 | \r | |
86 | /**\r | |
87 | Returns the next instance of a HOB type from the starting HOB.\r | |
88 | \r | |
89 | This function searches the first instance of a HOB type from the starting HOB pointer.\r | |
90 | If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r | |
91 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
92 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
93 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
94 | \r | |
95 | If HobStart is NULL, then ASSERT().\r | |
96 | \r | |
97 | @param Type The HOB type to return.\r | |
98 | @param HobStart The starting HOB pointer to search from.\r | |
99 | \r | |
100 | @return The next instance of a HOB type from the starting HOB.\r | |
101 | \r | |
102 | **/\r | |
103 | VOID *\r | |
104 | EFIAPI\r | |
105 | GetNextHob (\r | |
91415a36 MK |
106 | IN UINT16 Type,\r |
107 | IN CONST VOID *HobStart\r | |
380148b6 AB |
108 | )\r |
109 | {\r | |
110 | EFI_PEI_HOB_POINTERS Hob;\r | |
111 | \r | |
112 | ASSERT (HobStart != NULL);\r | |
113 | \r | |
91415a36 | 114 | Hob.Raw = (UINT8 *)HobStart;\r |
380148b6 AB |
115 | //\r |
116 | // Parse the HOB list until end of list or matching type is found.\r | |
117 | //\r | |
118 | while (!END_OF_HOB_LIST (Hob)) {\r | |
119 | if (Hob.Header->HobType == Type) {\r | |
120 | return Hob.Raw;\r | |
121 | }\r | |
91415a36 | 122 | \r |
380148b6 AB |
123 | Hob.Raw = GET_NEXT_HOB (Hob);\r |
124 | }\r | |
91415a36 | 125 | \r |
380148b6 AB |
126 | return NULL;\r |
127 | }\r | |
128 | \r | |
129 | /**\r | |
130 | Returns the first instance of a HOB type among the whole HOB list.\r | |
131 | \r | |
132 | This function searches the first instance of a HOB type among the whole HOB list.\r | |
133 | If there does not exist such HOB type in the HOB list, it will return NULL.\r | |
134 | \r | |
135 | If the pointer to the HOB list is NULL, then ASSERT().\r | |
136 | \r | |
137 | @param Type The HOB type to return.\r | |
138 | \r | |
139 | @return The next instance of a HOB type from the starting HOB.\r | |
140 | \r | |
141 | **/\r | |
142 | VOID *\r | |
143 | EFIAPI\r | |
144 | GetFirstHob (\r | |
91415a36 | 145 | IN UINT16 Type\r |
380148b6 AB |
146 | )\r |
147 | {\r | |
91415a36 | 148 | VOID *HobList;\r |
380148b6 AB |
149 | \r |
150 | HobList = GetHobList ();\r | |
151 | return GetNextHob (Type, HobList);\r | |
152 | }\r | |
153 | \r | |
154 | /**\r | |
155 | Returns the next instance of the matched GUID HOB from the starting HOB.\r | |
156 | \r | |
157 | This function searches the first instance of a HOB from the starting HOB pointer.\r | |
158 | Such HOB should satisfy two conditions:\r | |
159 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION, and its GUID Name equals to the input Guid.\r | |
160 | If such a HOB from the starting HOB pointer does not exist, it will return NULL.\r | |
161 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
162 | to extract the data section and its size information, respectively.\r | |
163 | In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r | |
164 | unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r | |
165 | caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r | |
166 | \r | |
167 | If Guid is NULL, then ASSERT().\r | |
168 | If HobStart is NULL, then ASSERT().\r | |
169 | \r | |
170 | @param Guid The GUID to match with in the HOB list.\r | |
171 | @param HobStart A pointer to a Guid.\r | |
172 | \r | |
173 | @return The next instance of the matched GUID HOB from the starting HOB.\r | |
174 | \r | |
175 | **/\r | |
176 | VOID *\r | |
177 | EFIAPI\r | |
178 | GetNextGuidHob (\r | |
91415a36 MK |
179 | IN CONST EFI_GUID *Guid,\r |
180 | IN CONST VOID *HobStart\r | |
380148b6 AB |
181 | )\r |
182 | {\r | |
183 | EFI_PEI_HOB_POINTERS GuidHob;\r | |
184 | \r | |
91415a36 | 185 | GuidHob.Raw = (UINT8 *)HobStart;\r |
380148b6 AB |
186 | while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r |
187 | if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r | |
188 | break;\r | |
189 | }\r | |
91415a36 | 190 | \r |
380148b6 AB |
191 | GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r |
192 | }\r | |
91415a36 | 193 | \r |
380148b6 AB |
194 | return GuidHob.Raw;\r |
195 | }\r | |
196 | \r | |
197 | /**\r | |
198 | Returns the first instance of the matched GUID HOB among the whole HOB list.\r | |
199 | \r | |
200 | This function searches the first instance of a HOB among the whole HOB list.\r | |
201 | Such HOB should satisfy two conditions:\r | |
202 | its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r | |
203 | If such a HOB from the starting HOB pointer does not exist, it will return NULL.\r | |
204 | Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r | |
205 | to extract the data section and its size information, respectively.\r | |
206 | \r | |
207 | If the pointer to the HOB list is NULL, then ASSERT().\r | |
208 | If Guid is NULL, then ASSERT().\r | |
209 | \r | |
210 | @param Guid The GUID to match with in the HOB list.\r | |
211 | \r | |
212 | @return The first instance of the matched GUID HOB among the whole HOB list.\r | |
213 | \r | |
214 | **/\r | |
215 | VOID *\r | |
216 | EFIAPI\r | |
217 | GetFirstGuidHob (\r | |
91415a36 | 218 | IN CONST EFI_GUID *Guid\r |
380148b6 AB |
219 | )\r |
220 | {\r | |
91415a36 | 221 | VOID *HobList;\r |
380148b6 AB |
222 | \r |
223 | HobList = GetHobList ();\r | |
224 | return GetNextGuidHob (Guid, HobList);\r | |
225 | }\r | |
226 | \r | |
227 | /**\r | |
228 | Get the system boot mode from the HOB list.\r | |
229 | \r | |
230 | This function returns the system boot mode information from the\r | |
231 | PHIT HOB in HOB list.\r | |
232 | \r | |
233 | If the pointer to the HOB list is NULL, then ASSERT().\r | |
234 | \r | |
235 | @param VOID\r | |
236 | \r | |
237 | @return The Boot Mode.\r | |
238 | \r | |
239 | **/\r | |
240 | EFI_BOOT_MODE\r | |
241 | EFIAPI\r | |
242 | GetBootModeHob (\r | |
243 | VOID\r | |
244 | )\r | |
245 | {\r | |
91415a36 | 246 | EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;\r |
380148b6 | 247 | \r |
91415a36 | 248 | HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();\r |
380148b6 | 249 | \r |
91415a36 | 250 | return HandOffHob->BootMode;\r |
380148b6 AB |
251 | }\r |
252 | \r | |
253 | VOID *\r | |
254 | CreateHob (\r | |
91415a36 MK |
255 | IN UINT16 HobType,\r |
256 | IN UINT16 HobLength\r | |
380148b6 AB |
257 | )\r |
258 | {\r | |
259 | EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;\r | |
260 | EFI_HOB_GENERIC_HEADER *HobEnd;\r | |
261 | EFI_PHYSICAL_ADDRESS FreeMemory;\r | |
262 | VOID *Hob;\r | |
263 | \r | |
264 | HandOffHob = GetHobList ();\r | |
265 | \r | |
266 | HobLength = (UINT16)((HobLength + 0x7) & (~0x7));\r | |
267 | \r | |
268 | FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom;\r | |
269 | \r | |
270 | if (FreeMemory < HobLength) {\r | |
91415a36 | 271 | return NULL;\r |
380148b6 AB |
272 | }\r |
273 | \r | |
91415a36 MK |
274 | Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;\r |
275 | ((EFI_HOB_GENERIC_HEADER *)Hob)->HobType = HobType;\r | |
276 | ((EFI_HOB_GENERIC_HEADER *)Hob)->HobLength = HobLength;\r | |
277 | ((EFI_HOB_GENERIC_HEADER *)Hob)->Reserved = 0;\r | |
380148b6 | 278 | \r |
91415a36 MK |
279 | HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob + HobLength);\r |
280 | HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;\r | |
380148b6 AB |
281 | \r |
282 | HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;\r | |
91415a36 | 283 | HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);\r |
380148b6 AB |
284 | HobEnd->Reserved = 0;\r |
285 | HobEnd++;\r | |
91415a36 | 286 | HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;\r |
380148b6 AB |
287 | \r |
288 | return Hob;\r | |
289 | }\r | |
290 | \r | |
291 | /**\r | |
292 | Builds a HOB for a loaded PE32 module.\r | |
293 | \r | |
294 | This function builds a HOB for a loaded PE32 module.\r | |
295 | If ModuleName is NULL, then ASSERT().\r | |
296 | If there is no additional space for HOB creation, then ASSERT().\r | |
297 | \r | |
298 | @param ModuleName The GUID File Name of the module.\r | |
299 | @param MemoryAllocationModule The 64 bit physical address of the module.\r | |
300 | @param ModuleLength The length of the module in bytes.\r | |
301 | @param EntryPoint The 64 bit physical address of the module entry point.\r | |
302 | \r | |
303 | **/\r | |
304 | VOID\r | |
305 | EFIAPI\r | |
306 | BuildModuleHob (\r | |
91415a36 MK |
307 | IN CONST EFI_GUID *ModuleName,\r |
308 | IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r | |
309 | IN UINT64 ModuleLength,\r | |
310 | IN EFI_PHYSICAL_ADDRESS EntryPoint\r | |
380148b6 AB |
311 | )\r |
312 | {\r | |
313 | EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;\r | |
314 | \r | |
91415a36 MK |
315 | ASSERT (\r |
316 | ((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
317 | ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)\r | |
318 | );\r | |
380148b6 AB |
319 | \r |
320 | Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r | |
321 | \r | |
322 | CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r | |
323 | Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r | |
324 | Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r | |
325 | Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r | |
326 | \r | |
327 | //\r | |
328 | // Zero the reserved space to match HOB spec\r | |
329 | //\r | |
330 | ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r | |
331 | \r | |
332 | CopyGuid (&Hob->ModuleName, ModuleName);\r | |
333 | Hob->EntryPoint = EntryPoint;\r | |
334 | }\r | |
335 | \r | |
336 | /**\r | |
337 | Builds a HOB that describes a chunk of system memory.\r | |
338 | \r | |
339 | This function builds a HOB that describes a chunk of system memory.\r | |
340 | If there is no additional space for HOB creation, then ASSERT().\r | |
341 | \r | |
342 | @param ResourceType The type of resource described by this HOB.\r | |
343 | @param ResourceAttribute The resource attributes of the memory described by this HOB.\r | |
344 | @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r | |
345 | @param NumberOfBytes The length of the memory described by this HOB in bytes.\r | |
346 | \r | |
347 | **/\r | |
348 | VOID\r | |
349 | EFIAPI\r | |
350 | BuildResourceDescriptorHob (\r | |
351 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
352 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
353 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
354 | IN UINT64 NumberOfBytes\r | |
355 | )\r | |
356 | {\r | |
357 | EFI_HOB_RESOURCE_DESCRIPTOR *Hob;\r | |
358 | \r | |
359 | Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r | |
91415a36 | 360 | ASSERT (Hob != NULL);\r |
380148b6 AB |
361 | \r |
362 | Hob->ResourceType = ResourceType;\r | |
363 | Hob->ResourceAttribute = ResourceAttribute;\r | |
364 | Hob->PhysicalStart = PhysicalStart;\r | |
365 | Hob->ResourceLength = NumberOfBytes;\r | |
366 | }\r | |
367 | \r | |
368 | /**\r | |
369 | Builds a GUID HOB with a certain data length.\r | |
370 | \r | |
371 | This function builds a customized HOB tagged with a GUID for identification\r | |
372 | and returns the start address of GUID HOB data so that caller can fill the customized data.\r | |
373 | The HOB Header and Name field is already stripped.\r | |
374 | If Guid is NULL, then ASSERT().\r | |
375 | If there is no additional space for HOB creation, then ASSERT().\r | |
376 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
377 | \r | |
378 | @param Guid The GUID to tag the customized HOB.\r | |
379 | @param DataLength The size of the data payload for the GUID HOB.\r | |
380 | \r | |
381 | @return The start address of GUID HOB data.\r | |
382 | \r | |
383 | **/\r | |
384 | VOID *\r | |
385 | EFIAPI\r | |
386 | BuildGuidHob (\r | |
91415a36 MK |
387 | IN CONST EFI_GUID *Guid,\r |
388 | IN UINTN DataLength\r | |
380148b6 AB |
389 | )\r |
390 | {\r | |
91415a36 | 391 | EFI_HOB_GUID_TYPE *Hob;\r |
380148b6 AB |
392 | \r |
393 | //\r | |
394 | // Make sure that data length is not too long.\r | |
395 | //\r | |
396 | ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r | |
397 | \r | |
91415a36 | 398 | Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r |
380148b6 AB |
399 | CopyGuid (&Hob->Name, Guid);\r |
400 | return Hob + 1;\r | |
401 | }\r | |
402 | \r | |
380148b6 AB |
403 | /**\r |
404 | Copies a data buffer to a newly-built HOB.\r | |
405 | \r | |
406 | This function builds a customized HOB tagged with a GUID for identification,\r | |
407 | copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r | |
408 | The HOB Header and Name field is already stripped.\r | |
409 | If Guid is NULL, then ASSERT().\r | |
410 | If Data is NULL and DataLength > 0, then ASSERT().\r | |
411 | If there is no additional space for HOB creation, then ASSERT().\r | |
412 | If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r | |
413 | \r | |
414 | @param Guid The GUID to tag the customized HOB.\r | |
415 | @param Data The data to be copied into the data field of the GUID HOB.\r | |
416 | @param DataLength The size of the data payload for the GUID HOB.\r | |
417 | \r | |
418 | @return The start address of GUID HOB data.\r | |
419 | \r | |
420 | **/\r | |
421 | VOID *\r | |
422 | EFIAPI\r | |
423 | BuildGuidDataHob (\r | |
91415a36 MK |
424 | IN CONST EFI_GUID *Guid,\r |
425 | IN VOID *Data,\r | |
426 | IN UINTN DataLength\r | |
380148b6 AB |
427 | )\r |
428 | {\r | |
429 | VOID *HobData;\r | |
430 | \r | |
431 | ASSERT (Data != NULL || DataLength == 0);\r | |
432 | \r | |
433 | HobData = BuildGuidHob (Guid, DataLength);\r | |
434 | \r | |
435 | return CopyMem (HobData, Data, DataLength);\r | |
436 | }\r | |
437 | \r | |
438 | /**\r | |
439 | Builds a Firmware Volume HOB.\r | |
440 | \r | |
441 | This function builds a Firmware Volume HOB.\r | |
442 | If there is no additional space for HOB creation, then ASSERT().\r | |
443 | \r | |
444 | @param BaseAddress The base address of the Firmware Volume.\r | |
445 | @param Length The size of the Firmware Volume in bytes.\r | |
446 | \r | |
447 | **/\r | |
448 | VOID\r | |
449 | EFIAPI\r | |
450 | BuildFvHob (\r | |
91415a36 MK |
451 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
452 | IN UINT64 Length\r | |
380148b6 AB |
453 | )\r |
454 | {\r | |
455 | EFI_HOB_FIRMWARE_VOLUME *Hob;\r | |
456 | \r | |
457 | Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r | |
458 | \r | |
459 | Hob->BaseAddress = BaseAddress;\r | |
460 | Hob->Length = Length;\r | |
461 | }\r | |
462 | \r | |
380148b6 AB |
463 | /**\r |
464 | Builds a EFI_HOB_TYPE_FV2 HOB.\r | |
465 | \r | |
466 | This function builds a EFI_HOB_TYPE_FV2 HOB.\r | |
467 | If there is no additional space for HOB creation, then ASSERT().\r | |
468 | \r | |
469 | @param BaseAddress The base address of the Firmware Volume.\r | |
470 | @param Length The size of the Firmware Volume in bytes.\r | |
471 | @param FvName The name of the Firmware Volume.\r | |
472 | @param FileName The name of the file.\r | |
473 | \r | |
474 | **/\r | |
475 | VOID\r | |
476 | EFIAPI\r | |
477 | BuildFv2Hob (\r | |
91415a36 MK |
478 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
479 | IN UINT64 Length,\r | |
480 | IN CONST EFI_GUID *FvName,\r | |
481 | IN CONST EFI_GUID *FileName\r | |
380148b6 AB |
482 | )\r |
483 | {\r | |
484 | EFI_HOB_FIRMWARE_VOLUME2 *Hob;\r | |
485 | \r | |
486 | Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r | |
487 | \r | |
488 | Hob->BaseAddress = BaseAddress;\r | |
489 | Hob->Length = Length;\r | |
490 | CopyGuid (&Hob->FvName, FvName);\r | |
491 | CopyGuid (&Hob->FileName, FileName);\r | |
492 | }\r | |
493 | \r | |
380148b6 AB |
494 | /**\r |
495 | Builds a HOB for the CPU.\r | |
496 | \r | |
497 | This function builds a HOB for the CPU.\r | |
498 | If there is no additional space for HOB creation, then ASSERT().\r | |
499 | \r | |
500 | @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r | |
501 | @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r | |
502 | \r | |
503 | **/\r | |
504 | VOID\r | |
505 | EFIAPI\r | |
506 | BuildCpuHob (\r | |
91415a36 MK |
507 | IN UINT8 SizeOfMemorySpace,\r |
508 | IN UINT8 SizeOfIoSpace\r | |
380148b6 AB |
509 | )\r |
510 | {\r | |
511 | EFI_HOB_CPU *Hob;\r | |
512 | \r | |
513 | Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r | |
514 | \r | |
515 | Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r | |
516 | Hob->SizeOfIoSpace = SizeOfIoSpace;\r | |
517 | \r | |
518 | //\r | |
519 | // Zero the reserved space to match HOB spec\r | |
520 | //\r | |
521 | ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));\r | |
522 | }\r | |
523 | \r | |
524 | /**\r | |
525 | Builds a HOB for the memory allocation.\r | |
526 | \r | |
527 | This function builds a HOB for the memory allocation.\r | |
528 | If there is no additional space for HOB creation, then ASSERT().\r | |
529 | \r | |
530 | @param BaseAddress The 64 bit physical address of the memory.\r | |
531 | @param Length The length of the memory allocation in bytes.\r | |
532 | @param MemoryType Type of memory allocated by this HOB.\r | |
533 | \r | |
534 | **/\r | |
535 | VOID\r | |
536 | EFIAPI\r | |
537 | BuildMemoryAllocationHob (\r | |
91415a36 MK |
538 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
539 | IN UINT64 Length,\r | |
540 | IN EFI_MEMORY_TYPE MemoryType\r | |
380148b6 AB |
541 | )\r |
542 | {\r | |
543 | EFI_HOB_MEMORY_ALLOCATION *Hob;\r | |
544 | \r | |
91415a36 MK |
545 | ASSERT (\r |
546 | ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r | |
547 | ((Length & (EFI_PAGE_SIZE - 1)) == 0)\r | |
548 | );\r | |
380148b6 AB |
549 | \r |
550 | Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r | |
551 | \r | |
552 | ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r | |
553 | Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r | |
554 | Hob->AllocDescriptor.MemoryLength = Length;\r | |
555 | Hob->AllocDescriptor.MemoryType = MemoryType;\r | |
556 | //\r | |
557 | // Zero the reserved space to match HOB spec\r | |
558 | //\r | |
559 | ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r | |
560 | }\r | |
561 | \r | |
562 | /**\r | |
563 | Builds a HOB that describes a chunk of system memory with Owner GUID.\r | |
564 | \r | |
565 | This function builds a HOB that describes a chunk of system memory.\r | |
566 | If there is no additional space for HOB creation, then ASSERT().\r | |
567 | \r | |
568 | @param ResourceType The type of resource described by this HOB.\r | |
569 | @param ResourceAttribute The resource attributes of the memory described by this HOB.\r | |
570 | @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r | |
571 | @param NumberOfBytes The length of the memory described by this HOB in bytes.\r | |
572 | @param OwnerGUID GUID for the owner of this resource.\r | |
573 | \r | |
574 | **/\r | |
575 | VOID\r | |
576 | EFIAPI\r | |
577 | BuildResourceDescriptorWithOwnerHob (\r | |
578 | IN EFI_RESOURCE_TYPE ResourceType,\r | |
579 | IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r | |
580 | IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r | |
581 | IN UINT64 NumberOfBytes,\r | |
582 | IN EFI_GUID *OwnerGUID\r | |
583 | )\r | |
584 | {\r | |
585 | ASSERT (FALSE);\r | |
586 | }\r | |
587 | \r | |
588 | /**\r | |
589 | Builds a Capsule Volume HOB.\r | |
590 | \r | |
591 | This function builds a Capsule Volume HOB.\r | |
592 | If the platform does not support Capsule Volume HOBs, then ASSERT().\r | |
593 | If there is no additional space for HOB creation, then ASSERT().\r | |
594 | \r | |
595 | @param BaseAddress The base address of the Capsule Volume.\r | |
596 | @param Length The size of the Capsule Volume in bytes.\r | |
597 | \r | |
598 | **/\r | |
599 | VOID\r | |
600 | EFIAPI\r | |
601 | BuildCvHob (\r | |
91415a36 MK |
602 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
603 | IN UINT64 Length\r | |
380148b6 AB |
604 | )\r |
605 | {\r | |
606 | ASSERT (FALSE);\r | |
607 | }\r | |
608 | \r | |
380148b6 AB |
609 | /**\r |
610 | Builds a HOB for the BSP store.\r | |
611 | \r | |
612 | This function builds a HOB for BSP store.\r | |
613 | If there is no additional space for HOB creation, then ASSERT().\r | |
614 | \r | |
615 | @param BaseAddress The 64 bit physical address of the BSP.\r | |
616 | @param Length The length of the BSP store in bytes.\r | |
617 | @param MemoryType Type of memory allocated by this HOB.\r | |
618 | \r | |
619 | **/\r | |
620 | VOID\r | |
621 | EFIAPI\r | |
622 | BuildBspStoreHob (\r | |
91415a36 MK |
623 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
624 | IN UINT64 Length,\r | |
625 | IN EFI_MEMORY_TYPE MemoryType\r | |
380148b6 AB |
626 | )\r |
627 | {\r | |
628 | ASSERT (FALSE);\r | |
629 | }\r | |
630 | \r | |
631 | /**\r | |
632 | Builds a HOB for the Stack.\r | |
633 | \r | |
634 | This function builds a HOB for the stack.\r | |
635 | If there is no additional space for HOB creation, then ASSERT().\r | |
636 | \r | |
637 | @param BaseAddress The 64 bit physical address of the Stack.\r | |
638 | @param Length The length of the stack in bytes.\r | |
639 | \r | |
640 | **/\r | |
641 | VOID\r | |
642 | EFIAPI\r | |
643 | BuildStackHob (\r | |
91415a36 MK |
644 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r |
645 | IN UINT64 Length\r | |
380148b6 AB |
646 | )\r |
647 | {\r | |
648 | ASSERT (FALSE);\r | |
649 | }\r |