TianoCore EDK2 master
Loading...
Searching...
No Matches
X86Xen.c
Go to the documentation of this file.
1
11#include <Library/BaseLib.h> // AsciiStrnCmp()
12#include <Library/HobLib.h> // GetFirstGuidHob()
13#include <Pi/PiHob.h> // EFI_HOB_GUID_TYPE
14
16
17#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
18#define XEN_SMBIOS_PHYSICAL_END 0x000F0000
19
30BOOLEAN
32 IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure
33 )
34{
35 UINTN Index;
36 UINT8 Length;
37 UINT8 Checksum;
38 UINT8 *BytePtr;
39
40 BytePtr = (UINT8 *)EntryPointStructure;
41 Length = EntryPointStructure->EntryPointLength;
42 Checksum = 0;
43
44 for (Index = 0; Index < Length; Index++) {
45 Checksum = Checksum + (UINT8)BytePtr[Index];
46 }
47
48 if (Checksum != 0) {
49 return FALSE;
50 } else {
51 return TRUE;
52 }
53}
54
63 VOID
64 )
65{
66 UINT8 *XenSmbiosPtr;
67 SMBIOS_TABLE_ENTRY_POINT *XenSmbiosEntryPointStructure;
68 EFI_HOB_GUID_TYPE *GuidHob;
69
70 //
71 // See if a XenInfo HOB is available
72 //
73 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
74 if (GuidHob == NULL) {
75 return NULL;
76 }
77
78 for (XenSmbiosPtr = (UINT8 *)(UINTN)XEN_SMBIOS_PHYSICAL_ADDRESS;
79 XenSmbiosPtr < (UINT8 *)(UINTN)XEN_SMBIOS_PHYSICAL_END;
80 XenSmbiosPtr += 0x10)
81 {
82 XenSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)XenSmbiosPtr;
83
84 if (!AsciiStrnCmp ((CHAR8 *)XenSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
85 !AsciiStrnCmp ((CHAR8 *)XenSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
86 IsEntryPointStructureValid (XenSmbiosEntryPointStructure))
87 {
88 return XenSmbiosEntryPointStructure;
89 }
90 }
91
92 return NULL;
93}
UINT64 UINTN
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
Definition: String.c:872
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
SMBIOS_TABLE_ENTRY_POINT * GetXenSmbiosTables(VOID)
Definition: X86Xen.c:62
STATIC BOOLEAN IsEntryPointStructureValid(IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure)
Definition: X86Xen.c:31