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/relocate_kernel.S | |
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/relocate_kernel.S')
-rw-r--r-- | arch/mips/kernel/relocate_kernel.S | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/mips/kernel/relocate_kernel.S b/arch/mips/kernel/relocate_kernel.S new file mode 100644 index 000000000000..a3f0d00c1334 --- /dev/null +++ b/arch/mips/kernel/relocate_kernel.S | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * relocate_kernel.S for kexec | ||
3 | * Created by <nschichan@corp.free.fr> on Thu Oct 12 17:49:57 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 <asm/asm.h> | ||
10 | #include <asm/asmmacro.h> | ||
11 | #include <asm/regdef.h> | ||
12 | #include <asm/page.h> | ||
13 | #include <asm/mipsregs.h> | ||
14 | #include <asm/stackframe.h> | ||
15 | #include <asm/addrspace.h> | ||
16 | |||
17 | .globl relocate_new_kernel | ||
18 | relocate_new_kernel: | ||
19 | |||
20 | PTR_L s0, kexec_indirection_page | ||
21 | PTR_L s1, kexec_start_address | ||
22 | |||
23 | process_entry: | ||
24 | PTR_L s2, (s0) | ||
25 | PTR_ADD s0, s0, SZREG | ||
26 | |||
27 | /* destination page */ | ||
28 | and s3, s2, 0x1 | ||
29 | beq s3, zero, 1f | ||
30 | and s4, s2, ~0x1 /* store destination addr in s4 */ | ||
31 | move a0, s4 | ||
32 | b process_entry | ||
33 | |||
34 | 1: | ||
35 | /* indirection page, update s0 */ | ||
36 | and s3, s2, 0x2 | ||
37 | beq s3, zero, 1f | ||
38 | and s0, s2, ~0x2 | ||
39 | b process_entry | ||
40 | |||
41 | 1: | ||
42 | /* done page */ | ||
43 | and s3, s2, 0x4 | ||
44 | beq s3, zero, 1f | ||
45 | b done | ||
46 | 1: | ||
47 | /* source page */ | ||
48 | and s3, s2, 0x8 | ||
49 | beq s3, zero, process_entry | ||
50 | and s2, s2, ~0x8 | ||
51 | li s6, (1 << PAGE_SHIFT) / SZREG | ||
52 | |||
53 | copy_word: | ||
54 | /* copy page word by word */ | ||
55 | REG_L s5, (s2) | ||
56 | REG_S s5, (s4) | ||
57 | INT_ADD s4, s4, SZREG | ||
58 | INT_ADD s2, s2, SZREG | ||
59 | INT_SUB s6, s6, 1 | ||
60 | beq s6, zero, process_entry | ||
61 | b copy_word | ||
62 | b process_entry | ||
63 | |||
64 | done: | ||
65 | /* jump to kexec_start_address */ | ||
66 | j s1 | ||
67 | |||
68 | .globl kexec_start_address | ||
69 | kexec_start_address: | ||
70 | .long 0x0 | ||
71 | |||
72 | .globl kexec_indirection_page | ||
73 | kexec_indirection_page: | ||
74 | .long 0x0 | ||
75 | |||
76 | relocate_new_kernel_end: | ||
77 | |||
78 | .globl relocate_new_kernel_size | ||
79 | relocate_new_kernel_size: | ||
80 | .long relocate_new_kernel_end - relocate_new_kernel | ||