tables.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/sfi.h>
  8. #include <asm/mpspec.h>
  9. #include <asm/smbios.h>
  10. #include <asm/tables.h>
  11. #include <asm/acpi_table.h>
  12. u8 table_compute_checksum(void *v, int len)
  13. {
  14. u8 *bytes = v;
  15. u8 checksum = 0;
  16. int i;
  17. for (i = 0; i < len; i++)
  18. checksum -= bytes[i];
  19. return checksum;
  20. }
  21. void table_fill_string(char *dest, const char *src, size_t n, char pad)
  22. {
  23. int start, len;
  24. int i;
  25. strncpy(dest, src, n);
  26. /* Fill the remaining bytes with pad */
  27. len = strlen(src);
  28. start = len < n ? len : n;
  29. for (i = start; i < n; i++)
  30. dest[i] = pad;
  31. }
  32. void write_tables(void)
  33. {
  34. u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR;
  35. #ifdef CONFIG_GENERATE_PIRQ_TABLE
  36. rom_table_end = write_pirq_routing_table(rom_table_end);
  37. rom_table_end = ALIGN(rom_table_end, 1024);
  38. #endif
  39. #ifdef CONFIG_GENERATE_SFI_TABLE
  40. rom_table_end = write_sfi_table(rom_table_end);
  41. rom_table_end = ALIGN(rom_table_end, 1024);
  42. #endif
  43. #ifdef CONFIG_GENERATE_MP_TABLE
  44. rom_table_end = write_mp_table(rom_table_end);
  45. rom_table_end = ALIGN(rom_table_end, 1024);
  46. #endif
  47. #ifdef CONFIG_GENERATE_ACPI_TABLE
  48. rom_table_end = write_acpi_tables(rom_table_end);
  49. rom_table_end = ALIGN(rom_table_end, 1024);
  50. #endif
  51. #ifdef CONFIG_GENERATE_SMBIOS_TABLE
  52. rom_table_end = write_smbios_table(rom_table_end);
  53. rom_table_end = ALIGN(rom_table_end, 1024);
  54. #endif
  55. }