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