]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / PeiHobLib / HobLib.c
CommitLineData
3eb9473e 1/*++\r
2\r
f99d3d23 3Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
2c7e5c2f 4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12\r
13Module Name:\r
14\r
15 HobLib.c\r
16 \r
17Abstract: \r
18\r
19 HOB Library.\r
20\r
21--*/\r
22\r
23#include "EdkIIGluePeim.h"\r
24\r
25/**\r
26 Returns the pointer to the HOB list.\r
27\r
28 This function returns the pointer to first HOB in the list.\r
29\r
30 @return The pointer to the HOB list.\r
31\r
32**/\r
33VOID *\r
34EFIAPI\r
35GetHobList (\r
36 VOID\r
37 )\r
38{\r
39 EFI_STATUS Status;\r
40 VOID *HobList;\r
41\r
42 Status = PeiServicesGetHobList (&HobList);\r
43 ASSERT_EFI_ERROR (Status);\r
44 ASSERT (HobList != NULL);\r
45\r
46 return HobList;\r
47}\r
48\r
49/**\r
50 Returns the next instance of a HOB type from the starting HOB.\r
51\r
52 This function searches the first instance of a HOB type from the starting HOB pointer. \r
53 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
54 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
55 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
56 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
57 If HobStart is NULL, then ASSERT().\r
58\r
59 @param Type The HOB type to return.\r
60 @param HobStart The starting HOB pointer to search from.\r
61\r
62 @return The next instance of a HOB type from the starting HOB.\r
63\r
64**/\r
65VOID *\r
66EFIAPI\r
67GetNextHob (\r
68 IN UINT16 Type,\r
69 IN CONST VOID *HobStart\r
70 )\r
71{\r
72 EFI_PEI_HOB_POINTERS Hob;\r
73\r
74 ASSERT (HobStart != NULL);\r
75 \r
76 Hob.Raw = (UINT8 *) HobStart;\r
77 //\r
78 // Parse the HOB list until end of list or matching type is found.\r
79 //\r
80 while (!END_OF_HOB_LIST (Hob)) {\r
81 if (Hob.Header->HobType == Type) {\r
82 return Hob.Raw;\r
83 }\r
84 Hob.Raw = GET_NEXT_HOB (Hob);\r
85 }\r
86 return NULL;\r
87}\r
88\r
89/**\r
90 Returns the first instance of a HOB type among the whole HOB list.\r
91\r
92 This function searches the first instance of a HOB type among the whole HOB list. \r
93 If there does not exist such HOB type in the HOB list, it will return NULL. \r
94\r
95 @param Type The HOB type to return.\r
96\r
97 @return The next instance of a HOB type from the starting HOB.\r
98\r
99**/\r
100VOID *\r
101EFIAPI\r
102GetFirstHob (\r
103 IN UINT16 Type\r
104 )\r
105{\r
106 VOID *HobList;\r
107\r
108 HobList = GetHobList ();\r
109 return GetNextHob (Type, HobList);\r
110}\r
111\r
112/**\r
113 This function searches the first instance of a HOB from the starting HOB pointer. \r
114 Such HOB should satisfy two conditions: \r
115 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
116 If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
117 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
118 to extract the data section and its size info respectively.\r
119 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
120 unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
121 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
122 If Guid is NULL, then ASSERT().\r
123 If HobStart is NULL, then ASSERT().\r
124\r
125 @param Guid The GUID to match with in the HOB list.\r
126 @param HobStart A pointer to a Guid.\r
127\r
128 @return The next instance of the matched GUID HOB from the starting HOB.\r
129\r
130**/\r
131VOID *\r
132EFIAPI\r
133GlueGetNextGuidHob (\r
134 IN CONST EFI_GUID *Guid,\r
135 IN CONST VOID *HobStart\r
136 )\r
137{\r
138 EFI_PEI_HOB_POINTERS GuidHob;\r
139\r
140 GuidHob.Raw = (UINT8 *) HobStart;\r
141 while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
142 if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
143 break;\r
144 }\r
145 GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
146 }\r
147 return GuidHob.Raw;\r
148}\r
149\r
150/**\r
151 This function searches the first instance of a HOB among the whole HOB list. \r
152 Such HOB should satisfy two conditions:\r
153 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
154 If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
155 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
156 to extract the data section and its size info respectively.\r
157 If Guid is NULL, then ASSERT().\r
158\r
159 @param Guid The GUID to match with in the HOB list.\r
160\r
161 @return The first instance of the matched GUID HOB among the whole HOB list.\r
162\r
163**/\r
164VOID *\r
165EFIAPI\r
166GlueGetFirstGuidHob (\r
167 IN CONST EFI_GUID *Guid\r
168 )\r
169{\r
170 VOID *HobList;\r
171\r
172 HobList = GetHobList ();\r
173 return GetNextGuidHob (Guid, HobList);\r
174}\r
175\r
176/**\r
177 Get the Boot Mode from the HOB list.\r
178\r
179 This function returns the system boot mode information from the \r
180 PHIT HOB in HOB list.\r
181\r
182 @param VOID\r
183\r
184 @return The Boot Mode.\r
185\r
186**/\r
187EFI_BOOT_MODE\r
188EFIAPI\r
189GetBootModeHob (\r
190 VOID\r
191 )\r
192{\r
193 EFI_STATUS Status;\r
194 EFI_BOOT_MODE BootMode;\r
195\r
196 Status = PeiServicesGetBootMode (&BootMode);\r
197 ASSERT_EFI_ERROR (Status);\r
198\r
199 return BootMode;\r
200}\r
201\r
202/**\r
203 Adds a new HOB to the HOB List.\r
204\r
205 This internal function enables PEIMs to create various types of HOBs.\r
206\r
207 @param Type Type of the new HOB.\r
208 @param Length Length of the new HOB to allocate.\r
209\r
f99d3d23
RN
210 @retval NULL The HOB could not be allocated.\r
211 @retval others The address of new HOB.\r
3eb9473e 212\r
213**/\r
214STATIC\r
215VOID *\r
216InternalPeiCreateHob (\r
217 IN UINT16 Type,\r
218 IN UINT16 Length\r
219 )\r
220{\r
221 EFI_STATUS Status;\r
222 VOID *Hob;\r
223\r
224 Status = PeiServicesCreateHob (Type, Length, &Hob);\r
f99d3d23
RN
225 if (EFI_ERROR (Status)) {\r
226 Hob = NULL;\r
227 }\r
3eb9473e 228 //\r
229 // Assume the process of HOB building is always successful.\r
230 //\r
f99d3d23 231 ASSERT (Hob != NULL);\r
3eb9473e 232 return Hob;\r
233}\r
234\r
235/**\r
236 Builds a HOB for a loaded PE32 module.\r
237\r
238 This function builds a HOB for a loaded PE32 module.\r
239 It can only be invoked during PEI phase;\r
240 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
241 If ModuleName is NULL, then ASSERT().\r
242 If there is no additional space for HOB creation, then ASSERT().\r
243\r
244 @param ModuleName The GUID File Name of the module.\r
245 @param MemoryAllocationModule The 64 bit physical address of the module.\r
246 @param ModuleLength The length of the module in bytes.\r
247 @param EntryPoint The 64 bit physical address of the module's entry point.\r
248\r
249**/\r
250VOID\r
251EFIAPI\r
252GlueBuildModuleHob (\r
253 IN CONST EFI_GUID *ModuleName,\r
254 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r
255 IN UINT64 ModuleLength,\r
256 IN EFI_PHYSICAL_ADDRESS EntryPoint\r
257 )\r
258{\r
259 EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;\r
260\r
e0096099 261 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
f99d3d23
RN
262 if (Hob == NULL) {\r
263 return;\r
264 }\r
3eb9473e 265\r
266 CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r
267 Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
268 Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r
269 Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r
270\r
271 //\r
272 // Zero the reserved space to match HOB spec\r
273 //\r
274 ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r
275 \r
276 CopyGuid (&Hob->ModuleName, ModuleName);\r
277 Hob->EntryPoint = EntryPoint;\r
278}\r
279\r
280/**\r
281 Builds a HOB that describes a chunk of system memory.\r
282\r
283 This function builds a HOB that describes a chunk of system memory.\r
284 It can only be invoked during PEI phase;\r
285 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
286 If there is no additional space for HOB creation, then ASSERT().\r
287\r
288 @param ResourceType The type of resource described by this HOB.\r
289 @param ResourceAttribute The resource attributes of the memory described by this HOB.\r
290 @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r
291 @param NumberOfBytes The length of the memory described by this HOB in bytes.\r
292\r
293**/\r
294VOID\r
295EFIAPI\r
296BuildResourceDescriptorHob (\r
297 IN EFI_RESOURCE_TYPE ResourceType,\r
298 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r
299 IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r
300 IN UINT64 NumberOfBytes\r
301 )\r
302{\r
303 EFI_HOB_RESOURCE_DESCRIPTOR *Hob;\r
304\r
e0096099 305 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, (UINT16) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
f99d3d23
RN
306 if (Hob == NULL) {\r
307 return;\r
308 }\r
3eb9473e 309\r
310 Hob->ResourceType = ResourceType;\r
311 Hob->ResourceAttribute = ResourceAttribute;\r
312 Hob->PhysicalStart = PhysicalStart;\r
313 Hob->ResourceLength = NumberOfBytes;\r
314}\r
315\r
316/**\r
317 Builds a GUID HOB with a certain data length.\r
318\r
319 This function builds a customized HOB tagged with a GUID for identification \r
320 and returns the start address of GUID HOB data so that caller can fill the customized data. \r
321 The HOB Header and Name field is already stripped.\r
322 It can only be invoked during PEI phase;\r
323 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
324 If Guid is NULL, then ASSERT().\r
325 If there is no additional space for HOB creation, then ASSERT().\r
326 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
327\r
328 @param Guid The GUID to tag the customized HOB.\r
329 @param DataLength The size of the data payload for the GUID HOB.\r
330\r
f99d3d23
RN
331 @retval NULL The GUID HOB could not be allocated.\r
332 @retval others The start address of GUID HOB data.\r
3eb9473e 333\r
334**/\r
335VOID *\r
336EFIAPI\r
337BuildGuidHob (\r
338 IN CONST EFI_GUID *Guid,\r
339 IN UINTN DataLength\r
340 )\r
341{\r
342 EFI_HOB_GUID_TYPE *Hob;\r
343\r
f99d3d23
RN
344 //\r
345 // Make sure Guid is valid\r
346 //\r
347 ASSERT (Guid != NULL);\r
348 \r
3eb9473e 349 //\r
350 // Make sure that data length is not too long.\r
351 //\r
352 ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r
353\r
354 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r
f99d3d23
RN
355 if (Hob == NULL) {\r
356 return Hob;\r
357 }\r
3eb9473e 358 CopyGuid (&Hob->Name, Guid);\r
359 return Hob + 1;\r
360}\r
361\r
362/**\r
363 Copies a data buffer to a newly-built HOB.\r
364\r
365 This function builds a customized HOB tagged with a GUID for identification,\r
366 copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
367 The HOB Header and Name field is already stripped.\r
368 It can only be invoked during PEI phase;\r
369 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
370 If Guid is NULL, then ASSERT().\r
371 If Data is NULL and DataLength > 0, then ASSERT().\r
372 If there is no additional space for HOB creation, then ASSERT().\r
373 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
374\r
375 @param Guid The GUID to tag the customized HOB.\r
376 @param Data The data to be copied into the data field of the GUID HOB.\r
377 @param DataLength The size of the data payload for the GUID HOB.\r
378\r
f99d3d23
RN
379 @retval NULL The GUID HOB could not be allocated.\r
380 @retval others The start address of GUID HOB data.\r
3eb9473e 381\r
382**/\r
383VOID *\r
384EFIAPI\r
385BuildGuidDataHob (\r
386 IN CONST EFI_GUID *Guid,\r
387 IN VOID *Data,\r
388 IN UINTN DataLength\r
389 )\r
390{\r
391 VOID *HobData;\r
392\r
393 ASSERT (Data != NULL || DataLength == 0);\r
394\r
395 HobData = BuildGuidHob (Guid, DataLength);\r
f99d3d23
RN
396 if (HobData == NULL) {\r
397 return HobData;\r
398 }\r
3eb9473e 399\r
400 return CopyMem (HobData, Data, DataLength);\r
401}\r
402\r
403/**\r
404 Builds a Firmware Volume HOB.\r
405\r
406 This function builds a Firmware Volume HOB.\r
407 It can only be invoked during PEI phase;\r
408 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
409 If there is no additional space for HOB creation, then ASSERT().\r
410\r
411 @param BaseAddress The base address of the Firmware Volume.\r
412 @param Length The size of the Firmware Volume in bytes.\r
413\r
414**/\r
415VOID\r
416EFIAPI\r
417BuildFvHob (\r
418 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
419 IN UINT64 Length\r
420 )\r
421{\r
422 EFI_HOB_FIRMWARE_VOLUME *Hob;\r
423\r
424 //\r
425 // Check FV Signature\r
426 //\r
427 ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r
e0096099 428 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
f99d3d23
RN
429 if (Hob == NULL) {\r
430 return;\r
431 }\r
3eb9473e 432\r
433 Hob->BaseAddress = BaseAddress;\r
434 Hob->Length = Length;\r
435}\r
436\r
437/**\r
438 Builds a Capsule Volume HOB.\r
439\r
440 This function builds a Capsule Volume HOB.\r
441 It can only be invoked during PEI phase;\r
442 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
443 If there is no additional space for HOB creation, then ASSERT().\r
444\r
445 @param BaseAddress The base address of the Capsule Volume.\r
446 @param Length The size of the Capsule Volume in bytes.\r
447\r
448**/\r
449VOID\r
450EFIAPI\r
451BuildCvHob (\r
452 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
453 IN UINT64 Length\r
454 )\r
455{\r
456 EFI_HOB_CAPSULE_VOLUME *Hob;\r
457\r
e0096099 458 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, (UINT16) sizeof (EFI_HOB_CAPSULE_VOLUME));\r
f99d3d23
RN
459 if (Hob == NULL) {\r
460 return;\r
461 }\r
3eb9473e 462\r
463 Hob->BaseAddress = BaseAddress;\r
464 Hob->Length = Length;\r
465}\r
466\r
467/**\r
468 Builds a HOB for the CPU.\r
469\r
470 This function builds a HOB for the CPU.\r
471 It can only be invoked during PEI phase;\r
472 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
473 If there is no additional space for HOB creation, then ASSERT().\r
474\r
475 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r
476 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r
477\r
478**/\r
479VOID\r
480EFIAPI\r
481BuildCpuHob (\r
482 IN UINT8 SizeOfMemorySpace,\r
483 IN UINT8 SizeOfIoSpace\r
484 )\r
485{\r
486 EFI_HOB_CPU *Hob;\r
487\r
e0096099 488 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, (UINT16) sizeof (EFI_HOB_CPU));\r
f99d3d23
RN
489 if (Hob == NULL) {\r
490 return;\r
491 }\r
3eb9473e 492\r
493 Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
494 Hob->SizeOfIoSpace = SizeOfIoSpace;\r
495\r
496 //\r
497 // Zero the reserved space to match HOB spec\r
498 //\r
499 ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r
500}\r
501\r
502/**\r
503 Builds a HOB for the Stack.\r
504\r
505 This function builds a HOB for the stack.\r
506 It can only be invoked during PEI phase;\r
507 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
508 If there is no additional space for HOB creation, then ASSERT().\r
509\r
510 @param BaseAddress The 64 bit physical address of the Stack.\r
511 @param Length The length of the stack in bytes.\r
512\r
513**/\r
514VOID\r
515EFIAPI\r
516BuildStackHob (\r
517 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
518 IN UINT64 Length\r
519 )\r
520{\r
521 EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;\r
522\r
e0096099 523 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
f99d3d23
RN
524 if (Hob == NULL) {\r
525 return;\r
526 }\r
3eb9473e 527\r
528 CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r
529 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
530 Hob->AllocDescriptor.MemoryLength = Length;\r
c7f33ca4 531 Hob->AllocDescriptor.MemoryType = EfiBootServicesData;\r
3eb9473e 532\r
533 //\r
534 // Zero the reserved space to match HOB spec\r
535 //\r
536 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
537}\r
538\r
539/**\r
540 Builds a HOB for the BSP store.\r
541\r
542 This function builds a HOB for BSP store.\r
543 It can only be invoked during PEI phase;\r
544 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
545 If there is no additional space for HOB creation, then ASSERT().\r
546\r
547 @param BaseAddress The 64 bit physical address of the BSP.\r
548 @param Length The length of the BSP store in bytes.\r
549 @param MemoryType Type of memory allocated by this HOB.\r
550\r
551**/\r
552VOID\r
553EFIAPI\r
554BuildBspStoreHob (\r
555 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
556 IN UINT64 Length,\r
557 IN EFI_MEMORY_TYPE MemoryType\r
558 )\r
559{\r
560 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;\r
561\r
e0096099 562 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
f99d3d23
RN
563 if (Hob == NULL) {\r
564 return;\r
565 }\r
3eb9473e 566\r
567 CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r
568 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
569 Hob->AllocDescriptor.MemoryLength = Length;\r
570 Hob->AllocDescriptor.MemoryType = MemoryType;\r
571\r
572 //\r
573 // Zero the reserved space to match HOB spec\r
574 //\r
575 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
576}\r
577\r
578/**\r
579 Builds a HOB for the memory allocation.\r
580\r
581 This function builds a HOB for the memory allocation.\r
582 It can only be invoked during PEI phase;\r
583 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
584 If there is no additional space for HOB creation, then ASSERT().\r
585\r
586 @param BaseAddress The 64 bit physical address of the memory.\r
587 @param Length The length of the memory allocation in bytes.\r
588 @param MemoryType Type of memory allocated by this HOB.\r
589\r
590**/\r
591VOID\r
592EFIAPI\r
593GlueBuildMemoryAllocationHob (\r
594 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
595 IN UINT64 Length,\r
596 IN EFI_MEMORY_TYPE MemoryType\r
597 )\r
598{\r
599 EFI_HOB_MEMORY_ALLOCATION *Hob;\r
600\r
e0096099 601 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
f99d3d23
RN
602 if (Hob == NULL) {\r
603 return;\r
604 }\r
605 \r
3eb9473e 606 ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r
607 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
608 Hob->AllocDescriptor.MemoryLength = Length;\r
609 Hob->AllocDescriptor.MemoryType = MemoryType;\r
610 //\r
611 // Zero the reserved space to match HOB spec\r
612 //\r
613 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
614}\r