machine_kexec.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * machine_kexec.c - handle transition of Linux booting another kernel
  3. */
  4. #include <linux/mm.h>
  5. #include <linux/kexec.h>
  6. #include <linux/delay.h>
  7. #include <linux/reboot.h>
  8. #include <asm/pgtable.h>
  9. #include <asm/pgalloc.h>
  10. #include <asm/mmu_context.h>
  11. #include <asm/io.h>
  12. #include <asm/cacheflush.h>
  13. #include <asm/mach-types.h>
  14. const extern unsigned char relocate_new_kernel[];
  15. const extern unsigned int relocate_new_kernel_size;
  16. extern void setup_mm_for_reboot(char mode);
  17. extern unsigned long kexec_start_address;
  18. extern unsigned long kexec_indirection_page;
  19. extern unsigned long kexec_mach_type;
  20. /*
  21. * Provide a dummy crash_notes definition while crash dump arrives to arm.
  22. * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
  23. */
  24. int machine_kexec_prepare(struct kimage *image)
  25. {
  26. return 0;
  27. }
  28. void machine_kexec_cleanup(struct kimage *image)
  29. {
  30. }
  31. void machine_shutdown(void)
  32. {
  33. }
  34. void machine_crash_shutdown(struct pt_regs *regs)
  35. {
  36. }
  37. void machine_kexec(struct kimage *image)
  38. {
  39. unsigned long page_list;
  40. unsigned long reboot_code_buffer_phys;
  41. void *reboot_code_buffer;
  42. page_list = image->head & PAGE_MASK;
  43. /* we need both effective and real address here */
  44. reboot_code_buffer_phys =
  45. page_to_pfn(image->control_code_page) << PAGE_SHIFT;
  46. reboot_code_buffer = page_address(image->control_code_page);
  47. /* Prepare parameters for reboot_code_buffer*/
  48. kexec_start_address = image->start;
  49. kexec_indirection_page = page_list;
  50. kexec_mach_type = machine_arch_type;
  51. /* copy our kernel relocation code to the control code page */
  52. memcpy(reboot_code_buffer,
  53. relocate_new_kernel, relocate_new_kernel_size);
  54. flush_icache_range((unsigned long) reboot_code_buffer,
  55. (unsigned long) reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE);
  56. printk(KERN_INFO "Bye!\n");
  57. cpu_proc_fin();
  58. setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
  59. cpu_reset(reboot_code_buffer_phys);
  60. }