]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiHobLib/HobLib.c
Code Scrub for Protocol Definition
[mirror_edk2.git] / MdePkg / Library / PeiHobLib / HobLib.c
CommitLineData
66f0059f 1/** @file\r
2 HOB Library.\r
3\r
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
66f0059f 13**/\r
14\r
c892d846 15\r
66f0059f 16#include <PiPei.h>\r
c892d846 17\r
66f0059f 18#include <Guid/MemoryAllocationHob.h>\r
c892d846 19\r
66f0059f 20#include <Library/HobLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/PeiServicesLib.h>\r
23#include <Library/BaseMemoryLib.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
133GetNextGuidHob (\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
166GetFirstGuidHob (\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
210 @return The address of new HOB.\r
211\r
212**/\r
213STATIC\r
214VOID *\r
215InternalPeiCreateHob (\r
216 IN UINT16 Type,\r
217 IN UINT16 Length\r
218 )\r
219{\r
220 EFI_STATUS Status;\r
221 VOID *Hob;\r
222\r
223 Status = PeiServicesCreateHob (Type, Length, &Hob);\r
224 //\r
225 // Assume the process of HOB building is always successful.\r
226 //\r
227 ASSERT_EFI_ERROR (Status);\r
228 return Hob;\r
229}\r
230\r
231/**\r
232 Builds a HOB for a loaded PE32 module.\r
233\r
234 This function builds a HOB for a loaded PE32 module.\r
235 It can only be invoked during PEI phase;\r
236 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
237 If ModuleName is NULL, then ASSERT().\r
238 If there is no additional space for HOB creation, then ASSERT().\r
239\r
240 @param ModuleName The GUID File Name of the module.\r
241 @param MemoryAllocationModule The 64 bit physical address of the module.\r
242 @param ModuleLength The length of the module in bytes.\r
243 @param EntryPoint The 64 bit physical address of the module's entry point.\r
244\r
245**/\r
246VOID\r
247EFIAPI\r
248BuildModuleHob (\r
249 IN CONST EFI_GUID *ModuleName,\r
250 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,\r
251 IN UINT64 ModuleLength,\r
252 IN EFI_PHYSICAL_ADDRESS EntryPoint\r
253 )\r
254{\r
255 EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;\r
256\r
0a7d0741 257 ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r
258 ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));\r
259\r
66f0059f 260 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
261\r
262 CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r
263 Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
264 Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r
265 Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r
266\r
267 //\r
268 // Zero the reserved space to match HOB spec\r
269 //\r
270 ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r
271 \r
272 CopyGuid (&Hob->ModuleName, ModuleName);\r
273 Hob->EntryPoint = EntryPoint;\r
274}\r
275\r
276/**\r
277 Builds a HOB that describes a chunk of system memory.\r
278\r
279 This function builds a HOB that describes a chunk of system memory.\r
280 It can only be invoked during PEI phase;\r
281 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
282 If there is no additional space for HOB creation, then ASSERT().\r
283\r
284 @param ResourceType The type of resource described by this HOB.\r
285 @param ResourceAttribute The resource attributes of the memory described by this HOB.\r
286 @param PhysicalStart The 64 bit physical address of memory described by this HOB.\r
287 @param NumberOfBytes The length of the memory described by this HOB in bytes.\r
288\r
289**/\r
290VOID\r
291EFIAPI\r
292BuildResourceDescriptorHob (\r
293 IN EFI_RESOURCE_TYPE ResourceType,\r
294 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r
295 IN EFI_PHYSICAL_ADDRESS PhysicalStart,\r
296 IN UINT64 NumberOfBytes\r
297 )\r
298{\r
299 EFI_HOB_RESOURCE_DESCRIPTOR *Hob;\r
300\r
301 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
302\r
303 Hob->ResourceType = ResourceType;\r
304 Hob->ResourceAttribute = ResourceAttribute;\r
305 Hob->PhysicalStart = PhysicalStart;\r
306 Hob->ResourceLength = NumberOfBytes;\r
307}\r
308\r
309/**\r
310 Builds a GUID HOB with a certain data length.\r
311\r
312 This function builds a customized HOB tagged with a GUID for identification \r
313 and returns the start address of GUID HOB data so that caller can fill the customized data. \r
314 The HOB Header and Name field is already stripped.\r
315 It can only be invoked during PEI phase;\r
316 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
317 If Guid is NULL, then ASSERT().\r
318 If there is no additional space for HOB creation, then ASSERT().\r
319 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
320\r
321 @param Guid The GUID to tag the customized HOB.\r
322 @param DataLength The size of the data payload for the GUID HOB.\r
323\r
324 @return The start address of GUID HOB data.\r
325\r
326**/\r
327VOID *\r
328EFIAPI\r
329BuildGuidHob (\r
330 IN CONST EFI_GUID *Guid,\r
331 IN UINTN DataLength\r
332 )\r
333{\r
334 EFI_HOB_GUID_TYPE *Hob;\r
335\r
336 //\r
337 // Make sure that data length is not too long.\r
338 //\r
339 ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r
340\r
341 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r
342 CopyGuid (&Hob->Name, Guid);\r
343 return Hob + 1;\r
344}\r
345\r
346/**\r
347 Copies a data buffer to a newly-built HOB.\r
348\r
349 This function builds a customized HOB tagged with a GUID for identification,\r
350 copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
351 The HOB Header and Name field is already stripped.\r
352 It can only be invoked during PEI phase;\r
353 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
354 If Guid is NULL, then ASSERT().\r
355 If Data is NULL and DataLength > 0, then ASSERT().\r
356 If there is no additional space for HOB creation, then ASSERT().\r
357 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
358\r
359 @param Guid The GUID to tag the customized HOB.\r
360 @param Data The data to be copied into the data field of the GUID HOB.\r
361 @param DataLength The size of the data payload for the GUID HOB.\r
362\r
363 @return The start address of GUID HOB data.\r
364\r
365**/\r
366VOID *\r
367EFIAPI\r
368BuildGuidDataHob (\r
369 IN CONST EFI_GUID *Guid,\r
370 IN VOID *Data,\r
371 IN UINTN DataLength\r
372 )\r
373{\r
374 VOID *HobData;\r
375\r
376 ASSERT (Data != NULL || DataLength == 0);\r
377\r
378 HobData = BuildGuidHob (Guid, DataLength);\r
379\r
380 return CopyMem (HobData, Data, DataLength);\r
381}\r
382\r
383/**\r
384 Builds a Firmware Volume HOB.\r
385\r
386 This function builds a Firmware Volume HOB.\r
387 It can only be invoked during PEI phase;\r
388 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
389 If there is no additional space for HOB creation, then ASSERT().\r
390\r
391 @param BaseAddress The base address of the Firmware Volume.\r
392 @param Length The size of the Firmware Volume in bytes.\r
393\r
394**/\r
395VOID\r
396EFIAPI\r
397BuildFvHob (\r
398 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
399 IN UINT64 Length\r
400 )\r
401{\r
402 EFI_HOB_FIRMWARE_VOLUME *Hob;\r
403\r
404 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
405\r
406 Hob->BaseAddress = BaseAddress;\r
407 Hob->Length = Length;\r
408}\r
409\r
07ad9b81 410/**\r
411 Builds a EFI_HOB_TYPE_FV2 HOB.\r
412\r
413 This function builds a EFI_HOB_TYPE_FV2 HOB.\r
414 It can only be invoked during PEI phase;\r
415 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
416 If there is no additional space for HOB creation, then ASSERT().\r
417\r
418 @param BaseAddress The base address of the Firmware Volume.\r
419 @param Length The size of the Firmware Volume in bytes.\r
420 @param FvName The name of the Firmware Volume.\r
421 @param FileName The name of the file.\r
422 \r
423**/\r
424VOID\r
425EFIAPI\r
426BuildFv2Hob (\r
427 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
428 IN UINT64 Length,\r
429 IN CONST EFI_GUID *FvName,\r
430 IN CONST EFI_GUID *FileName\r
431 )\r
432{\r
433 EFI_HOB_FIRMWARE_VOLUME2 *Hob;\r
434\r
435 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r
436\r
437 Hob->BaseAddress = BaseAddress;\r
438 Hob->Length = Length;\r
3a364554 439 CopyGuid (&Hob->FvName, FvName);\r
440 CopyGuid (&Hob->FileName, FileName);\r
07ad9b81 441}\r
442\r
66f0059f 443/**\r
444 Builds a Capsule Volume HOB.\r
445\r
446 This function builds a Capsule Volume HOB.\r
447 It can only be invoked during PEI phase;\r
448 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
449 If there is no additional space for HOB creation, then ASSERT().\r
450\r
451 @param BaseAddress The base address of the Capsule Volume.\r
452 @param Length The size of the Capsule Volume in bytes.\r
453\r
454**/\r
455VOID\r
456EFIAPI\r
457BuildCvHob (\r
458 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
459 IN UINT64 Length\r
460 )\r
461{\r
462 ASSERT (FALSE);\r
463}\r
464\r
465/**\r
466 Builds a HOB for the CPU.\r
467\r
468 This function builds a HOB for the CPU.\r
469 It can only be invoked during PEI phase;\r
470 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
471 If there is no additional space for HOB creation, then ASSERT().\r
472\r
473 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.\r
474 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.\r
475\r
476**/\r
477VOID\r
478EFIAPI\r
479BuildCpuHob (\r
480 IN UINT8 SizeOfMemorySpace,\r
481 IN UINT8 SizeOfIoSpace\r
482 )\r
483{\r
484 EFI_HOB_CPU *Hob;\r
485\r
486 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r
487\r
488 Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
489 Hob->SizeOfIoSpace = SizeOfIoSpace;\r
490\r
491 //\r
492 // Zero the reserved space to match HOB spec\r
493 //\r
494 ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r
495}\r
496\r
497/**\r
498 Builds a HOB for the Stack.\r
499\r
500 This function builds a HOB for the stack.\r
501 It can only be invoked during PEI phase;\r
502 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
503 If there is no additional space for HOB creation, then ASSERT().\r
504\r
505 @param BaseAddress The 64 bit physical address of the Stack.\r
506 @param Length The length of the stack in bytes.\r
507\r
508**/\r
509VOID\r
510EFIAPI\r
511BuildStackHob (\r
512 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
513 IN UINT64 Length\r
514 )\r
515{\r
516 EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;\r
517\r
0a7d0741 518 ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
519 ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
520\r
66f0059f 521 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
522\r
523 CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r
524 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
525 Hob->AllocDescriptor.MemoryLength = Length;\r
dda0251d 526 Hob->AllocDescriptor.MemoryType = EfiBootServicesData;\r
66f0059f 527\r
528 //\r
529 // Zero the reserved space to match HOB spec\r
530 //\r
531 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
532}\r
533\r
534/**\r
535 Builds a HOB for the BSP store.\r
536\r
537 This function builds a HOB for BSP store.\r
538 It can only be invoked during PEI phase;\r
539 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
540 If there is no additional space for HOB creation, then ASSERT().\r
541\r
542 @param BaseAddress The 64 bit physical address of the BSP.\r
543 @param Length The length of the BSP store in bytes.\r
544 @param MemoryType Type of memory allocated by this HOB.\r
545\r
546**/\r
547VOID\r
548EFIAPI\r
549BuildBspStoreHob (\r
550 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
551 IN UINT64 Length,\r
552 IN EFI_MEMORY_TYPE MemoryType\r
553 )\r
554{\r
555 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;\r
556\r
0a7d0741 557 ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
558 ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
559\r
66f0059f 560 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
561\r
562 CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r
563 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
564 Hob->AllocDescriptor.MemoryLength = Length;\r
565 Hob->AllocDescriptor.MemoryType = MemoryType;\r
566\r
567 //\r
568 // Zero the reserved space to match HOB spec\r
569 //\r
570 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
571}\r
572\r
573/**\r
574 Builds a HOB for the memory allocation.\r
575\r
576 This function builds a HOB for the memory allocation.\r
577 It can only be invoked during PEI phase;\r
578 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
579 If there is no additional space for HOB creation, then ASSERT().\r
580\r
581 @param BaseAddress The 64 bit physical address of the memory.\r
582 @param Length The length of the memory allocation in bytes.\r
583 @param MemoryType Type of memory allocated by this HOB.\r
584\r
585**/\r
586VOID\r
587EFIAPI\r
588BuildMemoryAllocationHob (\r
589 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
590 IN UINT64 Length,\r
591 IN EFI_MEMORY_TYPE MemoryType\r
592 )\r
593{\r
594 EFI_HOB_MEMORY_ALLOCATION *Hob;\r
595\r
0a7d0741 596 ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
597 ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
598 \r
66f0059f 599 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
0a7d0741 600 \r
66f0059f 601 ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r
602 Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
603 Hob->AllocDescriptor.MemoryLength = Length;\r
604 Hob->AllocDescriptor.MemoryType = MemoryType;\r
605 //\r
606 // Zero the reserved space to match HOB spec\r
607 //\r
608 ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
609}\r