]> git.proxmox.com Git - mirror_edk2.git/blob - UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c
8bb31b3f9c3f69d5d23bdaf2cadf95c7bd6ea4c0
[mirror_edk2.git] / UefiPayloadPkg / Library / DxeHobListLib / DxeHobListLib.c
1 /** @file
2 This library retrieve the EFI_BOOT_SERVICES pointer from EFI system table in
3 library's constructor.
4
5 Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10
11 #include <Uefi.h>
12
13 VOID *gHobList = NULL;
14
15 /**
16 Local implementation of GUID comparasion that doesn't depend on DebugLib::ASSERT().
17
18 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
19 If there are any bit differences in the two GUIDs, then FALSE is returned.
20
21 @param Guid1 A pointer to a 128 bit GUID.
22 @param Guid2 A pointer to a 128 bit GUID.
23
24 @retval TRUE Guid1 and Guid2 are identical.
25 @retval FALSE Guid1 and Guid2 are not identical.
26 **/
27 BOOLEAN
28 LocalCompareGuid (
29 IN CONST GUID *Guid1,
30 IN CONST GUID *Guid2
31 )
32 {
33 UINT64 *Left;
34 UINT64 *Right;
35
36 Left = (UINT64 *) Guid1;
37 Right = (UINT64 *) Guid2;
38
39 return (BOOLEAN) (Left[0] == Right[0] && Left[1] == Right[1]);
40 }
41
42 /**
43 @param ImageHandle The firmware allocated handle for the EFI image.
44 @param SystemTable A pointer to the EFI System Table.
45
46 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
47
48 **/
49 EFI_STATUS
50 EFIAPI
51 DxeHobListLibConstructor (
52 IN EFI_HANDLE ImageHandle,
53 IN EFI_SYSTEM_TABLE *SystemTable
54 )
55 {
56 UINTN Index;
57
58 for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
59 if (LocalCompareGuid (&gEfiHobListGuid, &SystemTable->ConfigurationTable[Index].VendorGuid)) {
60 gHobList = SystemTable->ConfigurationTable[Index].VendorTable;
61 return EFI_SUCCESS;
62 }
63 }
64
65 return EFI_NOT_FOUND;
66 }