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 | c4f407e | 2015-06-23 12:18:52 +0800 | [diff] [blame] | 9 | #include <asm/mpspec.h> |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 10 | #include <asm/tables.h> |
Saket Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 11 | #include <asm/acpi_table.h> |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 12 | |
| 13 | u8 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 Meng | f91cf6b | 2015-06-23 12:18:51 +0800 | [diff] [blame] | 25 | void 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 Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 39 | void write_tables(void) |
| 40 | { |
| 41 | u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR; |
| 42 | |
Bin Meng | 7b73090 | 2015-04-28 18:37:03 +0800 | [diff] [blame] | 43 | #ifdef CONFIG_GENERATE_PIRQ_TABLE |
Bin Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 44 | rom_table_end = write_pirq_routing_table(rom_table_end); |
| 45 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 46 | #endif |
Simon Glass | 07e922a | 2015-04-28 20:25:10 -0600 | [diff] [blame] | 47 | #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 Meng | c4f407e | 2015-06-23 12:18:52 +0800 | [diff] [blame] | 51 | #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 Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 55 | #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 Meng | f17cea6 | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 59 | } |