Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-x86
[deliverable/linux.git] / arch / ia64 / kernel / machine_kexec.c
CommitLineData
a7956113
ZN
1/*
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>
abac08db 17#include <linux/efi.h>
fd59d231
KO
18#include <linux/numa.h>
19#include <linux/mmzone.h>
a7956113
ZN
20#include <asm/mmu_context.h>
21#include <asm/setup.h>
22#include <asm/delay.h>
23#include <asm/meminit.h>
00cab92f 24#include <asm/processor.h>
a7956113 25
53da5763
H
26typedef NORET_TYPE void (*relocate_new_kernel_t)(
27 unsigned long indirection_page,
28 unsigned long start_address,
29 struct ia64_boot_param *boot_param,
30 unsigned long pal_addr) ATTRIB_NORET;
a7956113
ZN
31
32struct kimage *ia64_kimage;
33
34struct resource efi_memmap_res = {
35 .name = "EFI Memory Map",
36 .start = 0,
37 .end = 0,
38 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
39};
40
41struct resource boot_param_res = {
42 .name = "Boot parameter",
43 .start = 0,
44 .end = 0,
45 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
46};
47
48
49/*
50 * Do what every setup is needed on image and the
51 * reboot code buffer to allow us to avoid allocations
52 * later.
53 */
54int machine_kexec_prepare(struct kimage *image)
55{
56 void *control_code_buffer;
57 const unsigned long *func;
58
59 func = (unsigned long *)&relocate_new_kernel;
60 /* Pre-load control code buffer to minimize work in kexec path */
61 control_code_buffer = page_address(image->control_code_page);
62 memcpy((void *)control_code_buffer, (const void *)func[0],
63 relocate_new_kernel_size);
64 flush_icache_range((unsigned long)control_code_buffer,
65 (unsigned long)control_code_buffer + relocate_new_kernel_size);
66 ia64_kimage = image;
67
68 return 0;
69}
70
71void machine_kexec_cleanup(struct kimage *image)
72{
73}
74
a7956113
ZN
75/*
76 * Do not allocate memory (or fail in any way) in machine_kexec().
77 * We are past the point of no return, committed to rebooting now.
78 */
a7956113
ZN
79static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
80{
81 struct kimage *image = arg;
82 relocate_new_kernel_t rnk;
83 void *pal_addr = efi_get_pal_addr();
84 unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
a7956113
ZN
85 int ii;
86
c2c77fe8 87 BUG_ON(!image);
a7956113
ZN
88 if (image->type == KEXEC_TYPE_CRASH) {
89 crash_save_this_cpu();
90 current->thread.ksp = (__u64)info->sw - 16;
91 }
92
93 /* Interrupts aren't acceptable while we reboot */
94 local_irq_disable();
95
96 /* Mask CMC and Performance Monitor interrupts */
97 ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
98 ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
99
100 /* Mask ITV and Local Redirect Registers */
101 ia64_set_itv(1 << 16);
102 ia64_set_lrr0(1 << 16);
103 ia64_set_lrr1(1 << 16);
104
105 /* terminate possible nested in-service interrupts */
106 for (ii = 0; ii < 16; ii++)
107 ia64_eoi();
108
109 /* unmask TPR and clear any pending interrupts */
110 ia64_setreg(_IA64_REG_CR_TPR, 0);
111 ia64_srlz_d();
a62c9fe4 112 while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
a7956113 113 ia64_eoi();
a7956113
ZN
114 platform_kernel_launch_event();
115 rnk = (relocate_new_kernel_t)&code_addr;
116 (*rnk)(image->head, image->start, ia64_boot_param,
117 GRANULEROUNDDOWN((unsigned long) pal_addr));
118 BUG();
119}
120
121void machine_kexec(struct kimage *image)
122{
c2c77fe8 123 BUG_ON(!image);
a7956113
ZN
124 unw_init_running(ia64_machine_kexec, image);
125 for(;;);
126}
fd59d231
KO
127
128void arch_crash_save_vmcoreinfo(void)
129{
130#ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
bcbba6c1
KO
131 VMCOREINFO_SYMBOL(pgdat_list);
132 VMCOREINFO_LENGTH(pgdat_list, MAX_NUMNODES);
133
134 VMCOREINFO_SYMBOL(node_memblk);
135 VMCOREINFO_LENGTH(node_memblk, NR_NODE_MEMBLKS);
136 VMCOREINFO_SIZE(node_memblk_s);
137 VMCOREINFO_OFFSET(node_memblk_s, start_paddr);
138 VMCOREINFO_OFFSET(node_memblk_s, size);
fd59d231
KO
139#endif
140#ifdef CONFIG_PGTABLE_3
bcbba6c1 141 VMCOREINFO_CONFIG(PGTABLE_3);
fd59d231 142#elif CONFIG_PGTABLE_4
bcbba6c1 143 VMCOREINFO_CONFIG(PGTABLE_4);
fd59d231
KO
144#endif
145}
146
147unsigned long paddr_vmcoreinfo_note(void)
148{
00cab92f 149 return ia64_tpa((unsigned long)(char *)&vmcoreinfo_note);
fd59d231
KO
150}
151
This page took 0.11989 seconds and 5 git commands to generate.