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