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