aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_acpi.c
blob: f755af76f8665ff5261c6141f6e9038d5c4395d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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>
#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;

	/* 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();
	printf("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);
}