mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 14:25:56 +00:00

The add_u_boot_and_runtime() function paints with a broad brush, considering all of the memory from the top of U-Boot stack to gd->ram_top as EFI_RUNTIME_SERVICES_CODE This is fine, but we need to make sure we don't add a separate entry for any ACPI tables in this region (which happens when bloblist is used for tables). Otherwise the memory map looks strange and we get a test failure on qemu-x86 (only) for the 'virtual address map' test. Good map: Type Start End Attributes ================ ================ ================ ========== CONVENTIONAL 0000000000000000-00000000000a0000 WB RESERVED 00000000000a0000-00000000000f0000 WB RUNTIME DATA 00000000000f0000-00000000000f2000 WB|RT RESERVED 00000000000f2000-0000000000100000 WB CONVENTIONAL 0000000000100000-0000000005cc7000 WB BOOT DATA 0000000005cc7000-0000000005ccc000 WB RUNTIME DATA 0000000005ccc000-0000000005ccd000 WB|RT BOOT DATA 0000000005ccd000-0000000005cce000 WB RUNTIME DATA 0000000005cce000-0000000005cf0000 WB|RT BOOT DATA 0000000005cf0000-0000000006cf5000 WB RESERVED 0000000006cf5000-0000000006cfa000 WB ACPI RECLAIM MEM 0000000006cfa000-0000000006d1c000 WB RESERVED 0000000006d1c000-0000000006f35000 WB RUNTIME CODE 0000000006f35000-0000000006f37000 WB|RT RESERVED 0000000006f37000-0000000008000000 WB RESERVED 00000000e0000000-00000000f0000000 WB Bad map: (with BLOBLIST_TABLES but without this patch): Type Start End Attributes ================ ================ ================ ========== CONVENTIONAL 0000000000000000-00000000000a0000 WB RESERVED 00000000000a0000-00000000000f0000 WB ACPI RECLAIM MEM 00000000000f0000-00000000000f1000 WB RESERVED 00000000000f1000-0000000000100000 WB CONVENTIONAL 0000000000100000-0000000005ca5000 WB BOOT DATA 0000000005ca5000-0000000005caa000 WB RUNTIME DATA 0000000005caa000-0000000005cab000 WB|RT BOOT DATA 0000000005cab000-0000000005cac000 WB RUNTIME DATA 0000000005cac000-0000000005cce000 WB|RT BOOT DATA 0000000005cce000-0000000006cd3000 WB RUNTIME DATA 0000000006cd3000-0000000006cd5000 WB|RT BOOT DATA 0000000006cd5000-0000000006cf4000 WB RESERVED 0000000006cf4000-0000000006cf9000 WB ACPI RECLAIM MEM 0000000006cf9000-0000000006ce6000 WB Signed-off-by: Simon Glass <sjg@chromium.org>
59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* EFI application ACPI tables support
|
|
*
|
|
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
|
*/
|
|
|
|
#include <efi_loader.h>
|
|
#include <log.h>
|
|
#include <mapmem.h>
|
|
#include <acpi/acpi_table.h>
|
|
#include <asm/global_data.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
|
|
|
|
/*
|
|
* Install the ACPI table as a configuration table.
|
|
*
|
|
* Return: status code
|
|
*/
|
|
efi_status_t efi_acpi_register(void)
|
|
{
|
|
ulong addr, start, end;
|
|
efi_status_t ret;
|
|
|
|
/*
|
|
* The bloblist is already marked reserved. For now, we don't bother
|
|
* marking it with EFI_ACPI_RECLAIM_MEMORY since we would need to cut a
|
|
* hole in the EFI_BOOT_SERVICES_CODE region added by
|
|
* add_u_boot_and_runtime(). At some point that function could create a
|
|
* more detailed map.
|
|
*/
|
|
if (IS_ENABLED(CONFIG_BLOBLIST_TABLES))
|
|
return EFI_SUCCESS;
|
|
|
|
/* 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);
|
|
if (ret != EFI_SUCCESS)
|
|
return ret;
|
|
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;
|
|
}
|
|
|
|
addr = gd_acpi_start();
|
|
log_debug("EFI using ACPI tables at %lx\n", addr);
|
|
|
|
/* And expose them to our EFI payload */
|
|
return efi_install_configuration_table(&acpi_guid,
|
|
(void *)(ulong)addr);
|
|
}
|