blob: 40f9c3e19220acff046e3aaa159a14ba2396fa43 [file] [log] [blame]
Zou Nan haia79561132006-12-07 09:51:35 -08001/*
2 * arch/ia64/kernel/machine_kexec.c
3 *
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>
8 *
9 * This source code is licensed under the GNU General Public License,
10 * Version 2. See the file COPYING for more details.
11 */
12
13#include <linux/mm.h>
14#include <linux/kexec.h>
15#include <linux/cpu.h>
16#include <linux/irq.h>
Hormsabac08db2007-02-05 10:16:20 +090017#include <linux/efi.h>
Ken'ichi Ohmichifd59d232007-10-16 23:27:27 -070018#include <linux/numa.h>
19#include <linux/mmzone.h>
Zou Nan haia79561132006-12-07 09:51:35 -080020#include <asm/mmu_context.h>
21#include <asm/setup.h>
22#include <asm/delay.h>
23#include <asm/meminit.h>
24
Horms53da5762006-12-12 18:06:13 +090025typedef NORET_TYPE void (*relocate_new_kernel_t)(
26 unsigned long indirection_page,
27 unsigned long start_address,
28 struct ia64_boot_param *boot_param,
29 unsigned long pal_addr) ATTRIB_NORET;
Zou Nan haia79561132006-12-07 09:51:35 -080030
31struct kimage *ia64_kimage;
32
33struct resource efi_memmap_res = {
34 .name = "EFI Memory Map",
35 .start = 0,
36 .end = 0,
37 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
38};
39
40struct resource boot_param_res = {
41 .name = "Boot parameter",
42 .start = 0,
43 .end = 0,
44 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
45};
46
47
48/*
49 * Do what every setup is needed on image and the
50 * reboot code buffer to allow us to avoid allocations
51 * later.
52 */
53int machine_kexec_prepare(struct kimage *image)
54{
55 void *control_code_buffer;
56 const unsigned long *func;
57
58 func = (unsigned long *)&relocate_new_kernel;
59 /* Pre-load control code buffer to minimize work in kexec path */
60 control_code_buffer = page_address(image->control_code_page);
61 memcpy((void *)control_code_buffer, (const void *)func[0],
62 relocate_new_kernel_size);
63 flush_icache_range((unsigned long)control_code_buffer,
64 (unsigned long)control_code_buffer + relocate_new_kernel_size);
65 ia64_kimage = image;
66
67 return 0;
68}
69
70void machine_kexec_cleanup(struct kimage *image)
71{
72}
73
Zou Nan haia79561132006-12-07 09:51:35 -080074/*
75 * Do not allocate memory (or fail in any way) in machine_kexec().
76 * We are past the point of no return, committed to rebooting now.
77 */
Zou Nan haia79561132006-12-07 09:51:35 -080078static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
79{
80 struct kimage *image = arg;
81 relocate_new_kernel_t rnk;
82 void *pal_addr = efi_get_pal_addr();
83 unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
Zou Nan haia79561132006-12-07 09:51:35 -080084 int ii;
85
Bernhard Wallec2c77fe2007-01-28 13:47:02 +010086 BUG_ON(!image);
Zou Nan haia79561132006-12-07 09:51:35 -080087 if (image->type == KEXEC_TYPE_CRASH) {
88 crash_save_this_cpu();
89 current->thread.ksp = (__u64)info->sw - 16;
90 }
91
92 /* Interrupts aren't acceptable while we reboot */
93 local_irq_disable();
94
95 /* Mask CMC and Performance Monitor interrupts */
96 ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
97 ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
98
99 /* Mask ITV and Local Redirect Registers */
100 ia64_set_itv(1 << 16);
101 ia64_set_lrr0(1 << 16);
102 ia64_set_lrr1(1 << 16);
103
104 /* terminate possible nested in-service interrupts */
105 for (ii = 0; ii < 16; ii++)
106 ia64_eoi();
107
108 /* unmask TPR and clear any pending interrupts */
109 ia64_setreg(_IA64_REG_CR_TPR, 0);
110 ia64_srlz_d();
Simon Hormana62c9fe2007-09-19 14:02:20 +0900111 while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
Zou Nan haia79561132006-12-07 09:51:35 -0800112 ia64_eoi();
Zou Nan haia79561132006-12-07 09:51:35 -0800113 platform_kernel_launch_event();
114 rnk = (relocate_new_kernel_t)&code_addr;
115 (*rnk)(image->head, image->start, ia64_boot_param,
116 GRANULEROUNDDOWN((unsigned long) pal_addr));
117 BUG();
118}
119
120void machine_kexec(struct kimage *image)
121{
Bernhard Wallec2c77fe2007-01-28 13:47:02 +0100122 BUG_ON(!image);
Zou Nan haia79561132006-12-07 09:51:35 -0800123 unw_init_running(ia64_machine_kexec, image);
124 for(;;);
125}
Ken'ichi Ohmichifd59d232007-10-16 23:27:27 -0700126
127void arch_crash_save_vmcoreinfo(void)
128{
129#ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
130 SYMBOL(pgdat_list);
131 LENGTH(pgdat_list, MAX_NUMNODES);
132
133 SYMBOL(node_memblk);
134 LENGTH(node_memblk, NR_NODE_MEMBLKS);
135 SIZE(node_memblk_s);
136 OFFSET(node_memblk_s, start_paddr);
137 OFFSET(node_memblk_s, size);
138#endif
139#ifdef CONFIG_PGTABLE_3
140 CONFIG(PGTABLE_3);
141#elif CONFIG_PGTABLE_4
142 CONFIG(PGTABLE_4);
143#endif
144}
145
146unsigned long paddr_vmcoreinfo_note(void)
147{
148 unsigned long vaddr, paddr;
149 vaddr = (unsigned long)(char *)&vmcoreinfo_note;
150 asm volatile ("tpa %0 = %1" : "=r"(paddr) : "r"(vaddr) : "memory");
151 return paddr;
152}
153