Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _X86_TABLES_H_ |
| 7 | #define _X86_TABLES_H_ |
| 8 | |
Alexander Graf | 120b041 | 2016-08-19 01:23:22 +0200 | [diff] [blame] | 9 | #include <tables_csum.h> |
| 10 | |
Andy Shevchenko | a364e62 | 2017-07-28 20:02:15 +0300 | [diff] [blame] | 11 | #define ROM_TABLE_ADDR CONFIG_ROM_TABLE_ADDR |
| 12 | #define ROM_TABLE_END (CONFIG_ROM_TABLE_ADDR + CONFIG_ROM_TABLE_SIZE - 1) |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 13 | |
Bin Meng | 900e49a | 2016-02-27 22:57:59 -0800 | [diff] [blame] | 14 | #define ROM_TABLE_ALIGN 1024 |
| 15 | |
Bin Meng | 96030fa | 2016-02-28 23:54:50 -0800 | [diff] [blame] | 16 | /* SeaBIOS expects coreboot tables at address range 0x0000-0x1000 */ |
| 17 | #define CB_TABLE_ADDR 0x800 |
| 18 | |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 19 | /** |
| 20 | * table_compute_checksum() - Compute a table checksum |
| 21 | * |
| 22 | * This computes an 8-bit checksum for the configuration table. |
| 23 | * All bytes in the configuration table, including checksum itself and |
| 24 | * reserved bytes must add up to zero. |
| 25 | * |
| 26 | * @v: configuration table base address |
| 27 | * @len: configuration table size |
| 28 | * @return: the 8-bit checksum |
| 29 | */ |
| 30 | u8 table_compute_checksum(void *v, int len); |
| 31 | |
| 32 | /** |
Bin Meng | f91cf6b | 2015-06-23 12:18:51 +0800 | [diff] [blame] | 33 | * table_fill_string() - Fill a string with pad in the configuration table |
| 34 | * |
| 35 | * This fills a string in the configuration table. It copies number of bytes |
| 36 | * from the source string, and if source string length is shorter than the |
| 37 | * required size to copy, pad the table string with the given pad character. |
| 38 | * |
| 39 | * @dest: where to fill a string |
| 40 | * @src: where to copy from |
| 41 | * @n: number of bytes to copy |
| 42 | * @pad: character to pad the remaining bytes |
| 43 | */ |
| 44 | void table_fill_string(char *dest, const char *src, size_t n, char pad); |
| 45 | |
| 46 | /** |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 47 | * write_tables() - Write x86 configuration tables |
| 48 | * |
| 49 | * This writes x86 configuration tables, including PIRQ routing table, |
| 50 | * Multi-Processor table and ACPI table. Whether a specific type of |
| 51 | * configuration table is written is controlled by a Kconfig option. |
Simon Glass | e50129a | 2020-11-04 09:57:18 -0700 | [diff] [blame] | 52 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 53 | * Return: 0 if OK, -ENOSPC if table too large |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 54 | */ |
Simon Glass | e50129a | 2020-11-04 09:57:18 -0700 | [diff] [blame] | 55 | int write_tables(void); |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * write_pirq_routing_table() - Write PIRQ routing table |
| 59 | * |
| 60 | * This writes PIRQ routing table at a given address. |
| 61 | * |
| 62 | * @start: start address to write PIRQ routing table |
| 63 | * @return: end address of PIRQ routing table |
| 64 | */ |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 65 | ulong write_pirq_routing_table(ulong start); |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 66 | |
| 67 | #endif /* _X86_TABLES_H_ */ |