Xen and bhyve are placing ACPI tables into system memory. So, they can
share the same code. Therefore, create a new library which searches and
installs ACPI tables from system memory.
Signed-off-by: Corvin Köhne
Acked-by: Gerd Hoffmann
Cc: Ard Biesheuvel
Cc: Jiewen Yao
Cc: Jordan Justen
Cc: Anthony Perard
Cc: Julien Grall
---
OvmfPkg/OvmfPkg.dec | 4 +
OvmfPkg/OvmfXen.dsc | 1 +
.../AcpiPlatformLib/DxeAcpiPlatformLib.inf| 26
.../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf | 1 +
OvmfPkg/Include/Library/AcpiPlatformLib.h | 24
.../AcpiPlatformLib/DxeAcpiPlatformLib.c | 62 +
OvmfPkg/XenAcpiPlatformDxe/Xen.c | 119 +-
7 files changed, 147 insertions(+), 90 deletions(-)
create mode 100644 OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
create mode 100644 OvmfPkg/Include/Library/AcpiPlatformLib.h
create mode 100644 OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 03ae29e7b034..7b321ba01d72 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -20,6 +20,10 @@ [Includes]
Csm/Include
[LibraryClasses]
+ ## @libraryclass Search and install ACPI tables.
+ #
+ AcpiPlatformLib|Include/Library/AcpiPlatformLib.h
+
## @libraryclass Access bhyve's firmware control interface.
BhyveFwCtlLib|Include/Library/BhyveFwCtlLib.h
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 1f44ec86c9c7..ddcf8a36f513 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -321,6 +321,7 @@ [LibraryClasses.common.UEFI_DRIVER]
PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
[LibraryClasses.common.DXE_DRIVER]
+ AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
new file mode 100644
index ..dfe0e5623d32
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -0,0 +1,26 @@
+## @file
+# ACPI Platform Library Instance.
+#
+# Copyright (C) 2023, Corvin Köhne
+#
+# 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
diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
index d3a6353a50a6..65374569ddc2 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
+++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
@@ -32,6 +32,7 @@ [Packages]
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ AcpiPlatformLib
BaseLib
DebugLib
UefiBootServicesTableLib
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h
b/OvmfPkg/Include/Library/AcpiPlatformLib.h
new file mode 100644
index ..b0a3c5bd0048
--- /dev/null
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -0,0 +1,24 @@
+/** @file
+ Copyright (c) 2023, Corvin Köhne
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+/**
+ Searches and returns the address of the ACPI Root System Description Pointer
(RSDP) in system memory.
+
+ @param StartAddressStart address of search range.
+ @param EndAddress End address of search range.
+ @param RsdpPtr Return pointer to RSDP.
+
+ @retval EFI_SUCCESS RSDP successfully found.
+ @retval EFI_NOT_FOUND Couldn't find RSDP.
+ @retval EFI_ABORTED Invalid RSDP found.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiRsdpFromMemory (
+ IN UINT64 StartAddress,
+ IN UINT64 EndAddress,
+ OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr
+ );
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
new file mode 100644
index ..ce52ad31cf25
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
@@ -0,0 +1,62 @@
+/** @file
+ Copyright (c) 2023, Corvin Köhne
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include
+#include
+#include
+
+EFI_STATUS
+EFIAPI
+GetAcpiRsdpFromMemory (
+ IN UINTNStartAddress,
+ IN UINTNEndAddress,
+ OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr
+ )
+{
+ EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdpStructurePtr;
+ UINT8