2 * arch/ia64/kernel/relocate_kernel.S
4 * Relocate kexec'able kernel and start it
6 * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
7 * Copyright (C) 2005 Khalid Aziz <khalid.aziz@hp.com>
8 * Copyright (C) 2005 Intel Corp, Zou Nan hai <nanhai.zou@intel.com>
10 * This source code is licensed under the GNU General Public License,
11 * Version 2. See the file COPYING for more details.
13 #include <asm/asmmacro.h>
14 #include <asm/kregs.h>
16 #include <asm/pgtable.h>
17 #include <asm/mca_asm.h>
19 /* Must be relocatable PIC code callable as a C function
21 GLOBAL_ENTRY(relocate_new_kernel)
23 alloc r31=ar.pfs,4,0,0,0
32 flushrs // must be first insn in group
36 dep r2=0,r2,61,3 //to physical address
38 //first switch to physical mode
39 add r3=1f-.reloc_entry, r2
40 movl r16 = IA64_PSR_AC|IA64_PSR_BN|IA64_PSR_IC
41 mov ar.rsc=0 // put RSE in enforced lazy mode
43 add sp=(memory_stack_end - 16 - .reloc_entry),r2
44 add r8=(register_stack - .reloc_entry),r2
55 rfi // note: this unmask MCA/INIT (psr.mc)
58 //physical mode code begin
60 dep r28=0,in2,61,3 //to physical address
62 // purge all TC entries
63 #define O(member) IA64_CPUINFO_##member##_OFFSET
64 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
66 addl r17=O(PTCE_STRIDE),r2
67 addl r2=O(PTCE_BASE),r2
69 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
70 ld4 r19=[r2],4 // r19=ptce_count[0]
71 ld4 r21=[r17],4 // r21=ptce_stride[0]
73 ld4 r20=[r2] // r20=ptce_count[1]
74 ld4 r22=[r17] // r22=ptce_stride[1]
82 (p7) br.cond.dpnt.few 4f
97 // purge TR entry for kernel text and data
99 mov r18=KERNEL_TR_PAGE_SHIFT<<2
107 // purge TR entry for pal code
109 mov r18=IA64_GRANULE_SHIFT<<2
116 // purge TR entry for stack
117 mov r16=IA64_KR(CURRENT_STACK)
119 shl r16=r16,IA64_GRANULE_SHIFT
123 mov r18=IA64_GRANULE_SHIFT<<2
132 mov r30=in0 // in0 is page_list
133 br.sptk.few .dest_page
138 tbit.z p0, p6=r30, 0;; // 0x1 dest page
139 (p6) and r17=r30, r16
140 (p6) br.cond.sptk.few .loop;;
142 tbit.z p0, p6=r30, 1;; // 0x2 indirect page
143 (p6) and in0=r30, r16
144 (p6) br.cond.sptk.few .loop;;
146 tbit.z p0, p6=r30, 2;; // 0x4 end flag
147 (p6) br.cond.sptk.few .end_loop;;
149 tbit.z p6, p0=r30, 3;; // 0x8 source page
150 (p6) br.cond.sptk.few .loop
154 // simple copy page, may optimize later
155 movl r14=PAGE_SIZE/8 - 1;;
173 br.call.sptk.many b0=b6;;
182 relocate_new_kernel_end:
183 END(relocate_new_kernel)
185 .global relocate_new_kernel_size
186 relocate_new_kernel_size:
187 data8 relocate_new_kernel_end - relocate_new_kernel
189 GLOBAL_ENTRY(ia64_dump_cpu_regs)
191 alloc loc0=ar.pfs,1,2,0,0
193 mov ar.rsc=0 // put RSE in enforced lazy mode
194 add loc1=4*8, in0 // save r4 and r5 first
197 flushrs // flush dirty regs to backing store
207 st8 [in0]=r0, 8 // r0
208 st8 [loc1]=r4, 8 // rnat
211 st8 [in0]=r1, 8 // r1
212 st8 [loc1]=r5, 8 // pr
215 st8 [in0]=r2, 8 // r2
216 st8 [loc1]=r4, 8 // b0
219 st8 [in0]=r3, 24 // r3
220 st8 [loc1]=r5, 8 // b1
223 st8 [in0]=r6, 8 // r6
224 st8 [loc1]=r4, 8 // b2
227 st8 [in0]=r7, 8 // r7
228 st8 [loc1]=r5, 8 // b3
231 st8 [in0]=r8, 8 // r8
232 st8 [loc1]=r4, 8 // b4
235 st8 [in0]=r9, 8 // r9
236 st8 [loc1]=r5, 8 // b5
239 st8 [in0]=r10, 8 // r10
240 st8 [loc1]=r5, 8 // b6
243 st8 [in0]=r11, 8 // r11
244 st8 [loc1]=r5, 8 // b7
247 st8 [in0]=r12, 8 // r12
248 st8 [loc1]=r4, 8 // ip
251 st8 [in0]=r13, 8 // r13
252 extr.u r5=r5, 0, 38 // ar.pfs.pfm
253 mov r4=r0 // user mask
255 st8 [in0]=r14, 8 // r14
256 st8 [loc1]=r5, 8 // cfm
258 st8 [in0]=r15, 8 // r15
259 st8 [loc1]=r4, 8 // user mask
262 st8 [in0]=r16, 8 // r16
263 st8 [loc1]=r5, 8 // ar.rsc
266 st8 [in0]=r17, 8 // r17
267 st8 [loc1]=r4, 8 // ar.bsp
270 st8 [in0]=r18, 8 // r18
271 st8 [loc1]=r5, 8 // ar.bspstore
274 st8 [in0]=r19, 8 // r19
275 st8 [loc1]=r4, 8 // ar.rnat
278 st8 [in0]=r20, 8 // r20
279 st8 [loc1]=r5, 8 // ar.ccv
282 st8 [in0]=r21, 8 // r21
283 st8 [loc1]=r4, 8 // ar.unat
286 st8 [in0]=r22, 8 // r22
287 st8 [loc1]=r5, 8 // ar.fpsr
290 st8 [in0]=r23, 8 // r23
291 st8 [loc1]=r4, 8 // unat
294 st8 [in0]=r24, 8 // r24
295 st8 [loc1]=r5, 8 // fpsr
298 st8 [in0]=r25, 8 // r25
299 st8 [loc1]=r4, 8 // ar.pfs
302 st8 [in0]=r26, 8 // r26
303 st8 [loc1]=r5, 8 // ar.lc
306 st8 [in0]=r27, 8 // r27
307 st8 [loc1]=r4, 8 // ar.ec
310 st8 [in0]=r28, 8 // r28
311 st8 [loc1]=r5, 8 // ar.csd
314 st8 [in0]=r29, 8 // r29
315 st8 [loc1]=r4, 8 // ar.ssd
317 st8 [in0]=r30, 8 // r30
319 st8 [in0]=r31, 8 // r31
323 END(ia64_dump_cpu_regs)