]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Here is where the ball gets rolling as far as the kernel is concerned. | |
3 | * When control is transferred to _start, the bootload has already | |
4 | * loaded us to the correct address. All that's left to do here is | |
5 | * to set up the kernel's global pointer and jump to the kernel | |
6 | * entry point. | |
7 | * | |
8 | * Copyright (C) 1998-2001, 2003, 2005 Hewlett-Packard Co | |
9 | * David Mosberger-Tang <davidm@hpl.hp.com> | |
10 | * Stephane Eranian <eranian@hpl.hp.com> | |
11 | * Copyright (C) 1999 VA Linux Systems | |
12 | * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> | |
13 | * Copyright (C) 1999 Intel Corp. | |
14 | * Copyright (C) 1999 Asit Mallick <Asit.K.Mallick@intel.com> | |
15 | * Copyright (C) 1999 Don Dugger <Don.Dugger@intel.com> | |
16 | * Copyright (C) 2002 Fenghua Yu <fenghua.yu@intel.com> | |
17 | * -Optimize __ia64_save_fpu() and __ia64_load_fpu() for Itanium 2. | |
b8d8b883 AR |
18 | * Copyright (C) 2004 Ashok Raj <ashok.raj@intel.com> |
19 | * Support for CPU Hotplug | |
1da177e4 LT |
20 | */ |
21 | ||
1da177e4 LT |
22 | |
23 | #include <asm/asmmacro.h> | |
24 | #include <asm/fpu.h> | |
25 | #include <asm/kregs.h> | |
26 | #include <asm/mmu_context.h> | |
39e01cb8 | 27 | #include <asm/asm-offsets.h> |
1da177e4 | 28 | #include <asm/pal.h> |
3e0879de | 29 | #include <asm/paravirt.h> |
1da177e4 LT |
30 | #include <asm/pgtable.h> |
31 | #include <asm/processor.h> | |
32 | #include <asm/ptrace.h> | |
33 | #include <asm/system.h> | |
b8d8b883 | 34 | #include <asm/mca_asm.h> |
3e0879de IY |
35 | #include <linux/init.h> |
36 | #include <linux/linkage.h> | |
b8d8b883 AR |
37 | |
38 | #ifdef CONFIG_HOTPLUG_CPU | |
39 | #define SAL_PSR_BITS_TO_SET \ | |
40 | (IA64_PSR_AC | IA64_PSR_BN | IA64_PSR_MFH | IA64_PSR_MFL) | |
41 | ||
42 | #define SAVE_FROM_REG(src, ptr, dest) \ | |
43 | mov dest=src;; \ | |
44 | st8 [ptr]=dest,0x08 | |
45 | ||
46 | #define RESTORE_REG(reg, ptr, _tmp) \ | |
47 | ld8 _tmp=[ptr],0x08;; \ | |
48 | mov reg=_tmp | |
49 | ||
50 | #define SAVE_BREAK_REGS(ptr, _idx, _breg, _dest)\ | |
51 | mov ar.lc=IA64_NUM_DBG_REGS-1;; \ | |
52 | mov _idx=0;; \ | |
53 | 1: \ | |
54 | SAVE_FROM_REG(_breg[_idx], ptr, _dest);; \ | |
55 | add _idx=1,_idx;; \ | |
56 | br.cloop.sptk.many 1b | |
57 | ||
58 | #define RESTORE_BREAK_REGS(ptr, _idx, _breg, _tmp, _lbl)\ | |
59 | mov ar.lc=IA64_NUM_DBG_REGS-1;; \ | |
60 | mov _idx=0;; \ | |
61 | _lbl: RESTORE_REG(_breg[_idx], ptr, _tmp);; \ | |
62 | add _idx=1, _idx;; \ | |
63 | br.cloop.sptk.many _lbl | |
64 | ||
65 | #define SAVE_ONE_RR(num, _reg, _tmp) \ | |
66 | movl _tmp=(num<<61);; \ | |
67 | mov _reg=rr[_tmp] | |
68 | ||
69 | #define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \ | |
70 | SAVE_ONE_RR(0,_r0, _tmp);; \ | |
71 | SAVE_ONE_RR(1,_r1, _tmp);; \ | |
72 | SAVE_ONE_RR(2,_r2, _tmp);; \ | |
73 | SAVE_ONE_RR(3,_r3, _tmp);; \ | |
74 | SAVE_ONE_RR(4,_r4, _tmp);; \ | |
75 | SAVE_ONE_RR(5,_r5, _tmp);; \ | |
76 | SAVE_ONE_RR(6,_r6, _tmp);; \ | |
77 | SAVE_ONE_RR(7,_r7, _tmp);; | |
78 | ||
79 | #define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \ | |
80 | st8 [ptr]=_r0, 8;; \ | |
81 | st8 [ptr]=_r1, 8;; \ | |
82 | st8 [ptr]=_r2, 8;; \ | |
83 | st8 [ptr]=_r3, 8;; \ | |
84 | st8 [ptr]=_r4, 8;; \ | |
85 | st8 [ptr]=_r5, 8;; \ | |
86 | st8 [ptr]=_r6, 8;; \ | |
87 | st8 [ptr]=_r7, 8;; | |
88 | ||
89 | #define RESTORE_REGION_REGS(ptr, _idx1, _idx2, _tmp) \ | |
90 | mov ar.lc=0x08-1;; \ | |
91 | movl _idx1=0x00;; \ | |
92 | RestRR: \ | |
93 | dep.z _idx2=_idx1,61,3;; \ | |
94 | ld8 _tmp=[ptr],8;; \ | |
95 | mov rr[_idx2]=_tmp;; \ | |
96 | srlz.d;; \ | |
97 | add _idx1=1,_idx1;; \ | |
98 | br.cloop.sptk.few RestRR | |
99 | ||
df6c6804 AR |
100 | #define SET_AREA_FOR_BOOTING_CPU(reg1, reg2) \ |
101 | movl reg1=sal_state_for_booting_cpu;; \ | |
102 | ld8 reg2=[reg1];; | |
103 | ||
b8d8b883 AR |
104 | /* |
105 | * Adjust region registers saved before starting to save | |
106 | * break regs and rest of the states that need to be preserved. | |
107 | */ | |
108 | #define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(_reg1,_reg2,_pred) \ | |
109 | SAVE_FROM_REG(b0,_reg1,_reg2);; \ | |
110 | SAVE_FROM_REG(b1,_reg1,_reg2);; \ | |
111 | SAVE_FROM_REG(b2,_reg1,_reg2);; \ | |
112 | SAVE_FROM_REG(b3,_reg1,_reg2);; \ | |
113 | SAVE_FROM_REG(b4,_reg1,_reg2);; \ | |
114 | SAVE_FROM_REG(b5,_reg1,_reg2);; \ | |
115 | st8 [_reg1]=r1,0x08;; \ | |
116 | st8 [_reg1]=r12,0x08;; \ | |
117 | st8 [_reg1]=r13,0x08;; \ | |
118 | SAVE_FROM_REG(ar.fpsr,_reg1,_reg2);; \ | |
119 | SAVE_FROM_REG(ar.pfs,_reg1,_reg2);; \ | |
120 | SAVE_FROM_REG(ar.rnat,_reg1,_reg2);; \ | |
121 | SAVE_FROM_REG(ar.unat,_reg1,_reg2);; \ | |
122 | SAVE_FROM_REG(ar.bspstore,_reg1,_reg2);; \ | |
123 | SAVE_FROM_REG(cr.dcr,_reg1,_reg2);; \ | |
124 | SAVE_FROM_REG(cr.iva,_reg1,_reg2);; \ | |
125 | SAVE_FROM_REG(cr.pta,_reg1,_reg2);; \ | |
126 | SAVE_FROM_REG(cr.itv,_reg1,_reg2);; \ | |
127 | SAVE_FROM_REG(cr.pmv,_reg1,_reg2);; \ | |
128 | SAVE_FROM_REG(cr.cmcv,_reg1,_reg2);; \ | |
129 | SAVE_FROM_REG(cr.lrr0,_reg1,_reg2);; \ | |
130 | SAVE_FROM_REG(cr.lrr1,_reg1,_reg2);; \ | |
131 | st8 [_reg1]=r4,0x08;; \ | |
132 | st8 [_reg1]=r5,0x08;; \ | |
133 | st8 [_reg1]=r6,0x08;; \ | |
134 | st8 [_reg1]=r7,0x08;; \ | |
135 | st8 [_reg1]=_pred,0x08;; \ | |
136 | SAVE_FROM_REG(ar.lc, _reg1, _reg2);; \ | |
137 | stf.spill.nta [_reg1]=f2,16;; \ | |
138 | stf.spill.nta [_reg1]=f3,16;; \ | |
139 | stf.spill.nta [_reg1]=f4,16;; \ | |
140 | stf.spill.nta [_reg1]=f5,16;; \ | |
141 | stf.spill.nta [_reg1]=f16,16;; \ | |
142 | stf.spill.nta [_reg1]=f17,16;; \ | |
143 | stf.spill.nta [_reg1]=f18,16;; \ | |
144 | stf.spill.nta [_reg1]=f19,16;; \ | |
145 | stf.spill.nta [_reg1]=f20,16;; \ | |
146 | stf.spill.nta [_reg1]=f21,16;; \ | |
147 | stf.spill.nta [_reg1]=f22,16;; \ | |
148 | stf.spill.nta [_reg1]=f23,16;; \ | |
149 | stf.spill.nta [_reg1]=f24,16;; \ | |
150 | stf.spill.nta [_reg1]=f25,16;; \ | |
151 | stf.spill.nta [_reg1]=f26,16;; \ | |
152 | stf.spill.nta [_reg1]=f27,16;; \ | |
153 | stf.spill.nta [_reg1]=f28,16;; \ | |
154 | stf.spill.nta [_reg1]=f29,16;; \ | |
155 | stf.spill.nta [_reg1]=f30,16;; \ | |
156 | stf.spill.nta [_reg1]=f31,16;; | |
157 | ||
158 | #else | |
df6c6804 AR |
159 | #define SET_AREA_FOR_BOOTING_CPU(a1, a2) |
160 | #define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(a1,a2, a3) | |
b8d8b883 AR |
161 | #define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) |
162 | #define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) | |
163 | #endif | |
164 | ||
165 | #define SET_ONE_RR(num, pgsize, _tmp1, _tmp2, vhpt) \ | |
166 | movl _tmp1=(num << 61);; \ | |
167 | mov _tmp2=((ia64_rid(IA64_REGION_ID_KERNEL, (num<<61)) << 8) | (pgsize << 2) | vhpt);; \ | |
168 | mov rr[_tmp1]=_tmp2 | |
1da177e4 LT |
169 | |
170 | .section __special_page_section,"ax" | |
171 | ||
172 | .global empty_zero_page | |
173 | empty_zero_page: | |
174 | .skip PAGE_SIZE | |
175 | ||
176 | .global swapper_pg_dir | |
177 | swapper_pg_dir: | |
178 | .skip PAGE_SIZE | |
179 | ||
180 | .rodata | |
181 | halt_msg: | |
182 | stringz "Halting kernel\n" | |
183 | ||
9d6f40b8 | 184 | .section .text.head,"ax" |
1da177e4 LT |
185 | |
186 | .global start_ap | |
187 | ||
188 | /* | |
189 | * Start the kernel. When the bootloader passes control to _start(), r28 | |
190 | * points to the address of the boot parameter area. Execution reaches | |
191 | * here in physical mode. | |
192 | */ | |
193 | GLOBAL_ENTRY(_start) | |
194 | start_ap: | |
195 | .prologue | |
196 | .save rp, r0 // terminate unwind chain with a NULL rp | |
197 | .body | |
198 | ||
199 | rsm psr.i | psr.ic | |
200 | ;; | |
201 | srlz.i | |
202 | ;; | |
1c7d6707 JS |
203 | { |
204 | flushrs // must be first insn in group | |
205 | srlz.i | |
206 | } | |
207 | ;; | |
b8d8b883 AR |
208 | /* |
209 | * Save the region registers, predicate before they get clobbered | |
210 | */ | |
211 | SAVE_REGION_REGS(r2, r8,r9,r10,r11,r12,r13,r14,r15); | |
212 | mov r25=pr;; | |
213 | ||
1da177e4 LT |
214 | /* |
215 | * Initialize kernel region registers: | |
216 | * rr[0]: VHPT enabled, page size = PAGE_SHIFT | |
217 | * rr[1]: VHPT enabled, page size = PAGE_SHIFT | |
218 | * rr[2]: VHPT enabled, page size = PAGE_SHIFT | |
219 | * rr[3]: VHPT enabled, page size = PAGE_SHIFT | |
220 | * rr[4]: VHPT enabled, page size = PAGE_SHIFT | |
221 | * rr[5]: VHPT enabled, page size = PAGE_SHIFT | |
222 | * rr[6]: VHPT disabled, page size = IA64_GRANULE_SHIFT | |
223 | * rr[7]: VHPT disabled, page size = IA64_GRANULE_SHIFT | |
224 | * We initialize all of them to prevent inadvertently assuming | |
225 | * something about the state of address translation early in boot. | |
226 | */ | |
b8d8b883 AR |
227 | SET_ONE_RR(0, PAGE_SHIFT, r2, r16, 1);; |
228 | SET_ONE_RR(1, PAGE_SHIFT, r2, r16, 1);; | |
229 | SET_ONE_RR(2, PAGE_SHIFT, r2, r16, 1);; | |
230 | SET_ONE_RR(3, PAGE_SHIFT, r2, r16, 1);; | |
231 | SET_ONE_RR(4, PAGE_SHIFT, r2, r16, 1);; | |
232 | SET_ONE_RR(5, PAGE_SHIFT, r2, r16, 1);; | |
233 | SET_ONE_RR(6, IA64_GRANULE_SHIFT, r2, r16, 0);; | |
234 | SET_ONE_RR(7, IA64_GRANULE_SHIFT, r2, r16, 0);; | |
1da177e4 LT |
235 | /* |
236 | * Now pin mappings into the TLB for kernel text and data | |
237 | */ | |
238 | mov r18=KERNEL_TR_PAGE_SHIFT<<2 | |
239 | movl r17=KERNEL_START | |
240 | ;; | |
241 | mov cr.itir=r18 | |
242 | mov cr.ifa=r17 | |
243 | mov r16=IA64_TR_KERNEL | |
244 | mov r3=ip | |
245 | movl r18=PAGE_KERNEL | |
246 | ;; | |
247 | dep r2=0,r3,0,KERNEL_TR_PAGE_SHIFT | |
248 | ;; | |
249 | or r18=r2,r18 | |
250 | ;; | |
251 | srlz.i | |
252 | ;; | |
253 | itr.i itr[r16]=r18 | |
254 | ;; | |
255 | itr.d dtr[r16]=r18 | |
256 | ;; | |
257 | srlz.i | |
258 | ||
259 | /* | |
260 | * Switch into virtual mode: | |
261 | */ | |
262 | movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \ | |
263 | |IA64_PSR_DI) | |
264 | ;; | |
265 | mov cr.ipsr=r16 | |
266 | movl r17=1f | |
267 | ;; | |
268 | mov cr.iip=r17 | |
269 | mov cr.ifs=r0 | |
270 | ;; | |
271 | rfi | |
272 | ;; | |
273 | 1: // now we are in virtual mode | |
274 | ||
df6c6804 | 275 | SET_AREA_FOR_BOOTING_CPU(r2, r16); |
b8d8b883 AR |
276 | |
277 | STORE_REGION_REGS(r16, r8,r9,r10,r11,r12,r13,r14,r15); | |
278 | SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(r16,r17,r25) | |
279 | ;; | |
280 | ||
1da177e4 LT |
281 | // set IVT entry point---can't access I/O ports without it |
282 | movl r3=ia64_ivt | |
283 | ;; | |
284 | mov cr.iva=r3 | |
285 | movl r2=FPSR_DEFAULT | |
286 | ;; | |
287 | srlz.i | |
288 | movl gp=__gp | |
289 | ||
290 | mov ar.fpsr=r2 | |
291 | ;; | |
292 | ||
293 | #define isAP p2 // are we an Application Processor? | |
294 | #define isBP p3 // are we the Bootstrap Processor? | |
295 | ||
296 | #ifdef CONFIG_SMP | |
297 | /* | |
298 | * Find the init_task for the currently booting CPU. At poweron, and in | |
299 | * UP mode, task_for_booting_cpu is NULL. | |
300 | */ | |
301 | movl r3=task_for_booting_cpu | |
302 | ;; | |
303 | ld8 r3=[r3] | |
304 | movl r2=init_task | |
305 | ;; | |
306 | cmp.eq isBP,isAP=r3,r0 | |
307 | ;; | |
308 | (isAP) mov r2=r3 | |
309 | #else | |
310 | movl r2=init_task | |
311 | cmp.eq isBP,isAP=r0,r0 | |
312 | #endif | |
313 | ;; | |
314 | tpa r3=r2 // r3 == phys addr of task struct | |
315 | mov r16=-1 | |
316 | (isBP) br.cond.dpnt .load_current // BP stack is on region 5 --- no need to map it | |
317 | ||
318 | // load mapping for stack (virtaddr in r2, physaddr in r3) | |
319 | rsm psr.ic | |
320 | movl r17=PAGE_KERNEL | |
321 | ;; | |
322 | srlz.d | |
323 | dep r18=0,r3,0,12 | |
324 | ;; | |
325 | or r18=r17,r18 | |
326 | dep r2=-1,r3,61,3 // IMVA of task | |
327 | ;; | |
328 | mov r17=rr[r2] | |
329 | shr.u r16=r3,IA64_GRANULE_SHIFT | |
330 | ;; | |
331 | dep r17=0,r17,8,24 | |
332 | ;; | |
333 | mov cr.itir=r17 | |
334 | mov cr.ifa=r2 | |
335 | ||
336 | mov r19=IA64_TR_CURRENT_STACK | |
337 | ;; | |
338 | itr.d dtr[r19]=r18 | |
339 | ;; | |
340 | ssm psr.ic | |
341 | srlz.d | |
342 | ;; | |
343 | ||
344 | .load_current: | |
345 | // load the "current" pointer (r13) and ar.k6 with the current task | |
346 | mov IA64_KR(CURRENT)=r2 // virtual address | |
347 | mov IA64_KR(CURRENT_STACK)=r16 | |
348 | mov r13=r2 | |
349 | /* | |
b8d8b883 AR |
350 | * Reserve space at the top of the stack for "struct pt_regs". Kernel |
351 | * threads don't store interesting values in that structure, but the space | |
352 | * still needs to be there because time-critical stuff such as the context | |
353 | * switching can be implemented more efficiently (for example, __switch_to() | |
1da177e4 LT |
354 | * always sets the psr.dfh bit of the task it is switching to). |
355 | */ | |
b8d8b883 | 356 | |
1da177e4 LT |
357 | addl r12=IA64_STK_OFFSET-IA64_PT_REGS_SIZE-16,r2 |
358 | addl r2=IA64_RBS_OFFSET,r2 // initialize the RSE | |
359 | mov ar.rsc=0 // place RSE in enforced lazy mode | |
360 | ;; | |
361 | loadrs // clear the dirty partition | |
10617bbe TL |
362 | movl r19=__phys_per_cpu_start |
363 | mov r18=PERCPU_PAGE_SIZE | |
364 | ;; | |
365 | #ifndef CONFIG_SMP | |
366 | add r19=r19,r18 | |
367 | ;; | |
368 | #else | |
369 | (isAP) br.few 2f | |
370 | mov r20=r19 | |
371 | sub r19=r19,r18 | |
372 | ;; | |
373 | shr.u r18=r18,3 | |
374 | 1: | |
375 | ld8 r21=[r20],8;; | |
376 | st8[r19]=r21,8 | |
377 | adds r18=-1,r18;; | |
378 | cmp4.lt p7,p6=0,r18 | |
379 | (p7) br.cond.dptk.few 1b | |
380 | 2: | |
381 | #endif | |
382 | tpa r19=r19 | |
383 | ;; | |
384 | .pred.rel.mutex isBP,isAP | |
385 | (isBP) mov IA64_KR(PER_CPU_DATA)=r19 // per-CPU base for cpu0 | |
386 | (isAP) mov IA64_KR(PER_CPU_DATA)=r0 // clear physical per-CPU base | |
1da177e4 LT |
387 | ;; |
388 | mov ar.bspstore=r2 // establish the new RSE stack | |
389 | ;; | |
390 | mov ar.rsc=0x3 // place RSE in eager mode | |
391 | ||
392 | (isBP) dep r28=-1,r28,61,3 // make address virtual | |
393 | (isBP) movl r2=ia64_boot_param | |
394 | ;; | |
395 | (isBP) st8 [r2]=r28 // save the address of the boot param area passed by the bootloader | |
396 | ||
3e0879de IY |
397 | #ifdef CONFIG_PARAVIRT |
398 | ||
399 | movl r14=hypervisor_setup_hooks | |
400 | movl r15=hypervisor_type | |
401 | mov r16=num_hypervisor_hooks | |
402 | ;; | |
403 | ld8 r2=[r15] | |
404 | ;; | |
405 | cmp.ltu p7,p0=r2,r16 // array size check | |
406 | shladd r8=r2,3,r14 | |
407 | ;; | |
408 | (p7) ld8 r9=[r8] | |
409 | ;; | |
410 | (p7) mov b1=r9 | |
411 | (p7) cmp.ne.unc p7,p0=r9,r0 // no actual branch to NULL | |
412 | ;; | |
413 | (p7) br.call.sptk.many rp=b1 | |
414 | ||
415 | __INITDATA | |
416 | ||
417 | default_setup_hook = 0 // Currently nothing needs to be done. | |
418 | ||
419 | .weak xen_setup_hook | |
420 | ||
421 | .global hypervisor_type | |
422 | hypervisor_type: | |
423 | data8 PARAVIRT_HYPERVISOR_TYPE_DEFAULT | |
424 | ||
425 | // must have the same order with PARAVIRT_HYPERVISOR_TYPE_xxx | |
426 | ||
427 | hypervisor_setup_hooks: | |
428 | data8 default_setup_hook | |
429 | data8 xen_setup_hook | |
430 | num_hypervisor_hooks = (. - hypervisor_setup_hooks) / 8 | |
431 | .previous | |
432 | ||
433 | #endif | |
434 | ||
1da177e4 LT |
435 | #ifdef CONFIG_SMP |
436 | (isAP) br.call.sptk.many rp=start_secondary | |
437 | .ret0: | |
438 | (isAP) br.cond.sptk self | |
439 | #endif | |
440 | ||
441 | // This is executed by the bootstrap processor (bsp) only: | |
442 | ||
443 | #ifdef CONFIG_IA64_FW_EMU | |
444 | // initialize PAL & SAL emulator: | |
445 | br.call.sptk.many rp=sys_fw_init | |
446 | .ret1: | |
447 | #endif | |
448 | br.call.sptk.many rp=start_kernel | |
449 | .ret2: addl r3=@ltoff(halt_msg),gp | |
450 | ;; | |
451 | alloc r2=ar.pfs,8,0,2,0 | |
452 | ;; | |
453 | ld8 out0=[r3] | |
454 | br.call.sptk.many b0=console_print | |
455 | ||
456 | self: hint @pause | |
457 | br.sptk.many self // endless loop | |
458 | END(_start) | |
459 | ||
9d6f40b8 TL |
460 | .text |
461 | ||
1da177e4 LT |
462 | GLOBAL_ENTRY(ia64_save_debug_regs) |
463 | alloc r16=ar.pfs,1,0,0,0 | |
464 | mov r20=ar.lc // preserve ar.lc | |
465 | mov ar.lc=IA64_NUM_DBG_REGS-1 | |
466 | mov r18=0 | |
467 | add r19=IA64_NUM_DBG_REGS*8,in0 | |
468 | ;; | |
469 | 1: mov r16=dbr[r18] | |
470 | #ifdef CONFIG_ITANIUM | |
471 | ;; | |
472 | srlz.d | |
473 | #endif | |
474 | mov r17=ibr[r18] | |
475 | add r18=1,r18 | |
476 | ;; | |
477 | st8.nta [in0]=r16,8 | |
478 | st8.nta [r19]=r17,8 | |
479 | br.cloop.sptk.many 1b | |
480 | ;; | |
481 | mov ar.lc=r20 // restore ar.lc | |
482 | br.ret.sptk.many rp | |
483 | END(ia64_save_debug_regs) | |
484 | ||
485 | GLOBAL_ENTRY(ia64_load_debug_regs) | |
486 | alloc r16=ar.pfs,1,0,0,0 | |
487 | lfetch.nta [in0] | |
488 | mov r20=ar.lc // preserve ar.lc | |
489 | add r19=IA64_NUM_DBG_REGS*8,in0 | |
490 | mov ar.lc=IA64_NUM_DBG_REGS-1 | |
491 | mov r18=-1 | |
492 | ;; | |
493 | 1: ld8.nta r16=[in0],8 | |
494 | ld8.nta r17=[r19],8 | |
495 | add r18=1,r18 | |
496 | ;; | |
497 | mov dbr[r18]=r16 | |
498 | #ifdef CONFIG_ITANIUM | |
499 | ;; | |
500 | srlz.d // Errata 132 (NoFix status) | |
501 | #endif | |
502 | mov ibr[r18]=r17 | |
503 | br.cloop.sptk.many 1b | |
504 | ;; | |
505 | mov ar.lc=r20 // restore ar.lc | |
506 | br.ret.sptk.many rp | |
507 | END(ia64_load_debug_regs) | |
508 | ||
509 | GLOBAL_ENTRY(__ia64_save_fpu) | |
510 | alloc r2=ar.pfs,1,4,0,0 | |
511 | adds loc0=96*16-16,in0 | |
512 | adds loc1=96*16-16-128,in0 | |
513 | ;; | |
514 | stf.spill.nta [loc0]=f127,-256 | |
515 | stf.spill.nta [loc1]=f119,-256 | |
516 | ;; | |
517 | stf.spill.nta [loc0]=f111,-256 | |
518 | stf.spill.nta [loc1]=f103,-256 | |
519 | ;; | |
520 | stf.spill.nta [loc0]=f95,-256 | |
521 | stf.spill.nta [loc1]=f87,-256 | |
522 | ;; | |
523 | stf.spill.nta [loc0]=f79,-256 | |
524 | stf.spill.nta [loc1]=f71,-256 | |
525 | ;; | |
526 | stf.spill.nta [loc0]=f63,-256 | |
527 | stf.spill.nta [loc1]=f55,-256 | |
528 | adds loc2=96*16-32,in0 | |
529 | ;; | |
530 | stf.spill.nta [loc0]=f47,-256 | |
531 | stf.spill.nta [loc1]=f39,-256 | |
532 | adds loc3=96*16-32-128,in0 | |
533 | ;; | |
534 | stf.spill.nta [loc2]=f126,-256 | |
535 | stf.spill.nta [loc3]=f118,-256 | |
536 | ;; | |
537 | stf.spill.nta [loc2]=f110,-256 | |
538 | stf.spill.nta [loc3]=f102,-256 | |
539 | ;; | |
540 | stf.spill.nta [loc2]=f94,-256 | |
541 | stf.spill.nta [loc3]=f86,-256 | |
542 | ;; | |
543 | stf.spill.nta [loc2]=f78,-256 | |
544 | stf.spill.nta [loc3]=f70,-256 | |
545 | ;; | |
546 | stf.spill.nta [loc2]=f62,-256 | |
547 | stf.spill.nta [loc3]=f54,-256 | |
548 | adds loc0=96*16-48,in0 | |
549 | ;; | |
550 | stf.spill.nta [loc2]=f46,-256 | |
551 | stf.spill.nta [loc3]=f38,-256 | |
552 | adds loc1=96*16-48-128,in0 | |
553 | ;; | |
554 | stf.spill.nta [loc0]=f125,-256 | |
555 | stf.spill.nta [loc1]=f117,-256 | |
556 | ;; | |
557 | stf.spill.nta [loc0]=f109,-256 | |
558 | stf.spill.nta [loc1]=f101,-256 | |
559 | ;; | |
560 | stf.spill.nta [loc0]=f93,-256 | |
561 | stf.spill.nta [loc1]=f85,-256 | |
562 | ;; | |
563 | stf.spill.nta [loc0]=f77,-256 | |
564 | stf.spill.nta [loc1]=f69,-256 | |
565 | ;; | |
566 | stf.spill.nta [loc0]=f61,-256 | |
567 | stf.spill.nta [loc1]=f53,-256 | |
568 | adds loc2=96*16-64,in0 | |
569 | ;; | |
570 | stf.spill.nta [loc0]=f45,-256 | |
571 | stf.spill.nta [loc1]=f37,-256 | |
572 | adds loc3=96*16-64-128,in0 | |
573 | ;; | |
574 | stf.spill.nta [loc2]=f124,-256 | |
575 | stf.spill.nta [loc3]=f116,-256 | |
576 | ;; | |
577 | stf.spill.nta [loc2]=f108,-256 | |
578 | stf.spill.nta [loc3]=f100,-256 | |
579 | ;; | |
580 | stf.spill.nta [loc2]=f92,-256 | |
581 | stf.spill.nta [loc3]=f84,-256 | |
582 | ;; | |
583 | stf.spill.nta [loc2]=f76,-256 | |
584 | stf.spill.nta [loc3]=f68,-256 | |
585 | ;; | |
586 | stf.spill.nta [loc2]=f60,-256 | |
587 | stf.spill.nta [loc3]=f52,-256 | |
588 | adds loc0=96*16-80,in0 | |
589 | ;; | |
590 | stf.spill.nta [loc2]=f44,-256 | |
591 | stf.spill.nta [loc3]=f36,-256 | |
592 | adds loc1=96*16-80-128,in0 | |
593 | ;; | |
594 | stf.spill.nta [loc0]=f123,-256 | |
595 | stf.spill.nta [loc1]=f115,-256 | |
596 | ;; | |
597 | stf.spill.nta [loc0]=f107,-256 | |
598 | stf.spill.nta [loc1]=f99,-256 | |
599 | ;; | |
600 | stf.spill.nta [loc0]=f91,-256 | |
601 | stf.spill.nta [loc1]=f83,-256 | |
602 | ;; | |
603 | stf.spill.nta [loc0]=f75,-256 | |
604 | stf.spill.nta [loc1]=f67,-256 | |
605 | ;; | |
606 | stf.spill.nta [loc0]=f59,-256 | |
607 | stf.spill.nta [loc1]=f51,-256 | |
608 | adds loc2=96*16-96,in0 | |
609 | ;; | |
610 | stf.spill.nta [loc0]=f43,-256 | |
611 | stf.spill.nta [loc1]=f35,-256 | |
612 | adds loc3=96*16-96-128,in0 | |
613 | ;; | |
614 | stf.spill.nta [loc2]=f122,-256 | |
615 | stf.spill.nta [loc3]=f114,-256 | |
616 | ;; | |
617 | stf.spill.nta [loc2]=f106,-256 | |
618 | stf.spill.nta [loc3]=f98,-256 | |
619 | ;; | |
620 | stf.spill.nta [loc2]=f90,-256 | |
621 | stf.spill.nta [loc3]=f82,-256 | |
622 | ;; | |
623 | stf.spill.nta [loc2]=f74,-256 | |
624 | stf.spill.nta [loc3]=f66,-256 | |
625 | ;; | |
626 | stf.spill.nta [loc2]=f58,-256 | |
627 | stf.spill.nta [loc3]=f50,-256 | |
628 | adds loc0=96*16-112,in0 | |
629 | ;; | |
630 | stf.spill.nta [loc2]=f42,-256 | |
631 | stf.spill.nta [loc3]=f34,-256 | |
632 | adds loc1=96*16-112-128,in0 | |
633 | ;; | |
634 | stf.spill.nta [loc0]=f121,-256 | |
635 | stf.spill.nta [loc1]=f113,-256 | |
636 | ;; | |
637 | stf.spill.nta [loc0]=f105,-256 | |
638 | stf.spill.nta [loc1]=f97,-256 | |
639 | ;; | |
640 | stf.spill.nta [loc0]=f89,-256 | |
641 | stf.spill.nta [loc1]=f81,-256 | |
642 | ;; | |
643 | stf.spill.nta [loc0]=f73,-256 | |
644 | stf.spill.nta [loc1]=f65,-256 | |
645 | ;; | |
646 | stf.spill.nta [loc0]=f57,-256 | |
647 | stf.spill.nta [loc1]=f49,-256 | |
648 | adds loc2=96*16-128,in0 | |
649 | ;; | |
650 | stf.spill.nta [loc0]=f41,-256 | |
651 | stf.spill.nta [loc1]=f33,-256 | |
652 | adds loc3=96*16-128-128,in0 | |
653 | ;; | |
654 | stf.spill.nta [loc2]=f120,-256 | |
655 | stf.spill.nta [loc3]=f112,-256 | |
656 | ;; | |
657 | stf.spill.nta [loc2]=f104,-256 | |
658 | stf.spill.nta [loc3]=f96,-256 | |
659 | ;; | |
660 | stf.spill.nta [loc2]=f88,-256 | |
661 | stf.spill.nta [loc3]=f80,-256 | |
662 | ;; | |
663 | stf.spill.nta [loc2]=f72,-256 | |
664 | stf.spill.nta [loc3]=f64,-256 | |
665 | ;; | |
666 | stf.spill.nta [loc2]=f56,-256 | |
667 | stf.spill.nta [loc3]=f48,-256 | |
668 | ;; | |
669 | stf.spill.nta [loc2]=f40 | |
670 | stf.spill.nta [loc3]=f32 | |
671 | br.ret.sptk.many rp | |
672 | END(__ia64_save_fpu) | |
673 | ||
674 | GLOBAL_ENTRY(__ia64_load_fpu) | |
675 | alloc r2=ar.pfs,1,2,0,0 | |
676 | adds r3=128,in0 | |
677 | adds r14=256,in0 | |
678 | adds r15=384,in0 | |
679 | mov loc0=512 | |
680 | mov loc1=-1024+16 | |
681 | ;; | |
682 | ldf.fill.nta f32=[in0],loc0 | |
683 | ldf.fill.nta f40=[ r3],loc0 | |
684 | ldf.fill.nta f48=[r14],loc0 | |
685 | ldf.fill.nta f56=[r15],loc0 | |
686 | ;; | |
687 | ldf.fill.nta f64=[in0],loc0 | |
688 | ldf.fill.nta f72=[ r3],loc0 | |
689 | ldf.fill.nta f80=[r14],loc0 | |
690 | ldf.fill.nta f88=[r15],loc0 | |
691 | ;; | |
692 | ldf.fill.nta f96=[in0],loc1 | |
693 | ldf.fill.nta f104=[ r3],loc1 | |
694 | ldf.fill.nta f112=[r14],loc1 | |
695 | ldf.fill.nta f120=[r15],loc1 | |
696 | ;; | |
697 | ldf.fill.nta f33=[in0],loc0 | |
698 | ldf.fill.nta f41=[ r3],loc0 | |
699 | ldf.fill.nta f49=[r14],loc0 | |
700 | ldf.fill.nta f57=[r15],loc0 | |
701 | ;; | |
702 | ldf.fill.nta f65=[in0],loc0 | |
703 | ldf.fill.nta f73=[ r3],loc0 | |
704 | ldf.fill.nta f81=[r14],loc0 | |
705 | ldf.fill.nta f89=[r15],loc0 | |
706 | ;; | |
707 | ldf.fill.nta f97=[in0],loc1 | |
708 | ldf.fill.nta f105=[ r3],loc1 | |
709 | ldf.fill.nta f113=[r14],loc1 | |
710 | ldf.fill.nta f121=[r15],loc1 | |
711 | ;; | |
712 | ldf.fill.nta f34=[in0],loc0 | |
713 | ldf.fill.nta f42=[ r3],loc0 | |
714 | ldf.fill.nta f50=[r14],loc0 | |
715 | ldf.fill.nta f58=[r15],loc0 | |
716 | ;; | |
717 | ldf.fill.nta f66=[in0],loc0 | |
718 | ldf.fill.nta f74=[ r3],loc0 | |
719 | ldf.fill.nta f82=[r14],loc0 | |
720 | ldf.fill.nta f90=[r15],loc0 | |
721 | ;; | |
722 | ldf.fill.nta f98=[in0],loc1 | |
723 | ldf.fill.nta f106=[ r3],loc1 | |
724 | ldf.fill.nta f114=[r14],loc1 | |
725 | ldf.fill.nta f122=[r15],loc1 | |
726 | ;; | |
727 | ldf.fill.nta f35=[in0],loc0 | |
728 | ldf.fill.nta f43=[ r3],loc0 | |
729 | ldf.fill.nta f51=[r14],loc0 | |
730 | ldf.fill.nta f59=[r15],loc0 | |
731 | ;; | |
732 | ldf.fill.nta f67=[in0],loc0 | |
733 | ldf.fill.nta f75=[ r3],loc0 | |
734 | ldf.fill.nta f83=[r14],loc0 | |
735 | ldf.fill.nta f91=[r15],loc0 | |
736 | ;; | |
737 | ldf.fill.nta f99=[in0],loc1 | |
738 | ldf.fill.nta f107=[ r3],loc1 | |
739 | ldf.fill.nta f115=[r14],loc1 | |
740 | ldf.fill.nta f123=[r15],loc1 | |
741 | ;; | |
742 | ldf.fill.nta f36=[in0],loc0 | |
743 | ldf.fill.nta f44=[ r3],loc0 | |
744 | ldf.fill.nta f52=[r14],loc0 | |
745 | ldf.fill.nta f60=[r15],loc0 | |
746 | ;; | |
747 | ldf.fill.nta f68=[in0],loc0 | |
748 | ldf.fill.nta f76=[ r3],loc0 | |
749 | ldf.fill.nta f84=[r14],loc0 | |
750 | ldf.fill.nta f92=[r15],loc0 | |
751 | ;; | |
752 | ldf.fill.nta f100=[in0],loc1 | |
753 | ldf.fill.nta f108=[ r3],loc1 | |
754 | ldf.fill.nta f116=[r14],loc1 | |
755 | ldf.fill.nta f124=[r15],loc1 | |
756 | ;; | |
757 | ldf.fill.nta f37=[in0],loc0 | |
758 | ldf.fill.nta f45=[ r3],loc0 | |
759 | ldf.fill.nta f53=[r14],loc0 | |
760 | ldf.fill.nta f61=[r15],loc0 | |
761 | ;; | |
762 | ldf.fill.nta f69=[in0],loc0 | |
763 | ldf.fill.nta f77=[ r3],loc0 | |
764 | ldf.fill.nta f85=[r14],loc0 | |
765 | ldf.fill.nta f93=[r15],loc0 | |
766 | ;; | |
767 | ldf.fill.nta f101=[in0],loc1 | |
768 | ldf.fill.nta f109=[ r3],loc1 | |
769 | ldf.fill.nta f117=[r14],loc1 | |
770 | ldf.fill.nta f125=[r15],loc1 | |
771 | ;; | |
772 | ldf.fill.nta f38 =[in0],loc0 | |
773 | ldf.fill.nta f46 =[ r3],loc0 | |
774 | ldf.fill.nta f54 =[r14],loc0 | |
775 | ldf.fill.nta f62 =[r15],loc0 | |
776 | ;; | |
777 | ldf.fill.nta f70 =[in0],loc0 | |
778 | ldf.fill.nta f78 =[ r3],loc0 | |
779 | ldf.fill.nta f86 =[r14],loc0 | |
780 | ldf.fill.nta f94 =[r15],loc0 | |
781 | ;; | |
782 | ldf.fill.nta f102=[in0],loc1 | |
783 | ldf.fill.nta f110=[ r3],loc1 | |
784 | ldf.fill.nta f118=[r14],loc1 | |
785 | ldf.fill.nta f126=[r15],loc1 | |
786 | ;; | |
787 | ldf.fill.nta f39 =[in0],loc0 | |
788 | ldf.fill.nta f47 =[ r3],loc0 | |
789 | ldf.fill.nta f55 =[r14],loc0 | |
790 | ldf.fill.nta f63 =[r15],loc0 | |
791 | ;; | |
792 | ldf.fill.nta f71 =[in0],loc0 | |
793 | ldf.fill.nta f79 =[ r3],loc0 | |
794 | ldf.fill.nta f87 =[r14],loc0 | |
795 | ldf.fill.nta f95 =[r15],loc0 | |
796 | ;; | |
797 | ldf.fill.nta f103=[in0] | |
798 | ldf.fill.nta f111=[ r3] | |
799 | ldf.fill.nta f119=[r14] | |
800 | ldf.fill.nta f127=[r15] | |
801 | br.ret.sptk.many rp | |
802 | END(__ia64_load_fpu) | |
803 | ||
804 | GLOBAL_ENTRY(__ia64_init_fpu) | |
805 | stf.spill [sp]=f0 // M3 | |
806 | mov f32=f0 // F | |
807 | nop.b 0 | |
808 | ||
809 | ldfps f33,f34=[sp] // M0 | |
810 | ldfps f35,f36=[sp] // M1 | |
811 | mov f37=f0 // F | |
812 | ;; | |
813 | ||
814 | setf.s f38=r0 // M2 | |
815 | setf.s f39=r0 // M3 | |
816 | mov f40=f0 // F | |
817 | ||
818 | ldfps f41,f42=[sp] // M0 | |
819 | ldfps f43,f44=[sp] // M1 | |
820 | mov f45=f0 // F | |
821 | ||
822 | setf.s f46=r0 // M2 | |
823 | setf.s f47=r0 // M3 | |
824 | mov f48=f0 // F | |
825 | ||
826 | ldfps f49,f50=[sp] // M0 | |
827 | ldfps f51,f52=[sp] // M1 | |
828 | mov f53=f0 // F | |
829 | ||
830 | setf.s f54=r0 // M2 | |
831 | setf.s f55=r0 // M3 | |
832 | mov f56=f0 // F | |
833 | ||
834 | ldfps f57,f58=[sp] // M0 | |
835 | ldfps f59,f60=[sp] // M1 | |
836 | mov f61=f0 // F | |
837 | ||
838 | setf.s f62=r0 // M2 | |
839 | setf.s f63=r0 // M3 | |
840 | mov f64=f0 // F | |
841 | ||
842 | ldfps f65,f66=[sp] // M0 | |
843 | ldfps f67,f68=[sp] // M1 | |
844 | mov f69=f0 // F | |
845 | ||
846 | setf.s f70=r0 // M2 | |
847 | setf.s f71=r0 // M3 | |
848 | mov f72=f0 // F | |
849 | ||
850 | ldfps f73,f74=[sp] // M0 | |
851 | ldfps f75,f76=[sp] // M1 | |
852 | mov f77=f0 // F | |
853 | ||
854 | setf.s f78=r0 // M2 | |
855 | setf.s f79=r0 // M3 | |
856 | mov f80=f0 // F | |
857 | ||
858 | ldfps f81,f82=[sp] // M0 | |
859 | ldfps f83,f84=[sp] // M1 | |
860 | mov f85=f0 // F | |
861 | ||
862 | setf.s f86=r0 // M2 | |
863 | setf.s f87=r0 // M3 | |
864 | mov f88=f0 // F | |
865 | ||
866 | /* | |
867 | * When the instructions are cached, it would be faster to initialize | |
868 | * the remaining registers with simply mov instructions (F-unit). | |
869 | * This gets the time down to ~29 cycles. However, this would use up | |
870 | * 33 bundles, whereas continuing with the above pattern yields | |
871 | * 10 bundles and ~30 cycles. | |
872 | */ | |
873 | ||
874 | ldfps f89,f90=[sp] // M0 | |
875 | ldfps f91,f92=[sp] // M1 | |
876 | mov f93=f0 // F | |
877 | ||
878 | setf.s f94=r0 // M2 | |
879 | setf.s f95=r0 // M3 | |
880 | mov f96=f0 // F | |
881 | ||
882 | ldfps f97,f98=[sp] // M0 | |
883 | ldfps f99,f100=[sp] // M1 | |
884 | mov f101=f0 // F | |
885 | ||
886 | setf.s f102=r0 // M2 | |
887 | setf.s f103=r0 // M3 | |
888 | mov f104=f0 // F | |
889 | ||
890 | ldfps f105,f106=[sp] // M0 | |
891 | ldfps f107,f108=[sp] // M1 | |
892 | mov f109=f0 // F | |
893 | ||
894 | setf.s f110=r0 // M2 | |
895 | setf.s f111=r0 // M3 | |
896 | mov f112=f0 // F | |
897 | ||
898 | ldfps f113,f114=[sp] // M0 | |
899 | ldfps f115,f116=[sp] // M1 | |
900 | mov f117=f0 // F | |
901 | ||
902 | setf.s f118=r0 // M2 | |
903 | setf.s f119=r0 // M3 | |
904 | mov f120=f0 // F | |
905 | ||
906 | ldfps f121,f122=[sp] // M0 | |
907 | ldfps f123,f124=[sp] // M1 | |
908 | mov f125=f0 // F | |
909 | ||
910 | setf.s f126=r0 // M2 | |
911 | setf.s f127=r0 // M3 | |
912 | br.ret.sptk.many rp // F | |
913 | END(__ia64_init_fpu) | |
914 | ||
915 | /* | |
916 | * Switch execution mode from virtual to physical | |
917 | * | |
918 | * Inputs: | |
919 | * r16 = new psr to establish | |
920 | * Output: | |
921 | * r19 = old virtual address of ar.bsp | |
922 | * r20 = old virtual address of sp | |
923 | * | |
924 | * Note: RSE must already be in enforced lazy mode | |
925 | */ | |
926 | GLOBAL_ENTRY(ia64_switch_mode_phys) | |
927 | { | |
1da177e4 LT |
928 | rsm psr.i | psr.ic // disable interrupts and interrupt collection |
929 | mov r15=ip | |
930 | } | |
931 | ;; | |
932 | { | |
933 | flushrs // must be first insn in group | |
934 | srlz.i | |
935 | } | |
936 | ;; | |
937 | mov cr.ipsr=r16 // set new PSR | |
938 | add r3=1f-ia64_switch_mode_phys,r15 | |
939 | ||
940 | mov r19=ar.bsp | |
941 | mov r20=sp | |
942 | mov r14=rp // get return address into a general register | |
943 | ;; | |
944 | ||
945 | // going to physical mode, use tpa to translate virt->phys | |
946 | tpa r17=r19 | |
947 | tpa r3=r3 | |
948 | tpa sp=sp | |
949 | tpa r14=r14 | |
950 | ;; | |
951 | ||
952 | mov r18=ar.rnat // save ar.rnat | |
953 | mov ar.bspstore=r17 // this steps on ar.rnat | |
954 | mov cr.iip=r3 | |
955 | mov cr.ifs=r0 | |
956 | ;; | |
957 | mov ar.rnat=r18 // restore ar.rnat | |
958 | rfi // must be last insn in group | |
959 | ;; | |
960 | 1: mov rp=r14 | |
961 | br.ret.sptk.many rp | |
962 | END(ia64_switch_mode_phys) | |
963 | ||
964 | /* | |
965 | * Switch execution mode from physical to virtual | |
966 | * | |
967 | * Inputs: | |
968 | * r16 = new psr to establish | |
969 | * r19 = new bspstore to establish | |
970 | * r20 = new sp to establish | |
971 | * | |
972 | * Note: RSE must already be in enforced lazy mode | |
973 | */ | |
974 | GLOBAL_ENTRY(ia64_switch_mode_virt) | |
975 | { | |
1da177e4 LT |
976 | rsm psr.i | psr.ic // disable interrupts and interrupt collection |
977 | mov r15=ip | |
978 | } | |
979 | ;; | |
980 | { | |
981 | flushrs // must be first insn in group | |
982 | srlz.i | |
983 | } | |
984 | ;; | |
985 | mov cr.ipsr=r16 // set new PSR | |
986 | add r3=1f-ia64_switch_mode_virt,r15 | |
987 | ||
988 | mov r14=rp // get return address into a general register | |
989 | ;; | |
990 | ||
991 | // going to virtual | |
992 | // - for code addresses, set upper bits of addr to KERNEL_START | |
993 | // - for stack addresses, copy from input argument | |
994 | movl r18=KERNEL_START | |
995 | dep r3=0,r3,KERNEL_TR_PAGE_SHIFT,64-KERNEL_TR_PAGE_SHIFT | |
996 | dep r14=0,r14,KERNEL_TR_PAGE_SHIFT,64-KERNEL_TR_PAGE_SHIFT | |
997 | mov sp=r20 | |
998 | ;; | |
999 | or r3=r3,r18 | |
1000 | or r14=r14,r18 | |
1001 | ;; | |
1002 | ||
1003 | mov r18=ar.rnat // save ar.rnat | |
1004 | mov ar.bspstore=r19 // this steps on ar.rnat | |
1005 | mov cr.iip=r3 | |
1006 | mov cr.ifs=r0 | |
1007 | ;; | |
1008 | mov ar.rnat=r18 // restore ar.rnat | |
1009 | rfi // must be last insn in group | |
1010 | ;; | |
1011 | 1: mov rp=r14 | |
1012 | br.ret.sptk.many rp | |
1013 | END(ia64_switch_mode_virt) | |
1014 | ||
1015 | GLOBAL_ENTRY(ia64_delay_loop) | |
1016 | .prologue | |
1017 | { nop 0 // work around GAS unwind info generation bug... | |
1018 | .save ar.lc,r2 | |
1019 | mov r2=ar.lc | |
1020 | .body | |
1021 | ;; | |
1022 | mov ar.lc=r32 | |
1023 | } | |
1024 | ;; | |
1025 | // force loop to be 32-byte aligned (GAS bug means we cannot use .align | |
1026 | // inside function body without corrupting unwind info). | |
1027 | { nop 0 } | |
1028 | 1: br.cloop.sptk.few 1b | |
1029 | ;; | |
1030 | mov ar.lc=r2 | |
1031 | br.ret.sptk.many rp | |
1032 | END(ia64_delay_loop) | |
1033 | ||
1034 | /* | |
1035 | * Return a CPU-local timestamp in nano-seconds. This timestamp is | |
1036 | * NOT synchronized across CPUs its return value must never be | |
1037 | * compared against the values returned on another CPU. The usage in | |
1038 | * kernel/sched.c ensures that. | |
1039 | * | |
1040 | * The return-value of sched_clock() is NOT supposed to wrap-around. | |
1041 | * If it did, it would cause some scheduling hiccups (at the worst). | |
1042 | * Fortunately, with a 64-bit cycle-counter ticking at 100GHz, even | |
1043 | * that would happen only once every 5+ years. | |
1044 | * | |
1045 | * The code below basically calculates: | |
1046 | * | |
1047 | * (ia64_get_itc() * local_cpu_data->nsec_per_cyc) >> IA64_NSEC_PER_CYC_SHIFT | |
1048 | * | |
1049 | * except that the multiplication and the shift are done with 128-bit | |
1050 | * intermediate precision so that we can produce a full 64-bit result. | |
1051 | */ | |
1052 | GLOBAL_ENTRY(sched_clock) | |
1053 | addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0 | |
1054 | mov.m r9=ar.itc // fetch cycle-counter (35 cyc) | |
1055 | ;; | |
1056 | ldf8 f8=[r8] | |
1057 | ;; | |
1058 | setf.sig f9=r9 // certain to stall, so issue it _after_ ldf8... | |
1059 | ;; | |
1060 | xmpy.lu f10=f9,f8 // calculate low 64 bits of 128-bit product (4 cyc) | |
1061 | xmpy.hu f11=f9,f8 // calculate high 64 bits of 128-bit product | |
1062 | ;; | |
1063 | getf.sig r8=f10 // (5 cyc) | |
1064 | getf.sig r9=f11 | |
1065 | ;; | |
1066 | shrp r8=r9,r8,IA64_NSEC_PER_CYC_SHIFT | |
1067 | br.ret.sptk.many rp | |
1068 | END(sched_clock) | |
1069 | ||
b64f34cd HS |
1070 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
1071 | GLOBAL_ENTRY(cycle_to_cputime) | |
1072 | alloc r16=ar.pfs,1,0,0,0 | |
1073 | addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0 | |
1074 | ;; | |
1075 | ldf8 f8=[r8] | |
1076 | ;; | |
1077 | setf.sig f9=r32 | |
1078 | ;; | |
1079 | xmpy.lu f10=f9,f8 // calculate low 64 bits of 128-bit product (4 cyc) | |
1080 | xmpy.hu f11=f9,f8 // calculate high 64 bits of 128-bit product | |
1081 | ;; | |
1082 | getf.sig r8=f10 // (5 cyc) | |
1083 | getf.sig r9=f11 | |
1084 | ;; | |
1085 | shrp r8=r9,r8,IA64_NSEC_PER_CYC_SHIFT | |
1086 | br.ret.sptk.many rp | |
1087 | END(cycle_to_cputime) | |
1088 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | |
1089 | ||
1da177e4 LT |
1090 | GLOBAL_ENTRY(start_kernel_thread) |
1091 | .prologue | |
1092 | .save rp, r0 // this is the end of the call-chain | |
1093 | .body | |
1094 | alloc r2 = ar.pfs, 0, 0, 2, 0 | |
1095 | mov out0 = r9 | |
1096 | mov out1 = r11;; | |
1097 | br.call.sptk.many rp = kernel_thread_helper;; | |
1098 | mov out0 = r8 | |
1099 | br.call.sptk.many rp = sys_exit;; | |
1100 | 1: br.sptk.few 1b // not reached | |
1101 | END(start_kernel_thread) | |
1102 | ||
1103 | #ifdef CONFIG_IA64_BRL_EMU | |
1104 | ||
1105 | /* | |
1106 | * Assembly routines used by brl_emu.c to set preserved register state. | |
1107 | */ | |
1108 | ||
1109 | #define SET_REG(reg) \ | |
1110 | GLOBAL_ENTRY(ia64_set_##reg); \ | |
1111 | alloc r16=ar.pfs,1,0,0,0; \ | |
1112 | mov reg=r32; \ | |
1113 | ;; \ | |
1114 | br.ret.sptk.many rp; \ | |
1115 | END(ia64_set_##reg) | |
1116 | ||
1117 | SET_REG(b1); | |
1118 | SET_REG(b2); | |
1119 | SET_REG(b3); | |
1120 | SET_REG(b4); | |
1121 | SET_REG(b5); | |
1122 | ||
1123 | #endif /* CONFIG_IA64_BRL_EMU */ | |
1124 | ||
1125 | #ifdef CONFIG_SMP | |
1126 | /* | |
1127 | * This routine handles spinlock contention. It uses a non-standard calling | |
1128 | * convention to avoid converting leaf routines into interior routines. Because | |
1129 | * of this special convention, there are several restrictions: | |
1130 | * | |
1131 | * - do not use gp relative variables, this code is called from the kernel | |
1132 | * and from modules, r1 is undefined. | |
1133 | * - do not use stacked registers, the caller owns them. | |
1134 | * - do not use the scratch stack space, the caller owns it. | |
1135 | * - do not use any registers other than the ones listed below | |
1136 | * | |
1137 | * Inputs: | |
1138 | * ar.pfs - saved CFM of caller | |
1139 | * ar.ccv - 0 (and available for use) | |
1140 | * r27 - flags from spin_lock_irqsave or 0. Must be preserved. | |
1141 | * r28 - available for use. | |
1142 | * r29 - available for use. | |
1143 | * r30 - available for use. | |
1144 | * r31 - address of lock, available for use. | |
1145 | * b6 - return address | |
1146 | * p14 - available for use. | |
1147 | * p15 - used to track flag status. | |
1148 | * | |
1149 | * If you patch this code to use more registers, do not forget to update | |
7f30491c | 1150 | * the clobber lists for spin_lock() in arch/ia64/include/asm/spinlock.h. |
1da177e4 LT |
1151 | */ |
1152 | ||
a1365647 | 1153 | #if (__GNUC__ == 3 && __GNUC_MINOR__ < 3) |
1da177e4 LT |
1154 | |
1155 | GLOBAL_ENTRY(ia64_spinlock_contention_pre3_4) | |
1156 | .prologue | |
1157 | .save ar.pfs, r0 // this code effectively has a zero frame size | |
1158 | .save rp, r28 | |
1159 | .body | |
1160 | nop 0 | |
1161 | tbit.nz p15,p0=r27,IA64_PSR_I_BIT | |
1162 | .restore sp // pop existing prologue after next insn | |
1163 | mov b6 = r28 | |
1164 | .prologue | |
1165 | .save ar.pfs, r0 | |
1166 | .altrp b6 | |
1167 | .body | |
1168 | ;; | |
1169 | (p15) ssm psr.i // reenable interrupts if they were on | |
1170 | // DavidM says that srlz.d is slow and is not required in this case | |
1171 | .wait: | |
1172 | // exponential backoff, kdb, lockmeter etc. go in here | |
1173 | hint @pause | |
1174 | ld4 r30=[r31] // don't use ld4.bias; if it's contended, we won't write the word | |
1175 | nop 0 | |
1176 | ;; | |
1177 | cmp4.ne p14,p0=r30,r0 | |
1178 | (p14) br.cond.sptk.few .wait | |
1179 | (p15) rsm psr.i // disable interrupts if we reenabled them | |
1180 | br.cond.sptk.few b6 // lock is now free, try to acquire | |
1181 | .global ia64_spinlock_contention_pre3_4_end // for kernprof | |
1182 | ia64_spinlock_contention_pre3_4_end: | |
1183 | END(ia64_spinlock_contention_pre3_4) | |
1184 | ||
1185 | #else | |
1186 | ||
1187 | GLOBAL_ENTRY(ia64_spinlock_contention) | |
1188 | .prologue | |
1189 | .altrp b6 | |
1190 | .body | |
1191 | tbit.nz p15,p0=r27,IA64_PSR_I_BIT | |
1192 | ;; | |
1193 | .wait: | |
1194 | (p15) ssm psr.i // reenable interrupts if they were on | |
1195 | // DavidM says that srlz.d is slow and is not required in this case | |
1196 | .wait2: | |
1197 | // exponential backoff, kdb, lockmeter etc. go in here | |
1198 | hint @pause | |
1199 | ld4 r30=[r31] // don't use ld4.bias; if it's contended, we won't write the word | |
1200 | ;; | |
1201 | cmp4.ne p14,p0=r30,r0 | |
1202 | mov r30 = 1 | |
1203 | (p14) br.cond.sptk.few .wait2 | |
1204 | (p15) rsm psr.i // disable interrupts if we reenabled them | |
1205 | ;; | |
1206 | cmpxchg4.acq r30=[r31], r30, ar.ccv | |
1207 | ;; | |
1208 | cmp4.ne p14,p0=r0,r30 | |
1209 | (p14) br.cond.sptk.few .wait | |
1210 | ||
1211 | br.ret.sptk.many b6 // lock is now taken | |
1212 | END(ia64_spinlock_contention) | |
1213 | ||
1214 | #endif | |
1215 | ||
b8d8b883 AR |
1216 | #ifdef CONFIG_HOTPLUG_CPU |
1217 | GLOBAL_ENTRY(ia64_jump_to_sal) | |
1218 | alloc r16=ar.pfs,1,0,0,0;; | |
1219 | rsm psr.i | psr.ic | |
1220 | { | |
1221 | flushrs | |
1222 | srlz.i | |
1223 | } | |
1224 | tpa r25=in0 | |
1225 | movl r18=tlb_purge_done;; | |
1226 | DATA_VA_TO_PA(r18);; | |
1227 | mov b1=r18 // Return location | |
1228 | movl r18=ia64_do_tlb_purge;; | |
1229 | DATA_VA_TO_PA(r18);; | |
1230 | mov b2=r18 // doing tlb_flush work | |
1231 | mov ar.rsc=0 // Put RSE in enforced lazy, LE mode | |
1232 | movl r17=1f;; | |
1233 | DATA_VA_TO_PA(r17);; | |
1234 | mov cr.iip=r17 | |
1235 | movl r16=SAL_PSR_BITS_TO_SET;; | |
1236 | mov cr.ipsr=r16 | |
1237 | mov cr.ifs=r0;; | |
1238 | rfi;; | |
1239 | 1: | |
1240 | /* | |
1241 | * Invalidate all TLB data/inst | |
1242 | */ | |
1243 | br.sptk.many b2;; // jump to tlb purge code | |
1244 | ||
1245 | tlb_purge_done: | |
1246 | RESTORE_REGION_REGS(r25, r17,r18,r19);; | |
1247 | RESTORE_REG(b0, r25, r17);; | |
1248 | RESTORE_REG(b1, r25, r17);; | |
1249 | RESTORE_REG(b2, r25, r17);; | |
1250 | RESTORE_REG(b3, r25, r17);; | |
1251 | RESTORE_REG(b4, r25, r17);; | |
1252 | RESTORE_REG(b5, r25, r17);; | |
1253 | ld8 r1=[r25],0x08;; | |
1254 | ld8 r12=[r25],0x08;; | |
1255 | ld8 r13=[r25],0x08;; | |
1256 | RESTORE_REG(ar.fpsr, r25, r17);; | |
1257 | RESTORE_REG(ar.pfs, r25, r17);; | |
1258 | RESTORE_REG(ar.rnat, r25, r17);; | |
1259 | RESTORE_REG(ar.unat, r25, r17);; | |
1260 | RESTORE_REG(ar.bspstore, r25, r17);; | |
1261 | RESTORE_REG(cr.dcr, r25, r17);; | |
1262 | RESTORE_REG(cr.iva, r25, r17);; | |
1263 | RESTORE_REG(cr.pta, r25, r17);; | |
09106228 | 1264 | srlz.d;; // required not to violate RAW dependency |
b8d8b883 AR |
1265 | RESTORE_REG(cr.itv, r25, r17);; |
1266 | RESTORE_REG(cr.pmv, r25, r17);; | |
1267 | RESTORE_REG(cr.cmcv, r25, r17);; | |
1268 | RESTORE_REG(cr.lrr0, r25, r17);; | |
1269 | RESTORE_REG(cr.lrr1, r25, r17);; | |
1270 | ld8 r4=[r25],0x08;; | |
1271 | ld8 r5=[r25],0x08;; | |
1272 | ld8 r6=[r25],0x08;; | |
1273 | ld8 r7=[r25],0x08;; | |
1274 | ld8 r17=[r25],0x08;; | |
1275 | mov pr=r17,-1;; | |
1276 | RESTORE_REG(ar.lc, r25, r17);; | |
1277 | /* | |
1278 | * Now Restore floating point regs | |
1279 | */ | |
1280 | ldf.fill.nta f2=[r25],16;; | |
1281 | ldf.fill.nta f3=[r25],16;; | |
1282 | ldf.fill.nta f4=[r25],16;; | |
1283 | ldf.fill.nta f5=[r25],16;; | |
1284 | ldf.fill.nta f16=[r25],16;; | |
1285 | ldf.fill.nta f17=[r25],16;; | |
1286 | ldf.fill.nta f18=[r25],16;; | |
1287 | ldf.fill.nta f19=[r25],16;; | |
1288 | ldf.fill.nta f20=[r25],16;; | |
1289 | ldf.fill.nta f21=[r25],16;; | |
1290 | ldf.fill.nta f22=[r25],16;; | |
1291 | ldf.fill.nta f23=[r25],16;; | |
1292 | ldf.fill.nta f24=[r25],16;; | |
1293 | ldf.fill.nta f25=[r25],16;; | |
1294 | ldf.fill.nta f26=[r25],16;; | |
1295 | ldf.fill.nta f27=[r25],16;; | |
1296 | ldf.fill.nta f28=[r25],16;; | |
1297 | ldf.fill.nta f29=[r25],16;; | |
1298 | ldf.fill.nta f30=[r25],16;; | |
1299 | ldf.fill.nta f31=[r25],16;; | |
1300 | ||
1301 | /* | |
1302 | * Now that we have done all the register restores | |
1303 | * we are now ready for the big DIVE to SAL Land | |
1304 | */ | |
1305 | ssm psr.ic;; | |
1306 | srlz.d;; | |
1307 | br.ret.sptk.many b0;; | |
1308 | END(ia64_jump_to_sal) | |
1309 | #endif /* CONFIG_HOTPLUG_CPU */ | |
1310 | ||
1da177e4 | 1311 | #endif /* CONFIG_SMP */ |