2 * relocate_kernel.S - put the kernel image in place to boot
3 * 2005.9.17 kogiidena@eggplant.ddo.jp
5 * LANDISK/sh4 is supported. Maybe, SH archtecture works well.
7 * 2009-03-18 Magnus Damm - Added Kexec Jump support
9 * This source code is licensed under the GNU General Public License,
10 * Version 2. See the file COPYING for more details.
12 #include <linux/linkage.h>
13 #include <asm/addrspace.h>
16 .globl relocate_new_kernel
18 /* r4 = indirection_page */
19 /* r5 = reboot_code_buffer */
20 /* r6 = start_address */
22 mov.l 10f, r0 /* PAGE_SIZE */
23 add r5, r0 /* setup new stack at end of control page */
25 /* save r15->r8 to new stack */
36 /* save other random registers */
45 /* switch to bank1 and save r7->r0 */
59 /* switch to bank0 and save r7->r0 */
74 mov.l r4, @-r15 /* save indirection page again */
76 bsr swap_pages /* swap pages before jumping to new kernel */
80 mov.l r15, @r0 /* save pointer to stack */
82 jsr @r6 /* hand over control to new kernel */
85 mov.l 11f, r15 /* get pointer to stack */
86 mov.l @r15+, r4 /* restore r4 to get indirection page */
88 bsr swap_pages /* swap pages back to previous state */
91 /* make sure bank0 is active and restore r0->r7 */
106 /* switch to bank1 and restore r0->r7 */
120 /* switch back to bank0 */
127 /* restore other random registers */
136 /* restore r8->r15 */
150 mov r4,r0 /* cmd = indirection_page */
152 mov.l @r4+,r0 /* cmd = *ind++ */
154 1: /* addr = cmd & 0xfffffff0 */
159 /* if(cmd & IND_DESTINATION) dst = addr */
165 2: /* else if(cmd & IND_INDIRECTION) ind = addr */
171 3: /* else if(cmd & IND_DONE) return */
177 4: /* else if(cmd & IND_SOURCE) memcpy(dst,addr,PAGE_SIZE) */
181 mov.l 10f,r3 /* PAGE_SIZE */
187 /* regular kexec just overwrites the destination page
188 * with the contents of the source page.
189 * for the kexec jump case we need to swap the contents
191 * to keep it simple swap the contents for both cases.
226 .long 0x20000000 ! RB=1
228 relocate_new_kernel_end:
230 .globl relocate_new_kernel_size
231 relocate_new_kernel_size:
232 .long relocate_new_kernel_end - relocate_new_kernel