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 | |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 8 | #include <efi_loader.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 367f00d | 2021-12-01 09:02:42 -0700 | [diff] [blame] | 10 | #include <mapmem.h> |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 11 | #include <acpi/acpi_table.h> |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 12 | #include <asm/global_data.h> |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 15 | |
| 16 | static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; |
| 17 | |
| 18 | /* |
| 19 | * Install the ACPI table as a configuration table. |
| 20 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 21 | * Return: status code |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 22 | */ |
| 23 | efi_status_t efi_acpi_register(void) |
| 24 | { |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 25 | ulong addr, start, end; |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 26 | efi_status_t ret; |
| 27 | |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 28 | /* Mark space used for tables */ |
| 29 | start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK); |
| 30 | end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK); |
| 31 | ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY); |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 32 | if (ret != EFI_SUCCESS) |
| 33 | return ret; |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 34 | if (gd->arch.table_start_high) { |
| 35 | start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK); |
| 36 | end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK); |
| 37 | ret = efi_add_memory_map(start, end - start, |
| 38 | EFI_ACPI_RECLAIM_MEMORY); |
| 39 | if (ret != EFI_SUCCESS) |
| 40 | return ret; |
| 41 | } |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 42 | |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 43 | addr = gd_acpi_start(); |
Heinrich Schuchardt | 3b56ffd | 2024-04-09 22:48:24 +0200 | [diff] [blame] | 44 | log_debug("EFI using ACPI tables at %lx\n", addr); |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 45 | |
| 46 | /* And expose them to our EFI payload */ |
| 47 | return efi_install_configuration_table(&acpi_guid, |
Simon Glass | 8965f29 | 2023-07-15 21:39:17 -0600 | [diff] [blame] | 48 | (void *)(ulong)addr); |
Bin Meng | 2cfbdae | 2018-06-27 20:38:03 -0700 | [diff] [blame] | 49 | } |