spl.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2019 Fraunhofer AISEC,
  4. * Lukas Auer <lukas.auer@aisec.fraunhofer.de>
  5. */
  6. #include <common.h>
  7. #include <cpu_func.h>
  8. #include <hang.h>
  9. #include <init.h>
  10. #include <log.h>
  11. #include <spl.h>
  12. #include <asm/smp.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. __weak int spl_board_init_f(void)
  15. {
  16. return 0;
  17. }
  18. __weak void board_init_f(ulong dummy)
  19. {
  20. int ret;
  21. ret = spl_early_init();
  22. if (ret)
  23. panic("spl_early_init() failed: %d\n", ret);
  24. arch_cpu_init_dm();
  25. preloader_console_init();
  26. ret = spl_board_init_f();
  27. if (ret)
  28. panic("spl_board_init_f() failed: %d\n", ret);
  29. }
  30. void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
  31. {
  32. typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb);
  33. void *fdt_blob;
  34. int ret;
  35. #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
  36. fdt_blob = spl_image->fdt_addr;
  37. #else
  38. fdt_blob = (void *)gd->fdt_blob;
  39. #endif
  40. image_entry_riscv_t image_entry =
  41. (image_entry_riscv_t)spl_image->entry_point;
  42. invalidate_icache_all();
  43. debug("image entry point: 0x%lX\n", spl_image->entry_point);
  44. #ifdef CONFIG_SPL_SMP
  45. ret = smp_call_function(spl_image->entry_point, (ulong)fdt_blob, 0, 0);
  46. if (ret)
  47. hang();
  48. #endif
  49. image_entry(gd->arch.boot_hart, fdt_blob);
  50. }