Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 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> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 11 | #include <acpi/acpi_table.h> |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 12 | |
| 13 | static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; |
| 14 | |
| 15 | /* |
| 16 | * Install the ACPI table as a configuration table. |
| 17 | * |
| 18 | * @return status code |
| 19 | */ |
| 20 | efi_status_t efi_acpi_register(void) |
| 21 | { |
| 22 | /* Map within the low 32 bits, to allow for 32bit ACPI tables */ |
| 23 | u64 acpi = U32_MAX; |
| 24 | efi_status_t ret; |
| 25 | |
| 26 | /* Reserve 64kiB page for ACPI */ |
| 27 | ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, |
Heinrich Schuchardt | c462ae4 | 2021-02-21 10:16:58 +0100 | [diff] [blame] | 28 | EFI_ACPI_RECLAIM_MEMORY, 16, &acpi); |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 29 | if (ret != EFI_SUCCESS) |
| 30 | return ret; |
| 31 | |
| 32 | /* |
| 33 | * Generate ACPI tables - we know that efi_allocate_pages() returns |
| 34 | * a 4k-aligned address, so it is safe to assume that |
| 35 | * write_acpi_tables() will write the table at that address. |
| 36 | */ |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 37 | write_acpi_tables(acpi); |
| 38 | |
| 39 | /* And expose them to our EFI payload */ |
| 40 | return efi_install_configuration_table(&acpi_guid, |
| 41 | (void *)(uintptr_t)acpi); |
| 42 | } |