blob: 75ffbc1b220456bd6fbc6f2a266a94129963a01b [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#include <common.h>
Simon Glass6388e352015-04-28 20:25:10 -06008#include <asm/sfi.h>
Bin Meng07545d82015-06-23 12:18:52 +08009#include <asm/mpspec.h>
Bin Meng5e2400e2015-04-24 18:10:04 +080010#include <asm/tables.h>
11
12u8 table_compute_checksum(void *v, int len)
13{
14 u8 *bytes = v;
15 u8 checksum = 0;
16 int i;
17
18 for (i = 0; i < len; i++)
19 checksum -= bytes[i];
20
21 return checksum;
22}
23
Bin Meng7f5df8d2015-06-23 12:18:51 +080024void table_fill_string(char *dest, const char *src, size_t n, char pad)
25{
26 int start, len;
27 int i;
28
29 strncpy(dest, src, n);
30
31 /* Fill the remaining bytes with pad */
32 len = strlen(src);
33 start = len < n ? len : n;
34 for (i = start; i < n; i++)
35 dest[i] = pad;
36}
37
Bin Meng5e2400e2015-04-24 18:10:04 +080038void write_tables(void)
39{
40 u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR;
41
Bin Mengcc4c8ac2015-04-28 18:37:03 +080042#ifdef CONFIG_GENERATE_PIRQ_TABLE
Bin Meng5e2400e2015-04-24 18:10:04 +080043 rom_table_end = write_pirq_routing_table(rom_table_end);
44 rom_table_end = ALIGN(rom_table_end, 1024);
45#endif
Simon Glass6388e352015-04-28 20:25:10 -060046#ifdef CONFIG_GENERATE_SFI_TABLE
47 rom_table_end = write_sfi_table(rom_table_end);
48 rom_table_end = ALIGN(rom_table_end, 1024);
49#endif
Bin Meng07545d82015-06-23 12:18:52 +080050#ifdef CONFIG_GENERATE_MP_TABLE
51 rom_table_end = write_mp_table(rom_table_end);
52 rom_table_end = ALIGN(rom_table_end, 1024);
53#endif
Bin Meng5e2400e2015-04-24 18:10:04 +080054}