]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/sh/kernel/machine_kexec.c
sh: rework kexec segment code
[linux-2.6-omap-h63xx.git] / arch / sh / kernel / machine_kexec.c
1 /*
2  * machine_kexec.c - handle transition of Linux booting another kernel
3  * Copyright (C) 2002-2003 Eric Biederman  <ebiederm@xmission.com>
4  *
5  * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
6  * LANDISK/sh4 supported by kogiidena
7  *
8  * This source code is licensed under the GNU General Public License,
9  * Version 2.  See the file COPYING for more details.
10  */
11
12 #include <linux/mm.h>
13 #include <linux/kexec.h>
14 #include <linux/delay.h>
15 #include <linux/reboot.h>
16 #include <linux/numa.h>
17 #include <asm/pgtable.h>
18 #include <asm/pgalloc.h>
19 #include <asm/mmu_context.h>
20 #include <asm/io.h>
21 #include <asm/cacheflush.h>
22
23 typedef NORET_TYPE void (*relocate_new_kernel_t)(
24                                 unsigned long indirection_page,
25                                 unsigned long reboot_code_buffer,
26                                 unsigned long start_address) ATTRIB_NORET;
27
28 extern const unsigned char relocate_new_kernel[];
29 extern const unsigned int relocate_new_kernel_size;
30 extern void *gdb_vbr_vector;
31
32 void machine_shutdown(void)
33 {
34 }
35
36 void machine_crash_shutdown(struct pt_regs *regs)
37 {
38 }
39
40 /*
41  * Do what every setup is needed on image and the
42  * reboot code buffer to allow us to avoid allocations
43  * later.
44  */
45 int machine_kexec_prepare(struct kimage *image)
46 {
47         return 0;
48 }
49
50 void machine_kexec_cleanup(struct kimage *image)
51 {
52 }
53
54 static void kexec_info(struct kimage *image)
55 {
56         int i;
57         printk("kexec information\n");
58         for (i = 0; i < image->nr_segments; i++) {
59                 printk("  segment[%d]: 0x%08x - 0x%08x (0x%08x)\n",
60                        i,
61                        (unsigned int)image->segment[i].mem,
62                        (unsigned int)image->segment[i].mem +
63                                      image->segment[i].memsz,
64                        (unsigned int)image->segment[i].memsz);
65         }
66         printk("  start     : 0x%08x\n\n", (unsigned int)image->start);
67 }
68
69 /*
70  * Do not allocate memory (or fail in any way) in machine_kexec().
71  * We are past the point of no return, committed to rebooting now.
72  */
73 void machine_kexec(struct kimage *image)
74 {
75
76         unsigned long page_list;
77         unsigned long reboot_code_buffer;
78         relocate_new_kernel_t rnk;
79         unsigned long entry;
80         unsigned long *ptr;
81
82         /*
83          * Nicked from the mips version of machine_kexec():
84          * The generic kexec code builds a page list with physical
85          * addresses. Use phys_to_virt() to convert them to virtual.
86          */
87         for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE);
88              ptr = (entry & IND_INDIRECTION) ?
89                phys_to_virt(entry & PAGE_MASK) : ptr + 1) {
90                 if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION ||
91                     *ptr & IND_DESTINATION)
92                         *ptr = (unsigned long) phys_to_virt(*ptr);
93         }
94
95         /* Interrupts aren't acceptable while we reboot */
96         local_irq_disable();
97
98         page_list = image->head;
99
100         /* we need both effective and real address here */
101         reboot_code_buffer =
102                         (unsigned long)page_address(image->control_code_page);
103
104         /* copy our kernel relocation code to the control code page */
105         memcpy((void *)reboot_code_buffer, relocate_new_kernel,
106                                                 relocate_new_kernel_size);
107
108         kexec_info(image);
109         flush_cache_all();
110
111         set_bl_bit();
112 #if defined(CONFIG_SH_STANDARD_BIOS)
113         asm volatile("ldc %0, vbr" :
114                      : "r" (((unsigned long) gdb_vbr_vector) - 0x100)
115                      : "memory");
116 #endif
117         /* now call it */
118         rnk = (relocate_new_kernel_t) reboot_code_buffer;
119         (*rnk)(page_list, reboot_code_buffer, image->start);
120 }
121
122 void arch_crash_save_vmcoreinfo(void)
123 {
124 #ifdef CONFIG_NUMA
125         VMCOREINFO_SYMBOL(node_data);
126         VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
127 #endif
128 }