]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/SmbiosPlatformDxe/X86Xen.c
OvmfPkg/PlatformDxe: list "Platform.h" in the INF file
[mirror_edk2.git] / OvmfPkg / SmbiosPlatformDxe / X86Xen.c
CommitLineData
3e92a997
LE
1/** @file\r
2 Detect Xen hvmloader SMBIOS data for usage by OVMF.\r
3\r
4 Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>\r
5 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "SmbiosPlatformDxe.h"\r
18#include <Library/HobLib.h>\r
19#include <Guid/XenInfo.h>\r
20\r
21#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000\r
22#define XEN_SMBIOS_PHYSICAL_END 0x000F0000\r
23\r
24/**\r
25 Validates the SMBIOS entry point structure\r
26\r
27 @param EntryPointStructure SMBIOS entry point structure\r
28\r
29 @retval TRUE The entry point structure is valid\r
30 @retval FALSE The entry point structure is not valid\r
31\r
32**/\r
33STATIC\r
34BOOLEAN\r
35IsEntryPointStructureValid (\r
36 IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure\r
37 )\r
38{\r
39 UINTN Index;\r
40 UINT8 Length;\r
41 UINT8 Checksum;\r
42 UINT8 *BytePtr;\r
43\r
44 BytePtr = (UINT8*) EntryPointStructure;\r
45 Length = EntryPointStructure->EntryPointLength;\r
46 Checksum = 0;\r
47\r
48 for (Index = 0; Index < Length; Index++) {\r
49 Checksum = Checksum + (UINT8) BytePtr[Index];\r
50 }\r
51\r
52 if (Checksum != 0) {\r
53 return FALSE;\r
54 } else {\r
55 return TRUE;\r
56 }\r
57}\r
58\r
59/**\r
60 Locates the Xen SMBIOS data if it exists\r
61\r
62 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data\r
63\r
64**/\r
65SMBIOS_TABLE_ENTRY_POINT *\r
66GetXenSmbiosTables (\r
67 VOID\r
68 )\r
69{\r
70 UINT8 *XenSmbiosPtr;\r
71 SMBIOS_TABLE_ENTRY_POINT *XenSmbiosEntryPointStructure;\r
72 EFI_HOB_GUID_TYPE *GuidHob;\r
73\r
74 //\r
75 // See if a XenInfo HOB is available\r
76 //\r
77 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
78 if (GuidHob == NULL) {\r
79 return NULL;\r
80 }\r
81\r
82 for (XenSmbiosPtr = (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_ADDRESS;\r
83 XenSmbiosPtr < (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_END;\r
84 XenSmbiosPtr += 0x10) {\r
85\r
86 XenSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) XenSmbiosPtr;\r
87\r
88 if (!AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&\r
89 !AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&\r
90 IsEntryPointStructureValid (XenSmbiosEntryPointStructure)) {\r
91\r
92 return XenSmbiosEntryPointStructure;\r
93\r
94 }\r
95 }\r
96\r
97 return NULL;\r
98}\r