[edk2-devel] [PATCH v5 1/3] OvmfPkg/Xen: export search of RSDP into a library function

2023-05-11 Thread Corvin Köhne
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

Re: [edk2-devel] [PATCH v5 1/3] OvmfPkg/Xen: export search of RSDP into a library function

2023-05-11 Thread Anthony PERARD via groups.io
On Thu, May 11, 2023 at 02:02:37PM +0200, Corvin Köhne wrote:
> 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 

As this new file move codes from OvmfPkg/XenAcpiPlatformDxe/Xen.c,
shouldn't you also copy the "Copyright" lines from that file as well?


Beside that, patch looks fine:
Reviewed-by: Anthony PERARD 

Thanks,

-- 
Anthony PERARD


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104703): https://edk2.groups.io/g/devel/message/104703
Mute This Topic: https://groups.io/mt/98825804/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 1/3] OvmfPkg/Xen: export search of RSDP into a library function

2023-06-01 Thread Ard Biesheuvel
On Thu, 11 May 2023 at 15:30, Anthony PERARD via groups.io
 wrote:
>
> On Thu, May 11, 2023 at 02:02:37PM +0200, Corvin Köhne wrote:
> > 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 
>
> As this new file move codes from OvmfPkg/XenAcpiPlatformDxe/Xen.c,
> shouldn't you also copy the "Copyright" lines from that file as well?
>
>
> Beside that, patch looks fine:
> Reviewed-by: Anthony PERARD 
>

Agreed

Doing a bit of amateur archaeology, I think we should retain these as well

Copyright (c) 2012, Bei Guan 
Copyright (C) 2021, Red Hat, Inc.


Also, please run this series through the CI (just send a PR to the
tiancore/edk2 github project - it will not get merged but it will tell
you if the CI spots any issues in the code)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105568): https://edk2.groups.io/g/devel/message/105568
Mute This Topic: https://groups.io/mt/98825804/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-