machine_kexec.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }
  38. void machine_kexec(struct kimage *image)
  39. {
  40. unsigned long page_list;
  41. unsigned long reboot_code_buffer_phys;
  42. void *reboot_code_buffer;
  43. page_list = image->head & PAGE_MASK;
  44. /* we need both effective and real address here */
  45. reboot_code_buffer_phys =
  46. page_to_pfn(image->control_code_page) << PAGE_SHIFT;
  47. reboot_code_buffer = page_address(image->control_code_page);
  48. /* Prepare parameters for reboot_code_buffer*/
  49. kexec_start_address = image->start;
  50. kexec_indirection_page = page_list;
  51. kexec_mach_type = machine_arch_type;
  52. kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
  53. /* copy our kernel relocation code to the control code page */
  54. memcpy(reboot_code_buffer,
  55. relocate_new_kernel, relocate_new_kernel_size);
  56. flush_icache_range((unsigned long) reboot_code_buffer,
  57. (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
  58. printk(KERN_INFO "Bye!\n");
  59. cpu_proc_fin();
  60. setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
  61. cpu_reset(reboot_code_buffer_phys);
  62. }