2 Detect Xen hvmloader SMBIOS data for usage by OVMF.
4 Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
5 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/BaseLib.h> // AsciiStrnCmp()
12 #include <Library/HobLib.h> // GetFirstGuidHob()
13 #include <Pi/PiHob.h> // EFI_HOB_GUID_TYPE
15 #include "SmbiosPlatformDxe.h"
17 #define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
18 #define XEN_SMBIOS_PHYSICAL_END 0x000F0000
21 Validates the SMBIOS entry point structure
23 @param EntryPointStructure SMBIOS entry point structure
25 @retval TRUE The entry point structure is valid
26 @retval FALSE The entry point structure is not valid
31 IsEntryPointStructureValid (
32 IN SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
40 BytePtr
= (UINT8
*) EntryPointStructure
;
41 Length
= EntryPointStructure
->EntryPointLength
;
44 for (Index
= 0; Index
< Length
; Index
++) {
45 Checksum
= Checksum
+ (UINT8
) BytePtr
[Index
];
56 Locates the Xen SMBIOS data if it exists
58 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
61 SMBIOS_TABLE_ENTRY_POINT
*
67 SMBIOS_TABLE_ENTRY_POINT
*XenSmbiosEntryPointStructure
;
68 EFI_HOB_GUID_TYPE
*GuidHob
;
71 // See if a XenInfo HOB is available
73 GuidHob
= GetFirstGuidHob (&gEfiXenInfoGuid
);
74 if (GuidHob
== NULL
) {
78 for (XenSmbiosPtr
= (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_ADDRESS
;
79 XenSmbiosPtr
< (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_END
;
80 XenSmbiosPtr
+= 0x10) {
82 XenSmbiosEntryPointStructure
= (SMBIOS_TABLE_ENTRY_POINT
*) XenSmbiosPtr
;
84 if (!AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->AnchorString
, "_SM_", 4) &&
85 !AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->IntermediateAnchorString
, "_DMI_", 5) &&
86 IsEntryPointStructureValid (XenSmbiosEntryPointStructure
)) {
88 return XenSmbiosEntryPointStructure
;