Bin Meng | 5e2400e | 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 | 6388e35 | 2015-04-28 20:25:10 -0600 | [diff] [blame] | 8 | #include <asm/sfi.h> |
Bin Meng | 07545d8 | 2015-06-23 12:18:52 +0800 | [diff] [blame] | 9 | #include <asm/mpspec.h> |
Bin Meng | 721e992 | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 10 | #include <asm/smbios.h> |
Bin Meng | 5e2400e | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 11 | #include <asm/tables.h> |
Saket Sinha | 867bcb6 | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 12 | #include <asm/acpi_table.h> |
Bin Meng | 5e2400e | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 13 | |
| 14 | u8 table_compute_checksum(void *v, int len) |
| 15 | { |
| 16 | u8 *bytes = v; |
| 17 | u8 checksum = 0; |
| 18 | int i; |
| 19 | |
| 20 | for (i = 0; i < len; i++) |
| 21 | checksum -= bytes[i]; |
| 22 | |
| 23 | return checksum; |
| 24 | } |
| 25 | |
Bin Meng | 7f5df8d | 2015-06-23 12:18:51 +0800 | [diff] [blame] | 26 | void table_fill_string(char *dest, const char *src, size_t n, char pad) |
| 27 | { |
| 28 | int start, len; |
| 29 | int i; |
| 30 | |
| 31 | strncpy(dest, src, n); |
| 32 | |
| 33 | /* Fill the remaining bytes with pad */ |
| 34 | len = strlen(src); |
| 35 | start = len < n ? len : n; |
| 36 | for (i = start; i < n; i++) |
| 37 | dest[i] = pad; |
| 38 | } |
| 39 | |
Bin Meng | 5e2400e | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 40 | void write_tables(void) |
| 41 | { |
| 42 | u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR; |
| 43 | |
Bin Meng | cc4c8ac | 2015-04-28 18:37:03 +0800 | [diff] [blame] | 44 | #ifdef CONFIG_GENERATE_PIRQ_TABLE |
Bin Meng | 5e2400e | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 45 | rom_table_end = write_pirq_routing_table(rom_table_end); |
| 46 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 47 | #endif |
Simon Glass | 6388e35 | 2015-04-28 20:25:10 -0600 | [diff] [blame] | 48 | #ifdef CONFIG_GENERATE_SFI_TABLE |
| 49 | rom_table_end = write_sfi_table(rom_table_end); |
| 50 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 51 | #endif |
Bin Meng | 07545d8 | 2015-06-23 12:18:52 +0800 | [diff] [blame] | 52 | #ifdef CONFIG_GENERATE_MP_TABLE |
| 53 | rom_table_end = write_mp_table(rom_table_end); |
| 54 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 55 | #endif |
Saket Sinha | 867bcb6 | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 56 | #ifdef CONFIG_GENERATE_ACPI_TABLE |
| 57 | rom_table_end = write_acpi_tables(rom_table_end); |
| 58 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 59 | #endif |
Bin Meng | 721e992 | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 60 | #ifdef CONFIG_GENERATE_SMBIOS_TABLE |
| 61 | rom_table_end = write_smbios_table(rom_table_end); |
| 62 | rom_table_end = ALIGN(rom_table_end, 1024); |
| 63 | #endif |
Bin Meng | 5e2400e | 2015-04-24 18:10:04 +0800 | [diff] [blame] | 64 | } |