tables.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/tables.h>
  10. u8 table_compute_checksum(void *v, int len)
  11. {
  12. u8 *bytes = v;
  13. u8 checksum = 0;
  14. int i;
  15. for (i = 0; i < len; i++)
  16. checksum -= bytes[i];
  17. return checksum;
  18. }
  19. void table_fill_string(char *dest, const char *src, size_t n, char pad)
  20. {
  21. int start, len;
  22. int i;
  23. strncpy(dest, src, n);
  24. /* Fill the remaining bytes with pad */
  25. len = strlen(src);
  26. start = len < n ? len : n;
  27. for (i = start; i < n; i++)
  28. dest[i] = pad;
  29. }
  30. void write_tables(void)
  31. {
  32. u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR;
  33. #ifdef CONFIG_GENERATE_PIRQ_TABLE
  34. rom_table_end = write_pirq_routing_table(rom_table_end);
  35. rom_table_end = ALIGN(rom_table_end, 1024);
  36. #endif
  37. #ifdef CONFIG_GENERATE_SFI_TABLE
  38. rom_table_end = write_sfi_table(rom_table_end);
  39. rom_table_end = ALIGN(rom_table_end, 1024);
  40. #endif
  41. #ifdef CONFIG_GENERATE_MP_TABLE
  42. rom_table_end = write_mp_table(rom_table_end);
  43. rom_table_end = ALIGN(rom_table_end, 1024);
  44. #endif
  45. }