machine_kexec.c 2.1 KB

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