1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * arch/ia64/kernel/relocate_kernel.S
5 * Relocate kexec'able kernel and start it
7 * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
8 * Copyright (C) 2005 Khalid Aziz <khalid.aziz@hp.com>
9 * Copyright (C) 2005 Intel Corp, Zou Nan hai <nanhai.zou@intel.com>
11 #include <asm/asmmacro.h>
12 #include <asm/kregs.h>
14 #include <asm/pgtable.h>
15 #include <asm/mca_asm.h>
17 /* Must be relocatable PIC code callable as a C function
19 GLOBAL_ENTRY(relocate_new_kernel)
21 alloc r31=ar.pfs,4,0,0,0
30 flushrs // must be first insn in group
34 dep r2=0,r2,61,3 //to physical address
36 //first switch to physical mode
37 add r3=1f-.reloc_entry, r2
38 movl r16 = IA64_PSR_AC|IA64_PSR_BN|IA64_PSR_IC
39 mov ar.rsc=0 // put RSE in enforced lazy mode
41 add sp=(memory_stack_end - 16 - .reloc_entry),r2
42 add r8=(register_stack - .reloc_entry),r2
53 rfi // note: this unmask MCA/INIT (psr.mc)
56 //physical mode code begin
58 dep r28=0,in2,61,3 //to physical address
60 // purge all TC entries
61 #define O(member) IA64_CPUINFO_##member##_OFFSET
62 GET_THIS_PADDR(r2, ia64_cpu_info) // load phys addr of cpu_info into r2
64 addl r17=O(PTCE_STRIDE),r2
65 addl r2=O(PTCE_BASE),r2
67 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
68 ld4 r19=[r2],4 // r19=ptce_count[0]
69 ld4 r21=[r17],4 // r21=ptce_stride[0]
71 ld4 r20=[r2] // r20=ptce_count[1]
72 ld4 r22=[r17] // r22=ptce_stride[1]
80 (p7) br.cond.dpnt.few 4f
95 // purge TR entry for kernel text and data
97 mov r18=KERNEL_TR_PAGE_SHIFT<<2
105 // purge TR entry for pal code
107 mov r18=IA64_GRANULE_SHIFT<<2
114 // purge TR entry for stack
115 mov r16=IA64_KR(CURRENT_STACK)
117 shl r16=r16,IA64_GRANULE_SHIFT
121 mov r18=IA64_GRANULE_SHIFT<<2
130 mov r30=in0 // in0 is page_list
131 br.sptk.few .dest_page
136 tbit.z p0, p6=r30, 0;; // 0x1 dest page
137 (p6) and r17=r30, r16
138 (p6) br.cond.sptk.few .loop;;
140 tbit.z p0, p6=r30, 1;; // 0x2 indirect page
141 (p6) and in0=r30, r16
142 (p6) br.cond.sptk.few .loop;;
144 tbit.z p0, p6=r30, 2;; // 0x4 end flag
145 (p6) br.cond.sptk.few .end_loop;;
147 tbit.z p6, p0=r30, 3;; // 0x8 source page
148 (p6) br.cond.sptk.few .loop
152 // simple copy page, may optimize later
153 movl r14=PAGE_SIZE/8 - 1;;
171 br.call.sptk.many b0=b6;;
180 relocate_new_kernel_end:
181 END(relocate_new_kernel)
183 .global relocate_new_kernel_size
184 relocate_new_kernel_size:
185 data8 relocate_new_kernel_end - relocate_new_kernel
187 GLOBAL_ENTRY(ia64_dump_cpu_regs)
189 alloc loc0=ar.pfs,1,2,0,0
191 mov ar.rsc=0 // put RSE in enforced lazy mode
192 add loc1=4*8, in0 // save r4 and r5 first
195 flushrs // flush dirty regs to backing store
205 st8 [in0]=r0, 8 // r0
206 st8 [loc1]=r4, 8 // rnat
209 st8 [in0]=r1, 8 // r1
210 st8 [loc1]=r5, 8 // pr
213 st8 [in0]=r2, 8 // r2
214 st8 [loc1]=r4, 8 // b0
217 st8 [in0]=r3, 24 // r3
218 st8 [loc1]=r5, 8 // b1
221 st8 [in0]=r6, 8 // r6
222 st8 [loc1]=r4, 8 // b2
225 st8 [in0]=r7, 8 // r7
226 st8 [loc1]=r5, 8 // b3
229 st8 [in0]=r8, 8 // r8
230 st8 [loc1]=r4, 8 // b4
233 st8 [in0]=r9, 8 // r9
234 st8 [loc1]=r5, 8 // b5
237 st8 [in0]=r10, 8 // r10
238 st8 [loc1]=r5, 8 // b6
241 st8 [in0]=r11, 8 // r11
242 st8 [loc1]=r5, 8 // b7
245 st8 [in0]=r12, 8 // r12
246 st8 [loc1]=r4, 8 // ip
249 st8 [in0]=r13, 8 // r13
250 extr.u r5=r5, 0, 38 // ar.pfs.pfm
251 mov r4=r0 // user mask
253 st8 [in0]=r14, 8 // r14
254 st8 [loc1]=r5, 8 // cfm
256 st8 [in0]=r15, 8 // r15
257 st8 [loc1]=r4, 8 // user mask
260 st8 [in0]=r16, 8 // r16
261 st8 [loc1]=r5, 8 // ar.rsc
264 st8 [in0]=r17, 8 // r17
265 st8 [loc1]=r4, 8 // ar.bsp
268 st8 [in0]=r18, 8 // r18
269 st8 [loc1]=r5, 8 // ar.bspstore
272 st8 [in0]=r19, 8 // r19
273 st8 [loc1]=r4, 8 // ar.rnat
276 st8 [in0]=r20, 8 // r20
277 st8 [loc1]=r5, 8 // ar.ccv
280 st8 [in0]=r21, 8 // r21
281 st8 [loc1]=r4, 8 // ar.unat
284 st8 [in0]=r22, 8 // r22
285 st8 [loc1]=r5, 8 // ar.fpsr
288 st8 [in0]=r23, 8 // r23
289 st8 [loc1]=r4, 8 // unat
292 st8 [in0]=r24, 8 // r24
293 st8 [loc1]=r5, 8 // fpsr
296 st8 [in0]=r25, 8 // r25
297 st8 [loc1]=r4, 8 // ar.pfs
300 st8 [in0]=r26, 8 // r26
301 st8 [loc1]=r5, 8 // ar.lc
304 st8 [in0]=r27, 8 // r27
305 st8 [loc1]=r4, 8 // ar.ec
308 st8 [in0]=r28, 8 // r28
309 st8 [loc1]=r5, 8 // ar.csd
312 st8 [in0]=r29, 8 // r29
313 st8 [loc1]=r4, 8 // ar.ssd
315 st8 [in0]=r30, 8 // r30
317 st8 [in0]=r31, 8 // r31
321 END(ia64_dump_cpu_regs)