2 * arch/ia64/kernel/machine_kexec.c
4 * Handle transition of Linux booting another kernel
5 * Copyright (C) 2005 Hewlett-Packard Development Comapny, L.P.
6 * Copyright (C) 2005 Khalid Aziz <khalid.aziz@hp.com>
7 * Copyright (C) 2006 Intel Corp, Zou Nan hai <nanhai.zou@intel.com>
9 * This source code is licensed under the GNU General Public License,
10 * Version 2. See the file COPYING for more details.
14 #include <linux/kexec.h>
15 #include <linux/cpu.h>
16 #include <linux/irq.h>
17 #include <asm/mmu_context.h>
18 #include <asm/setup.h>
19 #include <asm/delay.h>
20 #include <asm/meminit.h>
22 typedef void (*relocate_new_kernel_t)(unsigned long, unsigned long,
23 struct ia64_boot_param *, unsigned long);
25 struct kimage *ia64_kimage;
27 struct resource efi_memmap_res = {
28 .name = "EFI Memory Map",
31 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
34 struct resource boot_param_res = {
35 .name = "Boot parameter",
38 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
43 * Do what every setup is needed on image and the
44 * reboot code buffer to allow us to avoid allocations
47 int machine_kexec_prepare(struct kimage *image)
49 void *control_code_buffer;
50 const unsigned long *func;
52 func = (unsigned long *)&relocate_new_kernel;
53 /* Pre-load control code buffer to minimize work in kexec path */
54 control_code_buffer = page_address(image->control_code_page);
55 memcpy((void *)control_code_buffer, (const void *)func[0],
56 relocate_new_kernel_size);
57 flush_icache_range((unsigned long)control_code_buffer,
58 (unsigned long)control_code_buffer + relocate_new_kernel_size);
64 void machine_kexec_cleanup(struct kimage *image)
68 void machine_shutdown(void)
72 for_each_online_cpu(cpu) {
73 if (cpu != smp_processor_id())
76 kexec_disable_iosapic();
80 * Do not allocate memory (or fail in any way) in machine_kexec().
81 * We are past the point of no return, committed to rebooting now.
83 extern void *efi_get_pal_addr(void);
84 static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
86 struct kimage *image = arg;
87 relocate_new_kernel_t rnk;
88 void *pal_addr = efi_get_pal_addr();
89 unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
93 if (image->type == KEXEC_TYPE_CRASH) {
94 crash_save_this_cpu();
95 current->thread.ksp = (__u64)info->sw - 16;
98 /* Interrupts aren't acceptable while we reboot */
101 /* Mask CMC and Performance Monitor interrupts */
102 ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
103 ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
105 /* Mask ITV and Local Redirect Registers */
106 ia64_set_itv(1 << 16);
107 ia64_set_lrr0(1 << 16);
108 ia64_set_lrr1(1 << 16);
110 /* terminate possible nested in-service interrupts */
111 for (ii = 0; ii < 16; ii++)
114 /* unmask TPR and clear any pending interrupts */
115 ia64_setreg(_IA64_REG_CR_TPR, 0);
117 vector = ia64_get_ivr();
118 while (vector != IA64_SPURIOUS_INT_VECTOR) {
120 vector = ia64_get_ivr();
122 platform_kernel_launch_event();
123 rnk = (relocate_new_kernel_t)&code_addr;
124 (*rnk)(image->head, image->start, ia64_boot_param,
125 GRANULEROUNDDOWN((unsigned long) pal_addr));
129 void machine_kexec(struct kimage *image)
131 unw_init_running(ia64_machine_kexec, image);