TianoCore EDK2 master
HobLib.c
Go to the documentation of this file.
1
10#define ASSERT(Expression) \
11 do { \
12 if (!(Expression)) { \
13 CpuDeadLoop (); \
14 } \
15 } while (FALSE)
16
17#include <PiDxe.h>
18
19#include <Guid/HobList.h>
20
21#include <Library/HobLib.h>
22#include <Library/UefiLib.h>
24
25VOID *mHobList = NULL;
26
40EFIAPI
42 IN EFI_HANDLE ImageHandle,
43 IN EFI_SYSTEM_TABLE *SystemTable
44 )
45{
46 UINTN Index;
47
48 for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
49 if (CompareGuid (&gEfiHobListGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {
50 mHobList = SystemTable->ConfigurationTable[Index].VendorTable;
51 return EFI_SUCCESS;
52 }
53 }
54
55 return EFI_NOT_FOUND;
56}
57
74VOID *
75EFIAPI
77 VOID
78 )
79{
80 ASSERT (mHobList != NULL);
81 return mHobList;
82}
83
101VOID *
102EFIAPI
104 IN UINT16 Type,
105 IN CONST VOID *HobStart
106 )
107{
109
110 ASSERT (HobStart != NULL);
111
112 Hob.Raw = (UINT8 *)HobStart;
113 //
114 // Parse the HOB list until end of list or matching type is found.
115 //
116 while (!END_OF_HOB_LIST (Hob)) {
117 if (Hob.Header->HobType == Type) {
118 return Hob.Raw;
119 }
120
121 Hob.Raw = GET_NEXT_HOB (Hob);
122 }
123
124 return NULL;
125}
126
140VOID *
141EFIAPI
143 IN UINT16 Type
144 )
145{
146 VOID *HobList;
147
148 HobList = GetHobList ();
149 return GetNextHob (Type, HobList);
150}
151
174VOID *
175EFIAPI
177 IN CONST EFI_GUID *Guid,
178 IN CONST VOID *HobStart
179 )
180{
181 EFI_PEI_HOB_POINTERS GuidHob;
182
183 GuidHob.Raw = (UINT8 *)HobStart;
184 while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
185 if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
186 break;
187 }
188
189 GuidHob.Raw = GET_NEXT_HOB (GuidHob);
190 }
191
192 return GuidHob.Raw;
193}
194
213VOID *
214EFIAPI
216 IN CONST EFI_GUID *Guid
217 )
218{
219 VOID *HobList;
220
221 HobList = GetHobList ();
222 return GetNextGuidHob (Guid, HobList);
223}
224
239EFIAPI
241 VOID
242 )
243{
244 EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
245
246 HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();
247
248 return HandOffHob->BootMode;
249}
250
267VOID
268EFIAPI
270 IN CONST EFI_GUID *ModuleName,
271 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
272 IN UINT64 ModuleLength,
273 IN EFI_PHYSICAL_ADDRESS EntryPoint
274 )
275{
276 //
277 // PEI HOB is read only for DXE phase
278 //
279 ASSERT (FALSE);
280}
281
297VOID
298EFIAPI
300 IN EFI_RESOURCE_TYPE ResourceType,
301 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
302 IN EFI_PHYSICAL_ADDRESS PhysicalStart,
303 IN UINT64 NumberOfBytes
304 )
305{
306 //
307 // PEI HOB is read only for DXE phase
308 //
309 ASSERT (FALSE);
310}
311
334VOID *
335EFIAPI
337 IN CONST EFI_GUID *Guid,
338 IN UINTN DataLength
339 )
340{
341 //
342 // PEI HOB is read only for DXE phase
343 //
344 ASSERT (FALSE);
345 return NULL;
346}
347
373VOID *
374EFIAPI
376 IN CONST EFI_GUID *Guid,
377 IN VOID *Data,
378 IN UINTN DataLength
379 )
380{
381 //
382 // PEI HOB is read only for DXE phase
383 //
384 ASSERT (FALSE);
385 return NULL;
386}
387
402VOID
403EFIAPI
405 IN EFI_PHYSICAL_ADDRESS BaseAddress,
406 IN UINT64 Length
407 )
408{
409 //
410 // PEI HOB is read only for DXE phase
411 //
412 ASSERT (FALSE);
413}
414
431VOID
432EFIAPI
434 IN EFI_PHYSICAL_ADDRESS BaseAddress,
435 IN UINT64 Length,
436 IN CONST EFI_GUID *FvName,
437 IN CONST EFI_GUID *FileName
438 )
439{
440 ASSERT (FALSE);
441}
442
464VOID
465EFIAPI
467 IN EFI_PHYSICAL_ADDRESS BaseAddress,
468 IN UINT64 Length,
469 IN UINT32 AuthenticationStatus,
470 IN BOOLEAN ExtractedFv,
471 IN CONST EFI_GUID *FvName OPTIONAL,
472 IN CONST EFI_GUID *FileName OPTIONAL
473 )
474{
475 ASSERT (FALSE);
476}
477
492VOID
493EFIAPI
495 IN EFI_PHYSICAL_ADDRESS BaseAddress,
496 IN UINT64 Length
497 )
498{
499 //
500 // PEI HOB is read only for DXE phase
501 //
502 ASSERT (FALSE);
503}
504
518VOID
519EFIAPI
521 IN UINT8 SizeOfMemorySpace,
522 IN UINT8 SizeOfIoSpace
523 )
524{
525 //
526 // PEI HOB is read only for DXE phase
527 //
528 ASSERT (FALSE);
529}
530
544VOID
545EFIAPI
547 IN EFI_PHYSICAL_ADDRESS BaseAddress,
548 IN UINT64 Length
549 )
550{
551 //
552 // PEI HOB is read only for DXE phase
553 //
554 ASSERT (FALSE);
555}
556
571VOID
572EFIAPI
574 IN EFI_PHYSICAL_ADDRESS BaseAddress,
575 IN UINT64 Length,
576 IN EFI_MEMORY_TYPE MemoryType
577 )
578{
579 //
580 // PEI HOB is read only for DXE phase
581 //
582 ASSERT (FALSE);
583}
584
599VOID
600EFIAPI
602 IN EFI_PHYSICAL_ADDRESS BaseAddress,
603 IN UINT64 Length,
604 IN EFI_MEMORY_TYPE MemoryType
605 )
606{
607 //
608 // PEI HOB is read only for DXE phase
609 //
610 ASSERT (FALSE);
611}
UINT64 UINTN
VOID EFIAPI BuildFv2Hob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN CONST EFI_GUID *FvName, IN CONST EFI_GUID *FileName)
Definition: HobLib.c:433
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
Definition: HobLib.c:142
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
Definition: HobLib.c:375
VOID EFIAPI BuildModuleHob(IN CONST EFI_GUID *ModuleName, IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, IN UINT64 ModuleLength, IN EFI_PHYSICAL_ADDRESS EntryPoint)
Definition: HobLib.c:269
VOID EFIAPI BuildCpuHob(IN UINT8 SizeOfMemorySpace, IN UINT8 SizeOfIoSpace)
Definition: HobLib.c:520
VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
Definition: HobLib.c:299
VOID EFIAPI BuildFvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
Definition: HobLib.c:404
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
Definition: HobLib.c:336
VOID EFIAPI BuildBspStoreHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
Definition: HobLib.c:573
VOID EFIAPI BuildFv3Hob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT32 AuthenticationStatus, IN BOOLEAN ExtractedFv, IN CONST EFI_GUID *FvName OPTIONAL, IN CONST EFI_GUID *FileName OPTIONAL)
Definition: HobLib.c:466
VOID EFIAPI BuildMemoryAllocationHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
Definition: HobLib.c:601
EFI_STATUS EFIAPI HobLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: HobLib.c:41
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
Definition: HobLib.c:103
VOID EFIAPI BuildCvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
Definition: HobLib.c:494
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
Definition: HobLib.c:176
VOID *EFIAPI GetHobList(VOID)
Definition: HobLib.c:76
VOID EFIAPI BuildStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
Definition: HobLib.c:546
EFI_BOOT_MODE EFIAPI GetBootModeHob(VOID)
Definition: HobLib.c:240
#define NULL
Definition: Base.h:312
#define CONST
Definition: Base.h:259
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
#define ASSERT(Expression)
Definition: DebugLib.h:391
#define GET_NEXT_HOB(HobStart)
Definition: HobLib.h:515
#define END_OF_HOB_LIST(HobStart)
Definition: HobLib.h:531
UINT32 EFI_BOOT_MODE
Definition: PiBootMode.h:18
UINT32 EFI_RESOURCE_TYPE
Definition: PiHob.h:223
UINT32 EFI_RESOURCE_ATTRIBUTE_TYPE
Definition: PiHob.h:240
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:49
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:28
VOID * EFI_HANDLE
Definition: UefiBaseType.h:32
#define EFI_SUCCESS
Definition: UefiBaseType.h:111
EFI_MEMORY_TYPE
EFI_GUID Name
Definition: PiHob.h:344
EFI_BOOT_MODE BootMode
Definition: PiHob.h:74
Definition: Base.h:213