2 * relocate_kernel.S - put the kernel image in place to boot
3 * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
5 * GAMECUBE/PPC32 port Copyright (C) 2004 Albert Herranz
7 * This source code is licensed under the GNU General Public License,
8 * Version 2. See the file COPYING for more details.
12 #include <asm/ppc_asm.h>
13 #include <asm/processor.h>
15 #include <asm/kexec.h>
17 #define PAGE_SIZE 4096 /* must be same value as in <asm/page.h> */
19 /* returns r3 = relocated address of sym */
21 #define RELOC_SYM(sym) \
34 * Must be relocatable PIC code callable as a C function.
36 .globl relocate_new_kernel
38 /* r3 = indirection_page */
39 /* r4 = reboot_code_buffer */
40 /* r5 = start_address */
44 /* Set Machine Status Register to a known status */
46 ori r8, r8, MSR_RI|MSR_ME
50 /* from this point address translation is turned off */
51 /* and interrupts are disabled */
53 /* set a new stack at the bottom of our page... */
54 /* (not really needed now) */
55 addi r1, r4, KEXEC_CONTROL_CODE_SIZE - 8 /* for LR Save+Back Chain */
59 li r6, 0 /* checksum */
62 0: /* top, read another word for the indirection page */
65 /* is it a destination page? (r8) */
66 rlwinm. r7, r0, 0, 31, 31 /* IND_DESTINATION (1<<0) */
69 rlwinm r8, r0, 0, 0, 19 /* clear kexec flags, page align */
72 1: /* is it an indirection page? (r3) */
73 rlwinm. r7, r0, 0, 30, 30 /* IND_INDIRECTION (1<<1) */
76 rlwinm r3, r0, 0, 0, 19 /* clear kexec flags, page align */
81 rlwinm. r7, r0, 0, 29, 29 /* IND_DONE (1<<2) */
85 1: /* is it a source page? (r9) */
86 rlwinm. r7, r0, 0, 28, 28 /* IND_SOURCE (1<<3) */
89 rlwinm r9, r0, 0, 0, 19 /* clear kexec flags, page align */
96 lwzu r0, 4(r9) /* do the copy */
110 /* To be certain of avoiding problems with self-modifying code
111 * execute a serializing instruction here.
116 /* jump to the entry point, usually the setup routine */
122 relocate_new_kernel_end:
124 .globl relocate_new_kernel_size
125 relocate_new_kernel_size:
126 .long relocate_new_kernel_end - relocate_new_kernel