blob: 9e8208ba2b7f2620b6270e53f56fb7386cce3b39 [file] [log] [blame]
Bin Meng5e2400e2015-04-24 18:10:04 +08001/*
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 Graf2b445e42016-08-19 01:23:22 +020010#include <tables_csum.h>
11
Bin Meng5e2400e2015-04-24 18:10:04 +080012/*
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
Bin Menge76bf382017-04-21 07:24:36 -070018#define ROM_TABLE_END 0xfffff
Bin Meng5e2400e2015-04-24 18:10:04 +080019
Bin Meng897e1dc2016-02-27 22:57:59 -080020#define ROM_TABLE_ALIGN 1024
21
Bin Meng3cf23712016-02-28 23:54:50 -080022/* SeaBIOS expects coreboot tables at address range 0x0000-0x1000 */
23#define CB_TABLE_ADDR 0x800
24
Bin Meng5e2400e2015-04-24 18:10:04 +080025/**
26 * table_compute_checksum() - Compute a table checksum
27 *
28 * This computes an 8-bit checksum for the configuration table.
29 * All bytes in the configuration table, including checksum itself and
30 * reserved bytes must add up to zero.
31 *
32 * @v: configuration table base address
33 * @len: configuration table size
34 * @return: the 8-bit checksum
35 */
36u8 table_compute_checksum(void *v, int len);
37
38/**
Bin Meng7f5df8d2015-06-23 12:18:51 +080039 * table_fill_string() - Fill a string with pad in the configuration table
40 *
41 * This fills a string in the configuration table. It copies number of bytes
42 * from the source string, and if source string length is shorter than the
43 * required size to copy, pad the table string with the given pad character.
44 *
45 * @dest: where to fill a string
46 * @src: where to copy from
47 * @n: number of bytes to copy
48 * @pad: character to pad the remaining bytes
49 */
50void table_fill_string(char *dest, const char *src, size_t n, char pad);
51
52/**
Bin Meng5e2400e2015-04-24 18:10:04 +080053 * write_tables() - Write x86 configuration tables
54 *
55 * This writes x86 configuration tables, including PIRQ routing table,
56 * Multi-Processor table and ACPI table. Whether a specific type of
57 * configuration table is written is controlled by a Kconfig option.
58 */
59void write_tables(void);
60
61/**
62 * write_pirq_routing_table() - Write PIRQ routing table
63 *
64 * This writes PIRQ routing table at a given address.
65 *
66 * @start: start address to write PIRQ routing table
67 * @return: end address of PIRQ routing table
68 */
Simon Glass42fd8c12017-01-16 07:03:35 -070069ulong write_pirq_routing_table(ulong start);
Bin Meng5e2400e2015-04-24 18:10:04 +080070
71#endif /* _X86_TABLES_H_ */