VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/SmbiosPlatformDxe/X86Xen.c@ 107675

最後變更 在這個檔案從107675是 99404,由 vboxsync 提交於 2 年 前

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 2.2 KB
 
1/** @file
2 Detect Xen hvmloader SMBIOS data for usage by OVMF.
3
4 Copyright (c) 2011, Bei Guan <[email protected]>
5 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10
11#include <Library/BaseLib.h> // AsciiStrnCmp()
12#include <Library/HobLib.h> // GetFirstGuidHob()
13#include <Pi/PiHob.h> // EFI_HOB_GUID_TYPE
14
15#include "XenSmbiosPlatformDxe.h"
16
17#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
18#define XEN_SMBIOS_PHYSICAL_END 0x000F0000
19
20/**
21 Validates the SMBIOS entry point structure
22
23 @param EntryPointStructure SMBIOS entry point structure
24
25 @retval TRUE The entry point structure is valid
26 @retval FALSE The entry point structure is not valid
27
28**/
29STATIC
30BOOLEAN
31IsEntryPointStructureValid (
32 IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure
33 )
34{
35 UINTN Index;
36 UINT8 Length;
37 UINT8 Checksum;
38 UINT8 *BytePtr;
39
40 BytePtr = (UINT8 *)EntryPointStructure;
41 Length = EntryPointStructure->EntryPointLength;
42 Checksum = 0;
43
44 for (Index = 0; Index < Length; Index++) {
45 Checksum = Checksum + (UINT8)BytePtr[Index];
46 }
47
48 if (Checksum != 0) {
49 return FALSE;
50 } else {
51 return TRUE;
52 }
53}
54
55/**
56 Locates the Xen SMBIOS data if it exists
57
58 @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
59
60**/
61SMBIOS_TABLE_ENTRY_POINT *
62GetXenSmbiosTables (
63 VOID
64 )
65{
66 UINT8 *XenSmbiosPtr;
67 SMBIOS_TABLE_ENTRY_POINT *XenSmbiosEntryPointStructure;
68 EFI_HOB_GUID_TYPE *GuidHob;
69
70 //
71 // See if a XenInfo HOB is available
72 //
73 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
74 if (GuidHob == NULL) {
75 return NULL;
76 }
77
78 for (XenSmbiosPtr = (UINT8 *)(UINTN)XEN_SMBIOS_PHYSICAL_ADDRESS;
79 XenSmbiosPtr < (UINT8 *)(UINTN)XEN_SMBIOS_PHYSICAL_END;
80 XenSmbiosPtr += 0x10)
81 {
82 XenSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)XenSmbiosPtr;
83
84 if (!AsciiStrnCmp ((CHAR8 *)XenSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
85 !AsciiStrnCmp ((CHAR8 *)XenSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
86 IsEntryPointStructureValid (XenSmbiosEntryPointStructure))
87 {
88 return XenSmbiosEntryPointStructure;
89 }
90 }
91
92 return NULL;
93}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette