2 * machine_kexec.c - handle transition of Linux booting another kernel
6 #include <linux/kexec.h>
7 #include <linux/delay.h>
8 #include <linux/reboot.h>
10 #include <asm/pgtable.h>
11 #include <asm/pgalloc.h>
12 #include <asm/mmu_context.h>
13 #include <asm/cacheflush.h>
14 #include <asm/mach-types.h>
16 extern const unsigned char relocate_new_kernel
[];
17 extern const unsigned int relocate_new_kernel_size
;
19 extern void setup_mm_for_reboot(char mode
);
21 extern void v7_flush_kern_cache_all(void);
23 extern unsigned long kexec_start_address
;
24 extern unsigned long kexec_indirection_page
;
25 extern unsigned long kexec_mach_type
;
26 extern unsigned long kexec_boot_atags
;
28 static atomic_t waiting_for_crash_ipi
;
31 * Provide a dummy crash_notes definition while crash dump arrives to arm.
32 * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
35 int machine_kexec_prepare(struct kimage
*image
)
40 void machine_kexec_cleanup(struct kimage
*image
)
44 void machine_crash_nonpanic_core(void *unused
)
48 crash_setup_regs(®s
, NULL
);
49 printk(KERN_DEBUG
"CPU %u will stop doing anything useful since another CPU has crashed\n",
51 crash_save_cpu(®s
, smp_processor_id());
52 v7_flush_kern_cache_all();
54 atomic_dec(&waiting_for_crash_ipi
);
59 void machine_crash_shutdown(struct pt_regs
*regs
)
65 atomic_set(&waiting_for_crash_ipi
, num_online_cpus() - 1);
66 smp_call_function(machine_crash_nonpanic_core
, NULL
, false);
67 msecs
= 1000; /* Wait at most a second for the other cpus to stop */
68 while ((atomic_read(&waiting_for_crash_ipi
) > 0) && msecs
) {
72 if (atomic_read(&waiting_for_crash_ipi
) > 0)
73 printk(KERN_WARNING
"Non-crashing CPUs did not react to IPI\n");
75 crash_save_cpu(regs
, smp_processor_id());
77 printk(KERN_INFO
"Loading crashdump kernel...\n");
81 * Function pointer to optional machine-specific reinitialization
83 void (*kexec_reinit
)(void);
85 void machine_kexec(struct kimage
*image
)
87 unsigned long page_list
;
88 unsigned long reboot_code_buffer_phys
;
89 void *reboot_code_buffer
;
91 page_list
= image
->head
& PAGE_MASK
;
93 /* we need both effective and real address here */
94 reboot_code_buffer_phys
=
95 page_to_pfn(image
->control_code_page
) << PAGE_SHIFT
;
96 reboot_code_buffer
= page_address(image
->control_code_page
);
98 /* Prepare parameters for reboot_code_buffer*/
99 kexec_start_address
= image
->start
;
100 kexec_indirection_page
= page_list
;
101 kexec_mach_type
= machine_arch_type
;
102 kexec_boot_atags
= image
->start
- KEXEC_ARM_ZIMAGE_OFFSET
+ KEXEC_ARM_ATAGS_OFFSET
;
104 /* copy our kernel relocation code to the control code page */
105 memcpy(reboot_code_buffer
,
106 relocate_new_kernel
, relocate_new_kernel_size
);
109 flush_icache_range((unsigned long) reboot_code_buffer
,
110 (unsigned long) reboot_code_buffer
+ KEXEC_CONTROL_PAGE_SIZE
);
111 printk(KERN_INFO
"Bye!\n");
117 setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
118 v7_flush_kern_cache_all();
119 #ifdef CONFIG_OUTER_CACHE
124 #ifdef CONFIG_OUTER_CACHE
127 //v7_flush_kern_cache_all();
128 cpu_reset(reboot_code_buffer_phys
);