spl.c 1.3 KB

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