2 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/mpspec.h>
10 #include <asm/smbios.h>
11 #include <asm/tables.h>
12 #include <asm/acpi_table.h>
15 * Function prototype to write a specific configuration table
17 * @addr: start address to write the table
18 * @return: end address of the table
20 typedef u32 (*table_write
)(u32 addr
);
22 static table_write table_write_funcs
[] = {
23 #ifdef CONFIG_GENERATE_PIRQ_TABLE
24 write_pirq_routing_table
,
26 #ifdef CONFIG_GENERATE_SFI_TABLE
29 #ifdef CONFIG_GENERATE_MP_TABLE
32 #ifdef CONFIG_GENERATE_ACPI_TABLE
35 #ifdef CONFIG_GENERATE_SMBIOS_TABLE
40 u8
table_compute_checksum(void *v
, int len
)
46 for (i
= 0; i
< len
; i
++)
52 void table_fill_string(char *dest
, const char *src
, size_t n
, char pad
)
57 strncpy(dest
, src
, n
);
59 /* Fill the remaining bytes with pad */
61 start
= len
< n
? len
: n
;
62 for (i
= start
; i
< n
; i
++)
66 void write_tables(void)
68 u32 rom_table_start
= ROM_TABLE_ADDR
;
72 for (i
= 0; i
< ARRAY_SIZE(table_write_funcs
); i
++) {
73 rom_table_end
= table_write_funcs
[i
](rom_table_start
);
74 rom_table_end
= ALIGN(rom_table_end
, ROM_TABLE_ALIGN
);
75 rom_table_start
= rom_table_end
;