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 "SmbiosPlatformDxe.h"
12 #include <Library/HobLib.h>
13 #include <Guid/XenInfo.h>
15 #define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
16 #define XEN_SMBIOS_PHYSICAL_END 0x000F0000
19 Validates the SMBIOS entry point structure
21 @param EntryPointStructure SMBIOS entry point structure
23 @retval TRUE The entry point structure is valid
24 @retval FALSE The entry point structure is not valid
29 IsEntryPointStructureValid (
30 IN SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
38 BytePtr
= (UINT8
*) EntryPointStructure
;
39 Length
= EntryPointStructure
->EntryPointLength
;
42 for (Index
= 0; Index
< Length
; Index
++) {
43 Checksum
= Checksum
+ (UINT8
) BytePtr
[Index
];
54 Locates the Xen SMBIOS data if it exists
56 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
59 SMBIOS_TABLE_ENTRY_POINT
*
65 SMBIOS_TABLE_ENTRY_POINT
*XenSmbiosEntryPointStructure
;
66 EFI_HOB_GUID_TYPE
*GuidHob
;
69 // See if a XenInfo HOB is available
71 GuidHob
= GetFirstGuidHob (&gEfiXenInfoGuid
);
72 if (GuidHob
== NULL
) {
76 for (XenSmbiosPtr
= (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_ADDRESS
;
77 XenSmbiosPtr
< (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_END
;
78 XenSmbiosPtr
+= 0x10) {
80 XenSmbiosEntryPointStructure
= (SMBIOS_TABLE_ENTRY_POINT
*) XenSmbiosPtr
;
82 if (!AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->AnchorString
, "_SM_", 4) &&
83 !AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->IntermediateAnchorString
, "_DMI_", 5) &&
84 IsEntryPointStructureValid (XenSmbiosEntryPointStructure
)) {
86 return XenSmbiosEntryPointStructure
;