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> |
| 7 | #include <string.h> |
| 8 | #include <types.h> |
| 9 | |
| 10 | struct amd_fsp_acpi_hob_info { |
| 11 | uint32_t table_size_in_bytes; |
| 12 | uint8_t total_hobs_for_table; |
| 13 | uint8_t sequence_number; |
| 14 | uint16_t reserved; |
| 15 | uint16_t hob_payload[0xffc8]; /* maximum payload size */ |
| 16 | } __packed; |
| 17 | |
Felix Held | 7f471dd | 2024-01-26 15:25:56 +0100 | [diff] [blame^] | 18 | unsigned long add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp, |
| 19 | unsigned long current) |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 20 | { |
| 21 | const struct amd_fsp_acpi_hob_info *data; |
| 22 | void *table = (void *)current; |
| 23 | size_t hob_size; |
| 24 | |
| 25 | data = fsp_find_extension_hob_by_guid(guid.b, &hob_size); |
Felix Held | ebc36c1 | 2022-08-10 16:34:47 +0200 | [diff] [blame] | 26 | if (data == NULL) { |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 27 | printk(BIOS_ERR, "AGESA %s ACPI table was not found.\n", name); |
| 28 | return current; |
| 29 | } |
| 30 | |
Felix Held | 75a2355 | 2021-05-04 20:18:41 +0200 | [diff] [blame] | 31 | if (data->table_size_in_bytes > sizeof(data->hob_payload)) { |
| 32 | printk(BIOS_ERR, "AGESA %s ACPI table size larger than maximum HOB payload " |
| 33 | "size.\n", name); |
| 34 | return current; |
| 35 | } |
| 36 | |
Felix Held | 245adca | 2021-05-04 20:01:46 +0200 | [diff] [blame] | 37 | printk(BIOS_INFO, "ACPI: * %s (AGESA).\n", name); |
| 38 | |
| 39 | memcpy(table, data->hob_payload, data->table_size_in_bytes); |
| 40 | |
| 41 | current += data->table_size_in_bytes; |
| 42 | acpi_add_table(rsdp, table); |
| 43 | current = acpi_align_current(current); |
| 44 | |
| 45 | return current; |
| 46 | } |