Commit | Line | Data |
---|---|---|
c587e4a6 RP |
1 | /* |
2 | * relocate_kernel.S - put the kernel image in place to boot | |
3 | */ | |
4 | ||
9b21d378 | 5 | #include <linux/linkage.h> |
c587e4a6 RP |
6 | #include <asm/kexec.h> |
7 | ||
9b21d378 DM |
8 | .align 3 /* not needed for this code, but keeps fncpy() happy */ |
9 | ||
10 | ENTRY(relocate_new_kernel) | |
c587e4a6 RP |
11 | |
12 | ldr r0,kexec_indirection_page | |
13 | ldr r1,kexec_start_address | |
14 | ||
8594a0c3 MW |
15 | /* |
16 | * If there is no indirection page (we are doing crashdumps) | |
17 | * skip any relocation. | |
18 | */ | |
19 | cmp r0, #0 | |
20 | beq 2f | |
c587e4a6 RP |
21 | |
22 | 0: /* top, read another word for the indirection page */ | |
23 | ldr r3, [r0],#4 | |
24 | ||
25 | /* Is it a destination page. Put destination address to r4 */ | |
26 | tst r3,#1,0 | |
27 | beq 1f | |
28 | bic r4,r3,#1 | |
29 | b 0b | |
30 | 1: | |
31 | /* Is it an indirection page */ | |
32 | tst r3,#2,0 | |
33 | beq 1f | |
34 | bic r0,r3,#2 | |
35 | b 0b | |
36 | 1: | |
37 | ||
38 | /* are we done ? */ | |
39 | tst r3,#4,0 | |
40 | beq 1f | |
41 | b 2f | |
42 | ||
43 | 1: | |
44 | /* is it source ? */ | |
45 | tst r3,#8,0 | |
46 | beq 0b | |
47 | bic r3,r3,#8 | |
48 | mov r6,#1024 | |
49 | 9: | |
50 | ldr r5,[r3],#4 | |
51 | str r5,[r4],#4 | |
52 | subs r6,r6,#1 | |
53 | bne 9b | |
54 | b 0b | |
55 | ||
56 | 2: | |
57 | /* Jump to relocated kernel */ | |
58 | mov lr,r1 | |
59 | mov r0,#0 | |
60 | ldr r1,kexec_mach_type | |
4cd9d6f7 | 61 | ldr r2,kexec_boot_atags |
552e0c8d WD |
62 | ARM( mov pc, lr ) |
63 | THUMB( bx lr ) | |
c587e4a6 | 64 | |
bc8b57f0 DM |
65 | .align |
66 | ||
c587e4a6 RP |
67 | .globl kexec_start_address |
68 | kexec_start_address: | |
69 | .long 0x0 | |
70 | ||
71 | .globl kexec_indirection_page | |
72 | kexec_indirection_page: | |
73 | .long 0x0 | |
74 | ||
75 | .globl kexec_mach_type | |
76 | kexec_mach_type: | |
77 | .long 0x0 | |
78 | ||
4cd9d6f7 RP |
79 | /* phy addr of the atags for the new kernel */ |
80 | .globl kexec_boot_atags | |
81 | kexec_boot_atags: | |
033b8ffe MW |
82 | .long 0x0 |
83 | ||
9b21d378 DM |
84 | ENDPROC(relocate_new_kernel) |
85 | ||
c587e4a6 RP |
86 | relocate_new_kernel_end: |
87 | ||
88 | .globl relocate_new_kernel_size | |
89 | relocate_new_kernel_size: | |
90 | .long relocate_new_kernel_end - relocate_new_kernel | |
91 | ||
92 |