1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * relocate_kernel.S for kexec
4 * Created by <nschichan@corp.free.fr> on Thu Oct 12 17:49:57 2006
8 #include <asm/asmmacro.h>
9 #include <asm/regdef.h>
10 #include <asm/mipsregs.h>
11 #include <asm/stackframe.h>
12 #include <asm/addrspace.h>
14 LEAF(relocate_new_kernel)
20 PTR_L s0, kexec_indirection_page
21 PTR_L s1, kexec_start_address
25 PTR_ADDIU s0, s0, SZREG
28 * In case of a kdump/crash kernel, the indirection page is not
29 * populated as the kernel is directly copied to a reserved location
33 /* destination page */
36 and s4, s2, ~0x1 /* store destination addr in s4 */
40 /* indirection page, update s0 */
54 beq s3, zero, process_entry
56 li s6, (1 << _PAGE_SHIFT) / SZREG
59 /* copy page word by word */
62 PTR_ADDIU s4, s4, SZREG
63 PTR_ADDIU s2, s2, SZREG
65 beq s6, zero, process_entry
71 /* kexec_flag reset is signal to other CPUs what kernel
72 was moved to it's location. Note - we need relocated address
84 #ifdef CONFIG_CPU_CAVIUM_OCTEON
85 /* We need to flush I-cache before jumping to new kernel.
86 * Unfortunately, this code is cpu-specific.
97 /* jump to kexec_start_address */
99 END(relocate_new_kernel)
103 * Other CPUs should wait until code is relocated and
104 * then start at entry (?) point.
111 PTR_L s1, kexec_start_address
113 /* Non-relocated address works for args and kexec_start_address ( old
114 * kernel is not overwritten). But we need relocated address of
128 #ifdef CONFIG_CPU_CAVIUM_OCTEON
141 /* all PTR's must be aligned to 8 byte in 64-bit mode */
145 /* All parameters to new kernel are passed in registers a0-a3.
146 * kexec_args[0..3] are used to prepare register values.
155 .size kexec_args,PTRSIZE*4
159 * Secondary CPUs may have different kernel parameters in
160 * their registers a0-a3. secondary_kexec_args[0..3] are used
161 * to prepare register values.
163 secondary_kexec_args:
164 EXPORT(secondary_kexec_args)
169 .size secondary_kexec_args,PTRSIZE*4
176 EXPORT(kexec_start_address)
178 .size kexec_start_address, PTRSIZE
180 kexec_indirection_page:
181 EXPORT(kexec_indirection_page)
183 .size kexec_indirection_page, PTRSIZE
185 relocate_new_kernel_end:
187 relocate_new_kernel_size:
188 EXPORT(relocate_new_kernel_size)
189 PTR relocate_new_kernel_end - relocate_new_kernel
190 .size relocate_new_kernel_size, PTRSIZE