spl.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/global_data.h>
  13. #include <asm/smp.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. __weak int spl_board_init_f(void)
  16. {
  17. return 0;
  18. }
  19. __weak void board_init_f(ulong dummy)
  20. {
  21. int ret;
  22. ret = spl_early_init();
  23. if (ret)
  24. panic("spl_early_init() failed: %d\n", ret);
  25. arch_cpu_init_dm();
  26. preloader_console_init();
  27. ret = spl_board_init_f();
  28. if (ret)
  29. panic("spl_board_init_f() failed: %d\n", ret);
  30. }
  31. void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
  32. {
  33. typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb);
  34. void *fdt_blob;
  35. __maybe_unused int ret;
  36. #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
  37. fdt_blob = spl_image->fdt_addr;
  38. #else
  39. fdt_blob = (void *)gd->fdt_blob;
  40. #endif
  41. image_entry_riscv_t image_entry =
  42. (image_entry_riscv_t)spl_image->entry_point;
  43. invalidate_icache_all();
  44. debug("image entry point: 0x%lX\n", spl_image->entry_point);
  45. #ifdef CONFIG_SPL_SMP
  46. ret = smp_call_function(spl_image->entry_point, (ulong)fdt_blob, 0, 0);
  47. if (ret)
  48. hang();
  49. #endif
  50. image_entry(gd->arch.boot_hart, fdt_blob);
  51. }