summaryrefslogtreecommitdiff
path: root/src/soc/amd/picasso/agesa_acpi.c
blob: fb168a1f5a552a77ba1a8487e40e1406ee1fff09 (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
51
52
53
54
55
/* SPDX-License-Identifier: GPL-2.0-only */

#include <acpi/acpi.h>
#include <console/console.h>
#include <fsp/util.h>
#include <FspGuids.h>
#include <soc/acpi.h>
#include <stdint.h>

struct amd_fsp_acpi_hob_info {
	uint32_t table_size_in_bytes;
	uint8_t total_hobs_for_table;
	uint8_t sequence_number;
	uint16_t reserved;
	uint16_t hob_payload[0xffc8];
} __packed;

static uintptr_t add_agesa_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp,
				      uintptr_t current)
{
	const struct amd_fsp_acpi_hob_info *data;
	void *table = (void *)current;
	size_t hob_size;

	data = fsp_find_extension_hob_by_guid(guid.b, &hob_size);
	if (!data) {
		printk(BIOS_ERR, "AGESA %s ACPI table was not found.\n", name);
		return current;
	}

	printk(BIOS_INFO, "ACPI:    * %s (AGESA).\n", name);

	memcpy(table, data->hob_payload, data->table_size_in_bytes);

	current += data->table_size_in_bytes;
	acpi_add_table(rsdp, table);
	current = acpi_align_current(current);

	return current;
}

uintptr_t agesa_write_acpi_tables(const struct device *device, uintptr_t current,
				  acpi_rsdp_t *rsdp)
{
	printk(BIOS_DEBUG, "Searching for AGESA FSP ACPI Tables\n");

	current = add_agesa_acpi_table(AMD_FSP_ACPI_SSDT_HOB_GUID, "SSDT", rsdp, current);
	current = add_agesa_acpi_table(AMD_FSP_ACPI_CRAT_HOB_GUID, "CRAT", rsdp, current);
	current = add_agesa_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current);
	current = add_agesa_acpi_table(AMD_FSP_ACPI_IVRS_HOB_GUID, "IVRS", rsdp, current);

	/* Add SRAT, MSCT, SLIT if needed in the future */

	return current;
}