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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "SmbiosPlatformDxe.h"
18 #include <Library/HobLib.h>
19 #include <Guid/XenInfo.h>
21 #define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
22 #define XEN_SMBIOS_PHYSICAL_END 0x000F0000
25 Validates the SMBIOS entry point structure
27 @param EntryPointStructure SMBIOS entry point structure
29 @retval TRUE The entry point structure is valid
30 @retval FALSE The entry point structure is not valid
35 IsEntryPointStructureValid (
36 IN SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
44 BytePtr
= (UINT8
*) EntryPointStructure
;
45 Length
= EntryPointStructure
->EntryPointLength
;
48 for (Index
= 0; Index
< Length
; Index
++) {
49 Checksum
= Checksum
+ (UINT8
) BytePtr
[Index
];
60 Locates the Xen SMBIOS data if it exists
62 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
65 SMBIOS_TABLE_ENTRY_POINT
*
71 SMBIOS_TABLE_ENTRY_POINT
*XenSmbiosEntryPointStructure
;
72 EFI_HOB_GUID_TYPE
*GuidHob
;
75 // See if a XenInfo HOB is available
77 GuidHob
= GetFirstGuidHob (&gEfiXenInfoGuid
);
78 if (GuidHob
== NULL
) {
82 for (XenSmbiosPtr
= (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_ADDRESS
;
83 XenSmbiosPtr
< (UINT8
*)(UINTN
) XEN_SMBIOS_PHYSICAL_END
;
84 XenSmbiosPtr
+= 0x10) {
86 XenSmbiosEntryPointStructure
= (SMBIOS_TABLE_ENTRY_POINT
*) XenSmbiosPtr
;
88 if (!AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->AnchorString
, "_SM_", 4) &&
89 !AsciiStrnCmp ((CHAR8
*) XenSmbiosEntryPointStructure
->IntermediateAnchorString
, "_DMI_", 5) &&
90 IsEntryPointStructureValid (XenSmbiosEntryPointStructure
)) {
92 return XenSmbiosEntryPointStructure
;