blob: 87481f916a61bb4ed8743a5d1b2b5b3778639daa [file] [log] [blame]
Nicolas Schichan583bb862006-10-18 15:14:55 +02001/*
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
Ralf Baechle00be0f32007-07-31 15:17:21 +010017LEAF(relocate_new_kernel)
18 PTR_L s0, kexec_indirection_page
19 PTR_L s1, kexec_start_address
Nicolas Schichan583bb862006-10-18 15:14:55 +020020
21process_entry:
Ralf Baechle00be0f32007-07-31 15:17:21 +010022 PTR_L s2, (s0)
23 PTR_ADD s0, s0, SZREG
Nicolas Schichan583bb862006-10-18 15:14:55 +020024
25 /* destination page */
Ralf Baechle00be0f32007-07-31 15:17:21 +010026 and s3, s2, 0x1
27 beq s3, zero, 1f
28 and s4, s2, ~0x1 /* store destination addr in s4 */
29 move a0, s4
30 b process_entry
Nicolas Schichan583bb862006-10-18 15:14:55 +020031
321:
33 /* indirection page, update s0 */
Ralf Baechle00be0f32007-07-31 15:17:21 +010034 and s3, s2, 0x2
35 beq s3, zero, 1f
36 and s0, s2, ~0x2
37 b process_entry
Nicolas Schichan583bb862006-10-18 15:14:55 +020038
391:
40 /* done page */
Ralf Baechle00be0f32007-07-31 15:17:21 +010041 and s3, s2, 0x4
42 beq s3, zero, 1f
43 b done
Nicolas Schichan583bb862006-10-18 15:14:55 +0200441:
45 /* source page */
Ralf Baechle00be0f32007-07-31 15:17:21 +010046 and s3, s2, 0x8
47 beq s3, zero, process_entry
48 and s2, s2, ~0x8
49 li s6, (1 << PAGE_SHIFT) / SZREG
Nicolas Schichan583bb862006-10-18 15:14:55 +020050
51copy_word:
52 /* copy page word by word */
Ralf Baechle00be0f32007-07-31 15:17:21 +010053 REG_L s5, (s2)
54 REG_S s5, (s4)
55 PTR_ADD s4, s4, SZREG
56 PTR_ADD s2, s2, SZREG
57 LONG_SUB s6, s6, 1
58 beq s6, zero, process_entry
59 b copy_word
60 b process_entry
Nicolas Schichan583bb862006-10-18 15:14:55 +020061
62done:
63 /* jump to kexec_start_address */
Ralf Baechle00be0f32007-07-31 15:17:21 +010064 j s1
65 END(relocate_new_kernel)
Nicolas Schichan583bb862006-10-18 15:14:55 +020066
Nicolas Schichan583bb862006-10-18 15:14:55 +020067kexec_start_address:
Ralf Baechle00be0f32007-07-31 15:17:21 +010068 EXPORT(kexec_start_address)
69 PTR 0x0
70 .size kexec_start_address, PTRSIZE
Nicolas Schichan583bb862006-10-18 15:14:55 +020071
Nicolas Schichan583bb862006-10-18 15:14:55 +020072kexec_indirection_page:
Ralf Baechle00be0f32007-07-31 15:17:21 +010073 EXPORT(kexec_indirection_page)
74 PTR 0
75 .size kexec_indirection_page, PTRSIZE
Nicolas Schichan583bb862006-10-18 15:14:55 +020076
77relocate_new_kernel_end:
78
Nicolas Schichan583bb862006-10-18 15:14:55 +020079relocate_new_kernel_size:
Ralf Baechle00be0f32007-07-31 15:17:21 +010080 EXPORT(relocate_new_kernel_size)
81 PTR relocate_new_kernel_end - relocate_new_kernel
82 .size relocate_new_kernel_size, PTRSIZE