1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * EFI application ACPI tables support 4 * 5 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> 6 */ 7 8 #include <common.h> 9 #include <efi_loader.h> 10 #include <log.h> 11 #include <mapmem.h> 12 #include <acpi/acpi_table.h> 13 14 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; 15 16 /* 17 * Install the ACPI table as a configuration table. 18 * 19 * Return: status code 20 */ efi_acpi_register(void)21efi_status_t efi_acpi_register(void) 22 { 23 /* Map within the low 32 bits, to allow for 32bit ACPI tables */ 24 u64 acpi = U32_MAX; 25 efi_status_t ret; 26 ulong addr; 27 28 /* Reserve 64kiB page for ACPI */ 29 ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, 30 EFI_ACPI_RECLAIM_MEMORY, 16, &acpi); 31 if (ret != EFI_SUCCESS) 32 return ret; 33 34 /* 35 * Generate ACPI tables - we know that efi_allocate_pages() returns 36 * a 4k-aligned address, so it is safe to assume that 37 * write_acpi_tables() will write the table at that address. 38 */ 39 addr = map_to_sysmem((void *)(ulong)acpi); 40 write_acpi_tables(addr); 41 42 /* And expose them to our EFI payload */ 43 return efi_install_configuration_table(&acpi_guid, 44 (void *)(uintptr_t)acpi); 45 } 46