2018-06-28 03:38:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* EFI application ACPI tables support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <efi_loader.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2021-12-01 16:02:42 +00:00
|
|
|
#include <mapmem.h>
|
2020-04-08 22:57:36 +00:00
|
|
|
#include <acpi/acpi_table.h>
|
2023-07-16 03:39:17 +00:00
|
|
|
#include <asm/global_data.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2018-06-28 03:38:03 +00:00
|
|
|
|
|
|
|
static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install the ACPI table as a configuration table.
|
|
|
|
*
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: status code
|
2018-06-28 03:38:03 +00:00
|
|
|
*/
|
|
|
|
efi_status_t efi_acpi_register(void)
|
|
|
|
{
|
2023-07-16 03:39:17 +00:00
|
|
|
ulong addr, start, end;
|
2018-06-28 03:38:03 +00:00
|
|
|
efi_status_t ret;
|
|
|
|
|
2023-07-16 03:39:17 +00:00
|
|
|
/* Mark space used for tables */
|
|
|
|
start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
|
|
|
|
end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
|
|
|
|
ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY);
|
2018-06-28 03:38:03 +00:00
|
|
|
if (ret != EFI_SUCCESS)
|
|
|
|
return ret;
|
2023-07-16 03:39:17 +00:00
|
|
|
if (gd->arch.table_start_high) {
|
|
|
|
start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK);
|
|
|
|
end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
|
|
|
|
ret = efi_add_memory_map(start, end - start,
|
|
|
|
EFI_ACPI_RECLAIM_MEMORY);
|
|
|
|
if (ret != EFI_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
}
|
2018-06-28 03:38:03 +00:00
|
|
|
|
2023-07-16 03:39:17 +00:00
|
|
|
addr = gd_acpi_start();
|
|
|
|
printf("EFI using ACPI tables at %lx\n", addr);
|
2018-06-28 03:38:03 +00:00
|
|
|
|
|
|
|
/* And expose them to our EFI payload */
|
|
|
|
return efi_install_configuration_table(&acpi_guid,
|
2023-07-16 03:39:17 +00:00
|
|
|
(void *)(ulong)addr);
|
2018-06-28 03:38:03 +00:00
|
|
|
}
|