machine_kexec.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * machine_kexec.c - handle transition of Linux booting another kernel
  4. */
  5. #include <linux/compiler.h>
  6. #include <linux/kexec.h>
  7. #include <linux/mm.h>
  8. #include <linux/delay.h>
  9. #include <asm/cacheflush.h>
  10. #include <asm/page.h>
  11. #include <asm/setup.h>
  12. extern const unsigned char relocate_new_kernel[];
  13. extern const size_t relocate_new_kernel_size;
  14. int machine_kexec_prepare(struct kimage *kimage)
  15. {
  16. return 0;
  17. }
  18. void machine_kexec_cleanup(struct kimage *kimage)
  19. {
  20. }
  21. void machine_shutdown(void)
  22. {
  23. }
  24. void machine_crash_shutdown(struct pt_regs *regs)
  25. {
  26. }
  27. typedef void (*relocate_kernel_t)(unsigned long ptr,
  28. unsigned long start,
  29. unsigned long cpu_mmu_flags) __noreturn;
  30. void machine_kexec(struct kimage *image)
  31. {
  32. void *reboot_code_buffer;
  33. unsigned long cpu_mmu_flags;
  34. reboot_code_buffer = page_address(image->control_code_page);
  35. memcpy(reboot_code_buffer, relocate_new_kernel,
  36. relocate_new_kernel_size);
  37. /*
  38. * we do not want to be bothered.
  39. */
  40. local_irq_disable();
  41. pr_info("Will call new kernel at 0x%08lx. Bye...\n", image->start);
  42. __flush_cache_all();
  43. cpu_mmu_flags = m68k_cputype | m68k_mmutype << 8;
  44. ((relocate_kernel_t) reboot_code_buffer)(image->head & PAGE_MASK,
  45. image->start,
  46. cpu_mmu_flags);
  47. }