ia64/xen-unstable

view xen/arch/ia64/xen/machine_kexec.c @ 16785:af3550f53874

[IA64] domheap: Don't pin xenheap down. Now it's unnecessary.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents 3f6e855d218b
children 0b20ac6ec64a c88394b7c05a
line source
1 /******************************************************************************
2 * machine_kexec.c
3 *
4 * Based on arch/ia64/kernel/machine_kexec.c from Linux 2.6.20-rc1
5 *
6 * Xen port written by:
7 * - Simon 'Horms' Horman <horms@verge.net.au>
8 * - Magnus Damm <magnus@valinux.co.jp>
9 */
11 #include <asm/smp.h>
12 #include <xen/lib.h>
13 #include <xen/types.h>
14 #include <xen/smp.h>
15 #include <xen/acpi.h>
16 #include <public/kexec.h>
17 #include <linux/efi.h>
18 #include <asm/delay.h>
19 #include <asm/meminit.h>
20 #include <asm/hw_irq.h>
21 #include <asm/kexec.h>
22 #include <asm/vhpt.h>
23 #include <linux/cpu.h>
24 #include <linux/cpu.h>
25 #include <linux/notifier.h>
26 #include <asm/dom_fw_dom0.h>
28 typedef asmlinkage NORET_TYPE void (*relocate_new_kernel_t)(
29 unsigned long indirection_page,
30 unsigned long start_address,
31 struct ia64_boot_param *boot_param,
32 unsigned long pal_addr,
33 unsigned long cpu_data_pa,
34 unsigned long kernel_start,
35 unsigned long page_offset,
36 unsigned long vhpt)
37 ATTRIB_NORET;
39 #define kexec_flush_icache_page(page) \
40 do { \
41 unsigned long page_addr = (unsigned long)page_address(page); \
42 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
43 } while(0)
45 int machine_kexec_load(int type, int slot, xen_kexec_image_t *image)
46 {
47 return 0;
48 }
50 void machine_kexec_unload(int type, int slot, xen_kexec_image_t *image)
51 {
52 }
54 static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
55 {
56 xen_kexec_image_t *image = arg;
57 relocate_new_kernel_t rnk;
58 unsigned long code_addr = (unsigned long)
59 __va(image->reboot_code_buffer);
60 unsigned long cpu_data_pa = (unsigned long)
61 __pa(cpu_data(smp_processor_id()));
62 unsigned long vhpt;
63 int ii;
65 /* Interrupts aren't acceptable while we reboot */
66 local_irq_disable();
68 /* Mask CMC and Performance Monitor interrupts */
69 ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
70 ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
72 /* Mask ITV and Local Redirect Registers */
73 ia64_set_itv(1 << 16);
74 ia64_set_lrr0(1 << 16);
75 ia64_set_lrr1(1 << 16);
77 /* terminate possible nested in-service interrupts */
78 for (ii = 0; ii < 16; ii++)
79 ia64_eoi();
81 /* unmask TPR and clear any pending interrupts */
82 ia64_setreg(_IA64_REG_CR_TPR, 0);
83 ia64_srlz_d();
84 while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
85 ia64_eoi();
86 platform_kernel_launch_event();
87 vhpt = __va_ul(vcpu_vhpt_maddr(current));
88 BUG_ON(!vhpt);
89 rnk = (relocate_new_kernel_t)&code_addr;
90 (*rnk)(image->indirection_page, image->start_address, ia64_boot_param,
91 GRANULEROUNDDOWN((unsigned long) pal_vaddr), cpu_data_pa,
92 KERNEL_START, PAGE_OFFSET, vhpt);
93 BUG();
94 }
96 #if CONFIG_SMP
97 /* Need to implement some subset of hotplug-cpu - enough to
98 * send a cpu into rendevouz */
100 /* N.B: The tasks frozen parameter can probably be dropped
101 * This can probably be rolled into cpu_down
102 */
103 static int _cpu_down(unsigned int cpu, int tasks_frozen)
104 {
105 if (num_online_cpus() == 1)
106 return -EBUSY;
108 if (!cpu_online(cpu))
109 return -EINVAL;
111 #ifndef XEN
112 /* XXX: What, if anything, should Xen do here? */
113 /* Ensure that we are not runnable on dying cpu */
114 old_affinity = current->cpus_allowed;
115 tmp = CPU_MASK_ALL;
116 cpu_clear(cpu, tmp);
117 set_cpus_allowed(current, tmp);
118 #endif
120 cpu_clear(cpu, cpu_online_map);
122 __cpu_die(cpu);
124 return 0;
125 }
127 static int cpu_down(unsigned int cpu)
128 {
129 int err;
131 /* Unlike Linux there is no lock, as there are no other callers
132 * and no other CPUS. */
133 err = _cpu_down(cpu, 0);
135 return 0;
136 }
137 #endif /* SMP */
139 /* This should probably be an arch-hook called from kexec_exec()
140 * Its also likely that it should be in the xen equivalent of
141 * arch/ia64/kernel/process.c */
142 static void machine_shutdown(void)
143 {
144 #ifdef CONFIG_SMP
145 unsigned int cpu;
147 for_each_online_cpu(cpu) {
148 if (cpu != smp_processor_id())
149 cpu_down(cpu);
150 }
151 #endif
152 kexec_disable_iosapic();
153 acpi_restore_tables();
154 }
156 void machine_kexec(xen_kexec_image_t *image)
157 {
158 machine_shutdown();
159 unw_init_running(ia64_machine_kexec, image);
160 for(;;);
161 }
163 void machine_reboot_kexec(xen_kexec_image_t *image)
164 {
165 machine_kexec(image);
166 }
168 /*
169 * Local variables:
170 * mode: C
171 * c-set-style: "BSD"
172 * c-basic-offset: 4
173 * tab-width: 4
174 * indent-tabs-mode: nil
175 * End:
176 */