[PATCH v2 5/9] acpi: enable writing ACPI tables on QEMU

Simon Glass sjg at chromium.org
Sat Dec 16 19:46:10 CET 2023


Hi Heinrich,

On Fri, 15 Dec 2023 at 06:33, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Invoke write_acpi_tables() via EVT_LAST_STAGE_INIT on QEMU except on X86.
> X86 calls write_acpi_tables() in write_tables().
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> v2:
>         new patch
> ---
>  drivers/misc/qfw_acpi.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>

This is fine for now.

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

I would like to collect all tables generation into one piece, using a
bloblist to hold them, so they are contiguous. This is implemented on
x86, but is optional.

Still, this patch gets things running and makes it possible to make
such a change later.

> diff --git a/drivers/misc/qfw_acpi.c b/drivers/misc/qfw_acpi.c
> index 6e14b2a504..7ffed1e8c0 100644
> --- a/drivers/misc/qfw_acpi.c
> +++ b/drivers/misc/qfw_acpi.c
> @@ -9,9 +9,11 @@
>  #include <acpi/acpi_table.h>
>  #include <errno.h>
>  #include <malloc.h>
> +#include <mapmem.h>
>  #include <qfw.h>
>  #include <tables_csum.h>
>  #include <stdio.h>
> +#include <linux/sizes.h>
>  #include <asm/byteorder.h>
>  #include <asm/global_data.h>
>
> @@ -254,3 +256,26 @@ ulong acpi_get_rsdp_addr(void)
>         file = qfw_find_file(dev, "etc/acpi/rsdp");
>         return file->addr;
>  }
> +
> +#ifndef CONFIG_X86
> +static int evt_write_acpi_tables(void)
> +{
> +       ulong addr, end;
> +       void *ptr;
> +
> +       /* Reserve 64K for ACPI tables, aligned to a 4K boundary */
> +       ptr = memalign(SZ_4K, SZ_64K);
> +       if (!ptr)
> +               return -ENOMEM;
> +       addr = map_to_sysmem(ptr);
> +
> +       /* Generate ACPI tables */
> +       end = write_acpi_tables(addr);
> +       gd->arch.table_start = addr;
> +       gd->arch.table_end = addr;
> +
> +       return 0;
> +}
> +
> +EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, evt_write_acpi_tables);
> +#endif
> --
> 2.40.1
>

Regards,
Simon


More information about the U-Boot mailing list