blob: f15b2e2855a9cbd6b3b8c53033230090038d7c3e [file] [log] [blame]
Bin Mengf17cea62015-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#include <common.h>
Simon Glass07e922a2015-04-28 20:25:10 -06008#include <asm/sfi.h>
Bin Mengc4f407e2015-06-23 12:18:52 +08009#include <asm/mpspec.h>
Bin Mengf17cea62015-04-24 18:10:04 +080010#include <asm/tables.h>
Saket Sinha331141a2015-08-22 12:20:55 +053011#include <asm/acpi_table.h>
Bin Mengf17cea62015-04-24 18:10:04 +080012
13u8 table_compute_checksum(void *v, int len)
14{
15 u8 *bytes = v;
16 u8 checksum = 0;
17 int i;
18
19 for (i = 0; i < len; i++)
20 checksum -= bytes[i];
21
22 return checksum;
23}
24
Bin Mengf91cf6b2015-06-23 12:18:51 +080025void table_fill_string(char *dest, const char *src, size_t n, char pad)
26{
27 int start, len;
28 int i;
29
30 strncpy(dest, src, n);
31
32 /* Fill the remaining bytes with pad */
33 len = strlen(src);
34 start = len < n ? len : n;
35 for (i = start; i < n; i++)
36 dest[i] = pad;
37}
38
Bin Mengf17cea62015-04-24 18:10:04 +080039void write_tables(void)
40{
41 u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR;
42
Bin Meng7b730902015-04-28 18:37:03 +080043#ifdef CONFIG_GENERATE_PIRQ_TABLE
Bin Mengf17cea62015-04-24 18:10:04 +080044 rom_table_end = write_pirq_routing_table(rom_table_end);
45 rom_table_end = ALIGN(rom_table_end, 1024);
46#endif
Simon Glass07e922a2015-04-28 20:25:10 -060047#ifdef CONFIG_GENERATE_SFI_TABLE
48 rom_table_end = write_sfi_table(rom_table_end);
49 rom_table_end = ALIGN(rom_table_end, 1024);
50#endif
Bin Mengc4f407e2015-06-23 12:18:52 +080051#ifdef CONFIG_GENERATE_MP_TABLE
52 rom_table_end = write_mp_table(rom_table_end);
53 rom_table_end = ALIGN(rom_table_end, 1024);
54#endif
Saket Sinha331141a2015-08-22 12:20:55 +053055#ifdef CONFIG_GENERATE_ACPI_TABLE
56 rom_table_end = write_acpi_tables(rom_table_end);
57 rom_table_end = ALIGN(rom_table_end, 1024);
58#endif
Bin Mengf17cea62015-04-24 18:10:04 +080059}