blob: f755af76f8665ff5261c6141f6e9038d5c4395d0 [file] [log] [blame]
Bin Meng2cfbdae2018-06-27 20:38:03 -07001// 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 Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Simon Glass367f00d2021-12-01 09:02:42 -070011#include <mapmem.h>
Simon Glass858fed12020-04-08 16:57:36 -060012#include <acpi/acpi_table.h>
Simon Glass8965f292023-07-15 21:39:17 -060013#include <asm/global_data.h>
14
15DECLARE_GLOBAL_DATA_PTR;
Bin Meng2cfbdae2018-06-27 20:38:03 -070016
17static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
18
19/*
20 * Install the ACPI table as a configuration table.
21 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010022 * Return: status code
Bin Meng2cfbdae2018-06-27 20:38:03 -070023 */
24efi_status_t efi_acpi_register(void)
25{
Simon Glass8965f292023-07-15 21:39:17 -060026 ulong addr, start, end;
Bin Meng2cfbdae2018-06-27 20:38:03 -070027 efi_status_t ret;
28
Simon Glass8965f292023-07-15 21:39:17 -060029 /* Mark space used for tables */
30 start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
31 end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
32 ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY);
Bin Meng2cfbdae2018-06-27 20:38:03 -070033 if (ret != EFI_SUCCESS)
34 return ret;
Simon Glass8965f292023-07-15 21:39:17 -060035 if (gd->arch.table_start_high) {
36 start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK);
37 end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
38 ret = efi_add_memory_map(start, end - start,
39 EFI_ACPI_RECLAIM_MEMORY);
40 if (ret != EFI_SUCCESS)
41 return ret;
42 }
Bin Meng2cfbdae2018-06-27 20:38:03 -070043
Simon Glass8965f292023-07-15 21:39:17 -060044 addr = gd_acpi_start();
45 printf("EFI using ACPI tables at %lx\n", addr);
Bin Meng2cfbdae2018-06-27 20:38:03 -070046
47 /* And expose them to our EFI payload */
48 return efi_install_configuration_table(&acpi_guid,
Simon Glass8965f292023-07-15 21:39:17 -060049 (void *)(ulong)addr);
Bin Meng2cfbdae2018-06-27 20:38:03 -070050}