diff options
author | Nicolas Schichan <nschichan@freebox.fr> | 2006-10-18 09:14:55 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-11-29 20:14:44 -0500 |
commit | 583bb86fbb9e85287f020fe4eb5352a0ec3c66a3 (patch) | |
tree | 5aa886f3fd85387d26df30bc33ef24aeda1181f5 /arch/mips/kernel/machine_kexec.c | |
parent | c237923009da464881d89f4bc27c3b5b1a93d61b (diff) |
[MIPS] Add support for kexec
A tiny userland application loading the kernel and invoking kexec_load for
mips is available here:
http://chac.le-poulpe.net/~nico/kexec/kexec-2006-10-18.tar.gz
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/machine_kexec.c')
-rw-r--r-- | arch/mips/kernel/machine_kexec.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/mips/kernel/machine_kexec.c b/arch/mips/kernel/machine_kexec.c new file mode 100644 index 000000000000..e0ad754c7edd --- /dev/null +++ b/arch/mips/kernel/machine_kexec.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * machine_kexec.c for kexec | ||
3 | * Created by <nschichan@corp.free.fr> on Thu Oct 12 15:15:06 2006 | ||
4 | * | ||
5 | * This source code is licensed under the GNU General Public License, | ||
6 | * Version 2. See the file COPYING for more details. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kexec.h> | ||
10 | #include <linux/mm.h> | ||
11 | #include <linux/delay.h> | ||
12 | |||
13 | #include <asm/cacheflush.h> | ||
14 | #include <asm/page.h> | ||
15 | |||
16 | const extern unsigned char relocate_new_kernel[]; | ||
17 | const extern unsigned int relocate_new_kernel_size; | ||
18 | |||
19 | extern unsigned long kexec_start_address; | ||
20 | extern unsigned long kexec_indirection_page; | ||
21 | |||
22 | int | ||
23 | machine_kexec_prepare(struct kimage *kimage) | ||
24 | { | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | void | ||
29 | machine_kexec_cleanup(struct kimage *kimage) | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void | ||
34 | machine_shutdown(void) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | void | ||
39 | machine_crash_shutdown(struct pt_regs *regs) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void | ||
44 | machine_kexec(struct kimage *image) | ||
45 | { | ||
46 | unsigned long reboot_code_buffer; | ||
47 | unsigned long entry; | ||
48 | unsigned long *ptr; | ||
49 | |||
50 | reboot_code_buffer = | ||
51 | (unsigned long)page_address(image->control_code_page); | ||
52 | |||
53 | kexec_start_address = image->start; | ||
54 | kexec_indirection_page = phys_to_virt(image->head & PAGE_MASK); | ||
55 | |||
56 | memcpy((void*)reboot_code_buffer, relocate_new_kernel, | ||
57 | relocate_new_kernel_size); | ||
58 | |||
59 | /* | ||
60 | * The generic kexec code builds a page list with physical | ||
61 | * addresses. they are directly accessible through KSEG0 (or | ||
62 | * CKSEG0 or XPHYS if on 64bit system), hence the | ||
63 | * pys_to_virt() call. | ||
64 | */ | ||
65 | for (ptr = &image->head; (entry = *ptr) && !(entry &IND_DONE); | ||
66 | ptr = (entry & IND_INDIRECTION) ? | ||
67 | phys_to_virt(entry & PAGE_MASK) : ptr + 1) { | ||
68 | if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION || | ||
69 | *ptr & IND_DESTINATION) | ||
70 | *ptr = phys_to_virt(*ptr); | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | * we do not want to be bothered. | ||
75 | */ | ||
76 | local_irq_disable(); | ||
77 | |||
78 | flush_icache_range(reboot_code_buffer, | ||
79 | reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE); | ||
80 | |||
81 | printk("Will call new kernel at %08x\n", image->start); | ||
82 | printk("Bye ...\n"); | ||
83 | flush_cache_all(); | ||
84 | ((void (*)(void))reboot_code_buffer)(); | ||
85 | } | ||