tables.c 951 B

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