Hi Patrick, On Thu, 26 Sept 2024 at 10:02, Patrick Rudolph <[email protected]> wrote: > > Allocate memory for ACPI tables inside the efi_loader and write out > the tables similar to SMBIOS tables. When ACPI is enabled and wasn't > installed in other places, install the ACPI table in EFI. Since EFI > is necessary to pass the ACPI table location when FDT isn't used, > there's no need to install it separately. > > When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a > bloblist. The tables are still passed to the OS using EFI. > > This allows non x86 platforms to boot using ACPI only in case the > EFI loader is being used. > > TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only. > > Signed-off-by: Patrick Rudolph <[email protected]> > Cc: Simon Glass <[email protected]> > Cc: Tom Rini <[email protected]> > --- > Changelog v3: > - Drop memalign and use efi_allocate_pages > - Use log_debug instead of debug > - Clarify commit message > - Skip writing ACPI tables on sandbox > - Rename function > - Add function comment > > --- > lib/efi_loader/efi_acpi.c | 80 +++++++++++++++++++++++++++++++- > test/py/tests/test_event_dump.py | 1 + > 2 files changed, 79 insertions(+), 2 deletions(-) > > diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c > index 67bd7f8ca2..9d38d0060c 100644 > --- a/lib/efi_loader/efi_acpi.c > +++ b/lib/efi_loader/efi_acpi.c > @@ -6,15 +6,23 @@ > */ > > #include <efi_loader.h> > -#include <log.h> > -#include <mapmem.h> > #include <acpi/acpi_table.h> > #include <asm/global_data.h> > +#include <asm/io.h> > +#include <bloblist.h> > +#include <linux/sizes.h> > +#include <linux/log2.h> > +#include <log.h> > +#include <malloc.h> > +#include <mapmem.h> > > DECLARE_GLOBAL_DATA_PTR; > > static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; > > +enum { > + TABLE_SIZE = SZ_64K, > +}; > /* > * Install the ACPI table as a configuration table. > * > @@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void) > return efi_install_configuration_table(&acpi_guid, > (void *)(ulong)addr); > } > + > +/* > + * Allocate memory for ACPI tables and write ACPI tables to the > + * allocated buffer. > + * > + * Return: status code > + */ > +static int alloc_write_acpi_tables(void) > +{ > + u64 table_addr, table_end; > + u64 new_acpi_addr = 0; > + efi_uintn_t pages; > + efi_status_t ret; > + void *addr; > + > + if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) > + return 0; > + > + if (IS_ENABLED(CONFIG_X86) || > + IS_ENABLED(CONFIG_QFW_ACPI) || > + IS_ENABLED(CONFIG_SANDBOX)) { > + log_debug("Skipping writing ACPI tables as already done\n"); > + return 0; > + } > + > + /* Align the table to a 4KB boundary to keep EFI happy */ > + if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) { > + addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE, > + ilog2(SZ_4K)); > + > + if (!addr) > + return log_msg_ret("mem", -ENOMEM); > + } else { > + pages = efi_size_in_pages(TABLE_SIZE); > + > + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, > + EFI_ACPI_RECLAIM_MEMORY, > + pages, &new_acpi_addr); > + if (ret != EFI_SUCCESS) > + return log_msg_ret("mem", -ENOMEM); > + > + addr = (void *)(uintptr_t)new_acpi_addr; > + }
You can drop the if and the else, since bloblist is always enabled for ACPI on Arm. If you set gd->arch.table_start and gd->arch.table_end then efi_acpi.c will add your ACPI table to the memory map. [..] Regards, Simon

