summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/Library')
-rw-r--r--OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c67
-rw-r--r--OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf26
2 files changed, 93 insertions, 0 deletions
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
new file mode 100644
index 0000000000..9dd9026edb
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
@@ -0,0 +1,67 @@
+/** @file
+ OVMF ACPI support
+
+ Copyright (C) 2021, Red Hat, Inc.
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012, Bei Guan <gbtju85@gmail.com>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AcpiPlatformLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+EFI_STATUS
+EFIAPI
+GetAcpiRsdpFromMemory (
+ IN UINTN StartAddress,
+ IN UINTN EndAddress,
+ OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr
+ )
+{
+ EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdpStructurePtr;
+ UINT8 *AcpiPtr;
+ UINT8 Sum;
+
+ for (AcpiPtr = (UINT8 *)StartAddress;
+ AcpiPtr < (UINT8 *)EndAddress;
+ AcpiPtr += 0x10)
+ {
+ RsdpStructurePtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)
+ (UINTN)AcpiPtr;
+
+ if (!AsciiStrnCmp ((CHAR8 *)&RsdpStructurePtr->Signature, "RSD PTR ", 8)) {
+ //
+ // RSDP ACPI 1.0 checksum for 1.0/2.0/3.0 table.
+ // This is only the first 20 bytes of the structure
+ //
+ Sum = CalculateSum8 (
+ (CONST UINT8 *)RsdpStructurePtr,
+ sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
+ );
+ if (Sum != 0) {
+ return EFI_ABORTED;
+ }
+
+ if (RsdpStructurePtr->Revision >= 2) {
+ //
+ // RSDP ACPI 2.0/3.0 checksum, this is the entire table
+ //
+ Sum = CalculateSum8 (
+ (CONST UINT8 *)RsdpStructurePtr,
+ sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
+ );
+ if (Sum != 0) {
+ return EFI_ABORTED;
+ }
+ }
+
+ *RsdpPtr = RsdpStructurePtr;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
new file mode 100644
index 0000000000..dfe0e5623d
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -0,0 +1,26 @@
+## @file
+# ACPI Platform Library Instance.
+#
+# Copyright (C) 2023, Corvin Köhne <corvink@FreeBSD.org>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeAcpiPlatformLib
+ FILE_GUID = 578F441A-4A4C-4D24-B9BE-F783152B46F6
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AcpiPlatformLib
+
+[Sources]
+ DxeAcpiPlatformLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib