Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 1 | /* |
| 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 Glass | 07e922a | 2015-04-28 20:25:10 -0600 | [diff] [blame] | 8 | #include <asm/sfi.h> |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 9 | #include <asm/tables.h> |
| 10 | |
| 11 | u8 table_compute_checksum(void *v, int len) |
| 12 | { |
| 13 | u8 *bytes = v; |
| 14 | u8 checksum = 0; |
| 15 | int i; |
| 16 | |
| 17 | for (i = 0; i < len; i++) |
| 18 | checksum -= bytes[i]; |
| 19 | |
| 20 | return checksum; |
| 21 | } |
| 22 | |
Bin Meng | f91cf6b | 2015-06-23 12:18:51 +0800 | [diff] [blame^] | 23 | void table_fill_string(char *dest, const char *src, size_t n, char pad) |
| 24 | { |
| 25 | int start, len; |
| 26 | int i; |
| 27 | |
| 28 | strncpy(dest, src, n); |
| 29 | |
| 30 | /* Fill the remaining bytes with pad */ |
| 31 | len = strlen(src); |
| 32 | start = len < n ? len : n; |
| 33 | for (i = start; i < n; i++) |
| 34 | dest[i] = pad; |
| 35 | } |
| 36 | |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 37 | void write_tables(void) |
| 38 | { |
| 39 | u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR; |
| 40 | |
Bin Meng | 7b73090 | 2015-04-28 18:37:03 +0800 | [diff] [blame] | 41 | #ifdef CONFIG_GENERATE_PIRQ_TABLE |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 42 | rom_table_end = write_pirq_routing_table(rom_table_end); |
| 43 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 44 | #endif |
Simon Glass | 07e922a | 2015-04-28 20:25:10 -0600 | [diff] [blame] | 45 | #ifdef CONFIG_GENERATE_SFI_TABLE |
| 46 | rom_table_end = write_sfi_table(rom_table_end); |
| 47 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 48 | #endif |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 49 | } |