diff mbox series

[v2,5/7] riscv: qemu: copy ACPI tables from QEMU

Message ID 20231121152740.24783-6-heinrich.schuchardt@canonical.com
State Superseded, archived
Delegated to: Andes
Headers show
Series risc-v: add ACPI support on QEMU | expand

Commit Message

Heinrich Schuchardt Nov. 21, 2023, 3:27 p.m. UTC
If CONFIG_GENERATE_ACPI_TABLES=y, read the ACPI tables provided by QEMU
and make them available to U-Boot.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 board/emulation/qemu-riscv/qemu-riscv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Simon Glass Dec. 2, 2023, 6:23 p.m. UTC | #1
On Tue, 21 Nov 2023 at 08:28, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> If CONFIG_GENERATE_ACPI_TABLES=y, read the ACPI tables provided by QEMU
> and make them available to U-Boot.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         no change
> ---
>  board/emulation/qemu-riscv/qemu-riscv.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Can we not use common code to do this? What is different about ARM and x86?


>
> diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
> index 181abbbf97..2cebce2128 100644
> --- a/board/emulation/qemu-riscv/qemu-riscv.c
> +++ b/board/emulation/qemu-riscv/qemu-riscv.c
> @@ -4,17 +4,20 @@
>   */
>
>  #include <common.h>
> +#include <acpi/acpi_table.h>
>  #include <dm.h>
>  #include <dm/ofnode.h>
>  #include <env.h>
>  #include <fdtdec.h>
>  #include <image.h>
>  #include <log.h>
> +#include <malloc.h>
>  #include <spl.h>
>  #include <init.h>
>  #include <usb.h>
>  #include <virtio_types.h>
>  #include <virtio.h>
> +#include <linux/sizes.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -46,6 +49,20 @@ int board_late_init(void)
>         if (CONFIG_IS_ENABLED(USB_KEYBOARD))
>                 usb_init();
>
> +       if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
> +               uintptr_t addr;
> +               void *ptr;
> +
> +               /* Reserve 64K for ACPI tables, aligned to a 4K boundary */
> +               ptr = memalign(SZ_4K, SZ_64K);
> +               addr = (uintptr_t)ptr;
> +
> +               /* Generate ACPI tables */
> +               write_acpi_tables(addr);
> +               gd->arch.table_start = addr;
> +               gd->arch.table_end = addr;
> +       }
> +
>         return 0;
>  }
>
> --
> 2.40.1
>
Tom Rini Dec. 9, 2023, 1:45 p.m. UTC | #2
On Sat, Dec 02, 2023 at 11:23:19AM -0700, Simon Glass wrote:
> On Tue, 21 Nov 2023 at 08:28, Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
> >
> > If CONFIG_GENERATE_ACPI_TABLES=y, read the ACPI tables provided by QEMU
> > and make them available to U-Boot.
> >
> > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > ---
> > v2:
> >         no change
> > ---
> >  board/emulation/qemu-riscv/qemu-riscv.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Can we not use common code to do this? What is different about ARM and x86?

This is why I was trying to convince people we need a symbol that means
"handle ACPI tables for QEMU targets" as yes, this code too should be in
that common area I bet.
diff mbox series

Patch

diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index 181abbbf97..2cebce2128 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -4,17 +4,20 @@ 
  */
 
 #include <common.h>
+#include <acpi/acpi_table.h>
 #include <dm.h>
 #include <dm/ofnode.h>
 #include <env.h>
 #include <fdtdec.h>
 #include <image.h>
 #include <log.h>
+#include <malloc.h>
 #include <spl.h>
 #include <init.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
+#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +49,20 @@  int board_late_init(void)
 	if (CONFIG_IS_ENABLED(USB_KEYBOARD))
 		usb_init();
 
+	if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+		uintptr_t addr;
+		void *ptr;
+
+		/* Reserve 64K for ACPI tables, aligned to a 4K boundary */
+		ptr = memalign(SZ_4K, SZ_64K);
+		addr = (uintptr_t)ptr;
+
+		/* Generate ACPI tables */
+		write_acpi_tables(addr);
+		gd->arch.table_start = addr;
+		gd->arch.table_end = addr;
+	}
+
 	return 0;
 }