Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
| 4 | #include <amdblocks/acpi.h> |
| 5 | #include <console/console.h> |
| 6 | #include <fsp/util.h> |
Felix Held | 112c227 | 2024-01-26 15:33:59 +0100 | [diff] [blame^] | 7 | #include <FspGuids.h> |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 8 | #include <string.h> |
| 9 | #include <types.h> |
| 10 | |
| 11 | struct amd_fsp_acpi_hob_info { |
| 12 | uint32_t table_size_in_bytes; |
| 13 | uint8_t total_hobs_for_table; |
| 14 | uint8_t sequence_number; |
| 15 | uint16_t reserved; |
| 16 | uint16_t hob_payload[0xffc8]; /* maximum payload size */ |
| 17 | } __packed; |
| 18 | |
Felix Held | 112c227 | 2024-01-26 15:33:59 +0100 | [diff] [blame^] | 19 | static unsigned long add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp, |
| 20 | unsigned long current) |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 21 | { |
| 22 | const struct amd_fsp_acpi_hob_info *data; |
| 23 | void *table = (void *)current; |
| 24 | size_t hob_size; |
| 25 | |
| 26 | data = fsp_find_extension_hob_by_guid(guid.b, &hob_size); |
Felix Held | ebc36c1 | 2022-08-10 16:34:47 +0200 | [diff] [blame] | 27 | if (data == NULL) { |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 28 | printk(BIOS_ERR, "AGESA %s ACPI table was not found.\n", name); |
| 29 | return current; |
| 30 | } |
| 31 | |
Felix Held | 75a2355 | 2021-05-04 20:18:41 +0200 | [diff] [blame] | 32 | if (data->table_size_in_bytes > sizeof(data->hob_payload)) { |
| 33 | printk(BIOS_ERR, "AGESA %s ACPI table size larger than maximum HOB payload " |
| 34 | "size.\n", name); |
| 35 | return current; |
| 36 | } |
| 37 | |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 38 | printk(BIOS_INFO, "ACPI: * %s (AGESA).\n", name); |
| 39 | |
| 40 | memcpy(table, data->hob_payload, data->table_size_in_bytes); |
| 41 | |
| 42 | current += data->table_size_in_bytes; |
| 43 | acpi_add_table(rsdp, table); |
| 44 | current = acpi_align_current(current); |
| 45 | |
| 46 | return current; |
| 47 | } |
Felix Held | 112c227 | 2024-01-26 15:33:59 +0100 | [diff] [blame^] | 48 | |
| 49 | unsigned long acpi_add_fsp_tables(unsigned long current, acpi_rsdp_t *rsdp) |
| 50 | { |
| 51 | /* add ALIB SSDT from HOB */ |
| 52 | current = acpi_align_current(current); |
| 53 | current = add_agesa_fsp_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current); |
| 54 | |
| 55 | return current; |
| 56 | } |