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