]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/x86/lib/tables.c
19b026093553e6d802cbe7c153859ec47abd9b3b
[people/ms/u-boot.git] / arch / x86 / lib / tables.c
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>
8 #include <asm/sfi.h>
9 #include <asm/mpspec.h>
10 #include <asm/smbios.h>
11 #include <asm/tables.h>
12 #include <asm/acpi_table.h>
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
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
40 void write_tables(void)
41 {
42 u32 __maybe_unused rom_table_start = ROM_TABLE_ADDR;
43 u32 __maybe_unused rom_table_end;
44
45 #ifdef CONFIG_GENERATE_PIRQ_TABLE
46 rom_table_end = write_pirq_routing_table(rom_table_start);
47 rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
48 rom_table_start = rom_table_end;
49 #endif
50 #ifdef CONFIG_GENERATE_SFI_TABLE
51 rom_table_end = write_sfi_table(rom_table_start);
52 rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
53 rom_table_start = rom_table_end;
54 #endif
55 #ifdef CONFIG_GENERATE_MP_TABLE
56 rom_table_end = write_mp_table(rom_table_start);
57 rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
58 rom_table_start = rom_table_end;
59 #endif
60 #ifdef CONFIG_GENERATE_ACPI_TABLE
61 rom_table_end = write_acpi_tables(rom_table_start);
62 rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
63 rom_table_start = rom_table_end;
64 #endif
65 #ifdef CONFIG_GENERATE_SMBIOS_TABLE
66 rom_table_end = write_smbios_table(rom_table_start);
67 rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
68 rom_table_start = rom_table_end;
69 #endif
70 }