]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/SmbiosPlatformDxe/Xen.c
EDK II Packages: Add Contributions.txt and License.txt files
[mirror_edk2.git] / OvmfPkg / SmbiosPlatformDxe / Xen.c
1 /** @file
2 Detect Xen hvmloader SMBIOS data for usage by OVMF.
3
4 Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
5 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6
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
11
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.
14
15 **/
16
17 #include "SmbiosPlatformDxe.h"
18 #include <Library/HobLib.h>
19 #include <Guid/XenInfo.h>
20
21 #define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
22 #define XEN_SMBIOS_PHYSICAL_END 0x000F0000
23
24 /**
25 Locates the Xen SMBIOS data if it exists
26
27 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
28
29 **/
30 SMBIOS_TABLE_ENTRY_POINT *
31 GetXenSmbiosTables (
32 VOID
33 )
34 {
35 UINT8 *XenSmbiosPtr;
36 SMBIOS_TABLE_ENTRY_POINT *XenSmbiosEntryPointStructure;
37 EFI_HOB_GUID_TYPE *GuidHob;
38
39 //
40 // See if a XenInfo HOB is available
41 //
42 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
43 if (GuidHob == NULL) {
44 return NULL;
45 }
46
47 for (XenSmbiosPtr = (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_ADDRESS;
48 XenSmbiosPtr < (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_END;
49 XenSmbiosPtr += 0x10) {
50
51 XenSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) XenSmbiosPtr;
52
53 if (!AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
54 !AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
55 IsEntryPointStructureValid (XenSmbiosEntryPointStructure)) {
56
57 return XenSmbiosEntryPointStructure;
58
59 }
60 }
61
62 return NULL;
63 }