blob: c1bd1feffab09dca071d32900f66524cac5aacc3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001//
2// assembly portion of the IA64 MCA handling
3//
4// Mods by cfleck to integrate into kernel build
5// 00/03/15 davidm Added various stop bits to get a clean compile
6//
7// 00/03/29 cfleck Added code to save INIT handoff state in pt_regs format, switch to temp
8// kstack, switch modes, jump to C INIT handler
9//
10// 02/01/04 J.Hall <jenna.s.hall@intel.com>
11// Before entering virtual mode code:
12// 1. Check for TLB CPU error
13// 2. Restore current thread pointer to kr6
14// 3. Move stack ptr 16 bytes to conform to C calling convention
15//
16// 04/11/12 Russ Anderson <rja@sgi.com>
17// Added per cpu MCA/INIT stack save areas.
18//
Keith Owens7f613c72005-09-11 17:22:53 +100019// 12/08/05 Keith Owens <kaos@sgi.com>
20// Use per cpu MCA/INIT stacks for all data.
21//
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/config.h>
23#include <linux/threads.h>
24
25#include <asm/asmmacro.h>
26#include <asm/pgtable.h>
27#include <asm/processor.h>
28#include <asm/mca_asm.h>
29#include <asm/mca.h>
30
Keith Owens7f613c72005-09-11 17:22:53 +100031#include "entry.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#define GET_IA64_MCA_DATA(reg) \
34 GET_THIS_PADDR(reg, ia64_mca_data) \
35 ;; \
36 ld8 reg=[reg]
37
Ashok Rajb8d8b882005-04-22 14:44:40 -070038 .global ia64_do_tlb_purge
Keith Owens7f613c72005-09-11 17:22:53 +100039 .global ia64_os_mca_dispatch
40 .global ia64_os_init_dispatch_monarch
41 .global ia64_os_init_dispatch_slave
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43 .text
44 .align 16
45
Keith Owens7f613c72005-09-11 17:22:53 +100046//StartMain////////////////////////////////////////////////////////////////////
47
Ashok Rajb8d8b882005-04-22 14:44:40 -070048/*
49 * Just the TLB purge part is moved to a separate function
50 * so we can re-use the code for cpu hotplug code as well
51 * Caller should now setup b1, so we can branch once the
52 * tlb flush is complete.
53 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Ashok Rajb8d8b882005-04-22 14:44:40 -070055ia64_do_tlb_purge:
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define O(member) IA64_CPUINFO_##member##_OFFSET
57
58 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
59 ;;
60 addl r17=O(PTCE_STRIDE),r2
61 addl r2=O(PTCE_BASE),r2
62 ;;
63 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
64 ld4 r19=[r2],4 // r19=ptce_count[0]
65 ld4 r21=[r17],4 // r21=ptce_stride[0]
66 ;;
67 ld4 r20=[r2] // r20=ptce_count[1]
68 ld4 r22=[r17] // r22=ptce_stride[1]
69 mov r24=0
70 ;;
71 adds r20=-1,r20
72 ;;
73#undef O
74
752:
76 cmp.ltu p6,p7=r24,r19
77(p7) br.cond.dpnt.few 4f
78 mov ar.lc=r20
793:
80 ptc.e r18
81 ;;
82 add r18=r22,r18
83 br.cloop.sptk.few 3b
84 ;;
85 add r18=r21,r18
86 add r24=1,r24
87 ;;
88 br.sptk.few 2b
894:
90 srlz.i // srlz.i implies srlz.d
91 ;;
92
93 // Now purge addresses formerly mapped by TR registers
94 // 1. Purge ITR&DTR for kernel.
95 movl r16=KERNEL_START
96 mov r18=KERNEL_TR_PAGE_SHIFT<<2
97 ;;
98 ptr.i r16, r18
99 ptr.d r16, r18
100 ;;
101 srlz.i
102 ;;
103 srlz.d
104 ;;
105 // 2. Purge DTR for PERCPU data.
106 movl r16=PERCPU_ADDR
107 mov r18=PERCPU_PAGE_SHIFT<<2
108 ;;
109 ptr.d r16,r18
110 ;;
111 srlz.d
112 ;;
113 // 3. Purge ITR for PAL code.
114 GET_THIS_PADDR(r2, ia64_mca_pal_base)
115 ;;
116 ld8 r16=[r2]
117 mov r18=IA64_GRANULE_SHIFT<<2
118 ;;
119 ptr.i r16,r18
120 ;;
121 srlz.i
122 ;;
123 // 4. Purge DTR for stack.
124 mov r16=IA64_KR(CURRENT_STACK)
125 ;;
126 shl r16=r16,IA64_GRANULE_SHIFT
127 movl r19=PAGE_OFFSET
128 ;;
129 add r16=r19,r16
130 mov r18=IA64_GRANULE_SHIFT<<2
131 ;;
132 ptr.d r16,r18
133 ;;
134 srlz.i
135 ;;
Ashok Rajb8d8b882005-04-22 14:44:40 -0700136 // Now branch away to caller.
137 br.sptk.many b1
138 ;;
139
Keith Owens7f613c72005-09-11 17:22:53 +1000140//EndMain//////////////////////////////////////////////////////////////////////
Ashok Rajb8d8b882005-04-22 14:44:40 -0700141
Keith Owens7f613c72005-09-11 17:22:53 +1000142//StartMain////////////////////////////////////////////////////////////////////
143
144ia64_os_mca_dispatch:
Ashok Rajb8d8b882005-04-22 14:44:40 -0700145 // Serialize all MCA processing
146 mov r3=1;;
147 LOAD_PHYSICAL(p0,r2,ia64_mca_serialize);;
148ia64_os_mca_spin:
Keith Owens7f613c72005-09-11 17:22:53 +1000149 xchg4 r4=[r2],r3;;
Ashok Rajb8d8b882005-04-22 14:44:40 -0700150 cmp.ne p6,p0=r4,r0
151(p6) br ia64_os_mca_spin
152
Keith Owens7f613c72005-09-11 17:22:53 +1000153 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
154 LOAD_PHYSICAL(p0,r2,1f) // return address
155 mov r19=1 // All MCA events are treated as monarch (for now)
156 br.sptk ia64_state_save // save the state that is not in minstate
1571:
158
159 GET_IA64_MCA_DATA(r2)
160 // Using MCA stack, struct ia64_sal_os_state, variable proc_state_param
Ashok Rajb8d8b882005-04-22 14:44:40 -0700161 ;;
Keith Owensd270acb2006-04-07 18:08:11 +1000162 add r3=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET+SOS(PROC_STATE_PARAM), r2
Ashok Rajb8d8b882005-04-22 14:44:40 -0700163 ;;
Keith Owens7f613c72005-09-11 17:22:53 +1000164 ld8 r18=[r3] // Get processor state parameter on existing PALE_CHECK.
Ashok Rajb8d8b882005-04-22 14:44:40 -0700165 ;;
166 tbit.nz p6,p7=r18,60
167(p7) br.spnt done_tlb_purge_and_reload
168
169 // The following code purges TC and TR entries. Then reload all TC entries.
170 // Purge percpu data TC entries.
171begin_tlb_purge_and_reload:
172 movl r18=ia64_reload_tr;;
173 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
174 mov b1=r18;;
175 br.sptk.many ia64_do_tlb_purge;;
176
177ia64_reload_tr:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 // Finally reload the TR registers.
179 // 1. Reload DTR/ITR registers for kernel.
180 mov r18=KERNEL_TR_PAGE_SHIFT<<2
181 movl r17=KERNEL_START
182 ;;
183 mov cr.itir=r18
184 mov cr.ifa=r17
185 mov r16=IA64_TR_KERNEL
186 mov r19=ip
187 movl r18=PAGE_KERNEL
188 ;;
189 dep r17=0,r19,0, KERNEL_TR_PAGE_SHIFT
190 ;;
191 or r18=r17,r18
192 ;;
193 itr.i itr[r16]=r18
194 ;;
195 itr.d dtr[r16]=r18
196 ;;
197 srlz.i
198 srlz.d
199 ;;
200 // 2. Reload DTR register for PERCPU data.
201 GET_THIS_PADDR(r2, ia64_mca_per_cpu_pte)
202 ;;
203 movl r16=PERCPU_ADDR // vaddr
204 movl r18=PERCPU_PAGE_SHIFT<<2
205 ;;
206 mov cr.itir=r18
207 mov cr.ifa=r16
208 ;;
209 ld8 r18=[r2] // load per-CPU PTE
210 mov r16=IA64_TR_PERCPU_DATA;
211 ;;
212 itr.d dtr[r16]=r18
213 ;;
214 srlz.d
215 ;;
216 // 3. Reload ITR for PAL code.
217 GET_THIS_PADDR(r2, ia64_mca_pal_pte)
218 ;;
219 ld8 r18=[r2] // load PAL PTE
220 ;;
221 GET_THIS_PADDR(r2, ia64_mca_pal_base)
222 ;;
223 ld8 r16=[r2] // load PAL vaddr
224 mov r19=IA64_GRANULE_SHIFT<<2
225 ;;
226 mov cr.itir=r19
227 mov cr.ifa=r16
228 mov r20=IA64_TR_PALCODE
229 ;;
230 itr.i itr[r20]=r18
231 ;;
232 srlz.i
233 ;;
234 // 4. Reload DTR for stack.
235 mov r16=IA64_KR(CURRENT_STACK)
236 ;;
237 shl r16=r16,IA64_GRANULE_SHIFT
238 movl r19=PAGE_OFFSET
239 ;;
240 add r18=r19,r16
241 movl r20=PAGE_KERNEL
242 ;;
243 add r16=r20,r16
244 mov r19=IA64_GRANULE_SHIFT<<2
245 ;;
246 mov cr.itir=r19
247 mov cr.ifa=r18
248 mov r20=IA64_TR_CURRENT_STACK
249 ;;
250 itr.d dtr[r20]=r16
251 ;;
252 srlz.d
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254done_tlb_purge_and_reload:
255
Keith Owens7f613c72005-09-11 17:22:53 +1000256 // switch to per cpu MCA stack
257 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
258 LOAD_PHYSICAL(p0,r2,1f) // return address
259 br.sptk ia64_new_stack
2601:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Keith Owens7f613c72005-09-11 17:22:53 +1000262 // everything saved, now we can set the kernel registers
263 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
264 LOAD_PHYSICAL(p0,r2,1f) // return address
265 br.sptk ia64_set_kernel_registers
2661:
267
268 // This must be done in physical mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 GET_IA64_MCA_DATA(r2)
270 ;;
Keith Owens7f613c72005-09-11 17:22:53 +1000271 mov r7=r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 // Enter virtual mode from physical mode
274 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_begin, r4)
Keith Owens7f613c72005-09-11 17:22:53 +1000275
276 // This code returns to SAL via SOS r2, in general SAL has no unwind
277 // data. To get a clean termination when backtracing the C MCA/INIT
278 // handler, set a dummy return address of 0 in this routine. That
279 // requires that ia64_os_mca_virtual_begin be a global function.
280ENTRY(ia64_os_mca_virtual_begin)
281 .prologue
282 .save rp,r0
283 .body
284
285 mov ar.rsc=3 // set eager mode for C handler
286 mov r2=r7 // see GET_IA64_MCA_DATA above
287 ;;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
289 // Call virtual mode handler
Keith Owens7f613c72005-09-11 17:22:53 +1000290 alloc r14=ar.pfs,0,0,3,0
291 ;;
292 DATA_PA_TO_VA(r2,r7)
293 ;;
294 add out0=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
295 add out1=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
296 add out2=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET, r2
297 br.call.sptk.many b0=ia64_mca_handler
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 // Revert back to physical mode before going back to SAL
300 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_end, r4)
301ia64_os_mca_virtual_end:
302
Keith Owens7f613c72005-09-11 17:22:53 +1000303END(ia64_os_mca_virtual_begin)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Keith Owens7f613c72005-09-11 17:22:53 +1000305 // switch back to previous stack
306 alloc r14=ar.pfs,0,0,0,0 // remove the MCA handler frame
307 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
308 LOAD_PHYSICAL(p0,r2,1f) // return address
309 br.sptk ia64_old_stack
3101:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Keith Owens7f613c72005-09-11 17:22:53 +1000312 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
313 LOAD_PHYSICAL(p0,r2,1f) // return address
314 br.sptk ia64_state_restore // restore the SAL state
3151:
316
317 mov b0=r12 // SAL_CHECK return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 // release lock
Keith Owens7f613c72005-09-11 17:22:53 +1000320 LOAD_PHYSICAL(p0,r3,ia64_mca_serialize);;
321 st4.rel [r3]=r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 br b0
Keith Owens7f613c72005-09-11 17:22:53 +1000324
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325//EndMain//////////////////////////////////////////////////////////////////////
326
Keith Owens7f613c72005-09-11 17:22:53 +1000327//StartMain////////////////////////////////////////////////////////////////////
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329//
Keith Owens7f613c72005-09-11 17:22:53 +1000330// SAL to OS entry point for INIT on all processors. This has been defined for
331// registration purposes with SAL as a part of ia64_mca_init. Monarch and
332// slave INIT have identical processing, except for the value of the
333// sos->monarch flag in r19.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334//
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Keith Owens7f613c72005-09-11 17:22:53 +1000336ia64_os_init_dispatch_monarch:
337 mov r19=1 // Bow, bow, ye lower middle classes!
338 br.sptk ia64_os_init_dispatch
339
340ia64_os_init_dispatch_slave:
341 mov r19=0 // <igor>yeth, mathter</igor>
342
343ia64_os_init_dispatch:
344
345 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
346 LOAD_PHYSICAL(p0,r2,1f) // return address
347 br.sptk ia64_state_save // save the state that is not in minstate
3481:
349
350 // switch to per cpu INIT stack
351 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
352 LOAD_PHYSICAL(p0,r2,1f) // return address
353 br.sptk ia64_new_stack
3541:
355
356 // everything saved, now we can set the kernel registers
357 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
358 LOAD_PHYSICAL(p0,r2,1f) // return address
359 br.sptk ia64_set_kernel_registers
3601:
361
362 // This must be done in physical mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 GET_IA64_MCA_DATA(r2)
364 ;;
Keith Owens7f613c72005-09-11 17:22:53 +1000365 mov r7=r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Keith Owens7f613c72005-09-11 17:22:53 +1000367 // Enter virtual mode from physical mode
368 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_begin, r4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
Keith Owens7f613c72005-09-11 17:22:53 +1000370 // This code returns to SAL via SOS r2, in general SAL has no unwind
371 // data. To get a clean termination when backtracing the C MCA/INIT
372 // handler, set a dummy return address of 0 in this routine. That
373 // requires that ia64_os_init_virtual_begin be a global function.
374ENTRY(ia64_os_init_virtual_begin)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 .prologue
Keith Owens7f613c72005-09-11 17:22:53 +1000376 .save rp,r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 .body
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
Keith Owens7f613c72005-09-11 17:22:53 +1000379 mov ar.rsc=3 // set eager mode for C handler
380 mov r2=r7 // see GET_IA64_MCA_DATA above
381 ;;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
Keith Owens7f613c72005-09-11 17:22:53 +1000383 // Call virtual mode handler
384 alloc r14=ar.pfs,0,0,3,0
385 ;;
386 DATA_PA_TO_VA(r2,r7)
387 ;;
388 add out0=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
389 add out1=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
390 add out2=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SOS_OFFSET, r2
391 br.call.sptk.many b0=ia64_init_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Keith Owens7f613c72005-09-11 17:22:53 +1000393 // Revert back to physical mode before going back to SAL
394 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_end, r4)
395ia64_os_init_virtual_end:
396
397END(ia64_os_init_virtual_begin)
398
399 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
400 LOAD_PHYSICAL(p0,r2,1f) // return address
401 br.sptk ia64_state_restore // restore the SAL state
4021:
403
404 // switch back to previous stack
405 alloc r14=ar.pfs,0,0,0,0 // remove the INIT handler frame
406 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
407 LOAD_PHYSICAL(p0,r2,1f) // return address
408 br.sptk ia64_old_stack
4091:
410
411 mov b0=r12 // SAL_CHECK return address
412 br b0
413
414//EndMain//////////////////////////////////////////////////////////////////////
415
416// common defines for the stubs
417#define ms r4
418#define regs r5
419#define temp1 r2 /* careful, it overlaps with input registers */
420#define temp2 r3 /* careful, it overlaps with input registers */
421#define temp3 r7
422#define temp4 r14
423
424
425//++
426// Name:
427// ia64_state_save()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428//
Keith Owens7f613c72005-09-11 17:22:53 +1000429// Stub Description:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430//
Keith Owens7f613c72005-09-11 17:22:53 +1000431// Save the state that is not in minstate. This is sensitive to the layout of
432// struct ia64_sal_os_state in mca.h.
433//
434// r2 contains the return address, r3 contains either
435// IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
436//
437// The OS to SAL section of struct ia64_sal_os_state is set to a default
438// value of cold boot (MCA) or warm boot (INIT) and return to the same
439// context. ia64_sal_os_state is also used to hold some registers that
440// need to be saved and restored across the stack switches.
441//
442// Most input registers to this stub come from PAL/SAL
443// r1 os gp, physical
444// r8 pal_proc entry point
445// r9 sal_proc entry point
446// r10 sal gp
447// r11 MCA - rendevzous state, INIT - reason code
448// r12 sal return address
449// r17 pal min_state
450// r18 processor state parameter
451// r19 monarch flag, set by the caller of this routine
452//
453// In addition to the SAL to OS state, this routine saves all the
454// registers that appear in struct pt_regs and struct switch_stack,
455// excluding those that are already in the PAL minstate area. This
456// results in a partial pt_regs and switch_stack, the C code copies the
457// remaining registers from PAL minstate to pt_regs and switch_stack. The
458// resulting structures contain all the state of the original process when
459// MCA/INIT occurred.
460//
461//--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
Keith Owens7f613c72005-09-11 17:22:53 +1000463ia64_state_save:
464 add regs=MCA_SOS_OFFSET, r3
465 add ms=MCA_SOS_OFFSET+8, r3
466 mov b0=r2 // save return address
467 cmp.eq p1,p2=IA64_MCA_CPU_MCA_STACK_OFFSET, r3
468 ;;
469 GET_IA64_MCA_DATA(temp2)
470 ;;
471 add temp1=temp2, regs // struct ia64_sal_os_state on MCA or INIT stack
472 add temp2=temp2, ms // struct ia64_sal_os_state+8 on MCA or INIT stack
473 ;;
474 mov regs=temp1 // save the start of sos
475 st8 [temp1]=r1,16 // os_gp
476 st8 [temp2]=r8,16 // pal_proc
477 ;;
478 st8 [temp1]=r9,16 // sal_proc
479 st8 [temp2]=r11,16 // rv_rc
480 mov r11=cr.iipa
481 ;;
Keith Owensd270acb2006-04-07 18:08:11 +1000482 st8 [temp1]=r18 // proc_state_param
483 st8 [temp2]=r19 // monarch
Keith Owens7f613c72005-09-11 17:22:53 +1000484 mov r6=IA64_KR(CURRENT)
Keith Owensd270acb2006-04-07 18:08:11 +1000485 add temp1=SOS(SAL_RA), regs
486 add temp2=SOS(SAL_GP), regs
Keith Owens7f613c72005-09-11 17:22:53 +1000487 ;;
488 st8 [temp1]=r12,16 // sal_ra
489 st8 [temp2]=r10,16 // sal_gp
490 mov r12=cr.isr
491 ;;
492 st8 [temp1]=r17,16 // pal_min_state
493 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
Keith Owens20bb8682005-09-22 18:49:15 +1000494 mov r6=IA64_KR(CURRENT_STACK)
495 ;;
496 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
497 st8 [temp2]=r0,16 // prev_task, starts off as NULL
Keith Owens7f613c72005-09-11 17:22:53 +1000498 mov r6=cr.ifa
499 ;;
Keith Owens20bb8682005-09-22 18:49:15 +1000500 st8 [temp1]=r12,16 // cr.isr
501 st8 [temp2]=r6,16 // cr.ifa
Keith Owens7f613c72005-09-11 17:22:53 +1000502 mov r12=cr.itir
503 ;;
Keith Owens20bb8682005-09-22 18:49:15 +1000504 st8 [temp1]=r12,16 // cr.itir
505 st8 [temp2]=r11,16 // cr.iipa
Keith Owens7f613c72005-09-11 17:22:53 +1000506 mov r12=cr.iim
507 ;;
Keith Owensd270acb2006-04-07 18:08:11 +1000508 st8 [temp1]=r12 // cr.iim
Keith Owens7f613c72005-09-11 17:22:53 +1000509(p1) mov r12=IA64_MCA_COLD_BOOT
510(p2) mov r12=IA64_INIT_WARM_BOOT
Keith Owens20bb8682005-09-22 18:49:15 +1000511 mov r6=cr.iha
Keith Owensd270acb2006-04-07 18:08:11 +1000512 add temp1=SOS(OS_STATUS), regs
Keith Owens7f613c72005-09-11 17:22:53 +1000513 ;;
Keith Owensd270acb2006-04-07 18:08:11 +1000514 st8 [temp2]=r6 // cr.iha
515 add temp2=SOS(CONTEXT), regs
Keith Owens20bb8682005-09-22 18:49:15 +1000516 st8 [temp1]=r12 // os_status, default is cold boot
Keith Owens7f613c72005-09-11 17:22:53 +1000517 mov r6=IA64_MCA_SAME_CONTEXT
518 ;;
Keith Owens2a792052006-01-24 12:31:26 +1100519 st8 [temp2]=r6 // context, default is same context
Keith Owens7f613c72005-09-11 17:22:53 +1000520
521 // Save the pt_regs data that is not in minstate. The previous code
522 // left regs at sos.
523 add regs=MCA_PT_REGS_OFFSET-MCA_SOS_OFFSET, regs
524 ;;
525 add temp1=PT(B6), regs
526 mov temp3=b6
527 mov temp4=b7
528 add temp2=PT(B7), regs
529 ;;
530 st8 [temp1]=temp3,PT(AR_CSD)-PT(B6) // save b6
531 st8 [temp2]=temp4,PT(AR_SSD)-PT(B7) // save b7
532 mov temp3=ar.csd
533 mov temp4=ar.ssd
534 cover // must be last in group
535 ;;
536 st8 [temp1]=temp3,PT(AR_UNAT)-PT(AR_CSD) // save ar.csd
537 st8 [temp2]=temp4,PT(AR_PFS)-PT(AR_SSD) // save ar.ssd
538 mov temp3=ar.unat
539 mov temp4=ar.pfs
540 ;;
541 st8 [temp1]=temp3,PT(AR_RNAT)-PT(AR_UNAT) // save ar.unat
542 st8 [temp2]=temp4,PT(AR_BSPSTORE)-PT(AR_PFS) // save ar.pfs
543 mov temp3=ar.rnat
544 mov temp4=ar.bspstore
545 ;;
546 st8 [temp1]=temp3,PT(LOADRS)-PT(AR_RNAT) // save ar.rnat
547 st8 [temp2]=temp4,PT(AR_FPSR)-PT(AR_BSPSTORE) // save ar.bspstore
548 mov temp3=ar.bsp
549 ;;
550 sub temp3=temp3, temp4 // ar.bsp - ar.bspstore
551 mov temp4=ar.fpsr
552 ;;
553 shl temp3=temp3,16 // compute ar.rsc to be used for "loadrs"
554 ;;
555 st8 [temp1]=temp3,PT(AR_CCV)-PT(LOADRS) // save loadrs
556 st8 [temp2]=temp4,PT(F6)-PT(AR_FPSR) // save ar.fpsr
557 mov temp3=ar.ccv
558 ;;
559 st8 [temp1]=temp3,PT(F7)-PT(AR_CCV) // save ar.ccv
560 stf.spill [temp2]=f6,PT(F8)-PT(F6)
561 ;;
562 stf.spill [temp1]=f7,PT(F9)-PT(F7)
563 stf.spill [temp2]=f8,PT(F10)-PT(F8)
564 ;;
565 stf.spill [temp1]=f9,PT(F11)-PT(F9)
566 stf.spill [temp2]=f10
567 ;;
568 stf.spill [temp1]=f11
569
570 // Save the switch_stack data that is not in minstate nor pt_regs. The
571 // previous code left regs at pt_regs.
572 add regs=MCA_SWITCH_STACK_OFFSET-MCA_PT_REGS_OFFSET, regs
573 ;;
574 add temp1=SW(F2), regs
575 add temp2=SW(F3), regs
576 ;;
577 stf.spill [temp1]=f2,32
578 stf.spill [temp2]=f3,32
579 ;;
580 stf.spill [temp1]=f4,32
581 stf.spill [temp2]=f5,32
582 ;;
583 stf.spill [temp1]=f12,32
584 stf.spill [temp2]=f13,32
585 ;;
586 stf.spill [temp1]=f14,32
587 stf.spill [temp2]=f15,32
588 ;;
589 stf.spill [temp1]=f16,32
590 stf.spill [temp2]=f17,32
591 ;;
592 stf.spill [temp1]=f18,32
593 stf.spill [temp2]=f19,32
594 ;;
595 stf.spill [temp1]=f20,32
596 stf.spill [temp2]=f21,32
597 ;;
598 stf.spill [temp1]=f22,32
599 stf.spill [temp2]=f23,32
600 ;;
601 stf.spill [temp1]=f24,32
602 stf.spill [temp2]=f25,32
603 ;;
604 stf.spill [temp1]=f26,32
605 stf.spill [temp2]=f27,32
606 ;;
607 stf.spill [temp1]=f28,32
608 stf.spill [temp2]=f29,32
609 ;;
610 stf.spill [temp1]=f30,SW(B2)-SW(F30)
611 stf.spill [temp2]=f31,SW(B3)-SW(F31)
612 mov temp3=b2
613 mov temp4=b3
614 ;;
615 st8 [temp1]=temp3,16 // save b2
616 st8 [temp2]=temp4,16 // save b3
617 mov temp3=b4
618 mov temp4=b5
619 ;;
620 st8 [temp1]=temp3,SW(AR_LC)-SW(B4) // save b4
621 st8 [temp2]=temp4 // save b5
622 mov temp3=ar.lc
623 ;;
624 st8 [temp1]=temp3 // save ar.lc
625
626 // FIXME: Some proms are incorrectly accessing the minstate area as
627 // cached data. The C code uses region 6, uncached virtual. Ensure
628 // that there is no cache data lying around for the first 1K of the
629 // minstate area.
630 // Remove this code in September 2006, that gives platforms a year to
631 // fix their proms and get their customers updated.
632
633 add r1=32*1,r17
634 add r2=32*2,r17
635 add r3=32*3,r17
636 add r4=32*4,r17
637 add r5=32*5,r17
638 add r6=32*6,r17
639 add r7=32*7,r17
640 ;;
641 fc r17
642 fc r1
643 fc r2
644 fc r3
645 fc r4
646 fc r5
647 fc r6
648 fc r7
649 add r17=32*8,r17
650 add r1=32*8,r1
651 add r2=32*8,r2
652 add r3=32*8,r3
653 add r4=32*8,r4
654 add r5=32*8,r5
655 add r6=32*8,r6
656 add r7=32*8,r7
657 ;;
658 fc r17
659 fc r1
660 fc r2
661 fc r3
662 fc r4
663 fc r5
664 fc r6
665 fc r7
666 add r17=32*8,r17
667 add r1=32*8,r1
668 add r2=32*8,r2
669 add r3=32*8,r3
670 add r4=32*8,r4
671 add r5=32*8,r5
672 add r6=32*8,r6
673 add r7=32*8,r7
674 ;;
675 fc r17
676 fc r1
677 fc r2
678 fc r3
679 fc r4
680 fc r5
681 fc r6
682 fc r7
683 add r17=32*8,r17
684 add r1=32*8,r1
685 add r2=32*8,r2
686 add r3=32*8,r3
687 add r4=32*8,r4
688 add r5=32*8,r5
689 add r6=32*8,r6
690 add r7=32*8,r7
691 ;;
692 fc r17
693 fc r1
694 fc r2
695 fc r3
696 fc r4
697 fc r5
698 fc r6
699 fc r7
700
701 br.sptk b0
702
703//EndStub//////////////////////////////////////////////////////////////////////
704
705
706//++
707// Name:
708// ia64_state_restore()
709//
710// Stub Description:
711//
712// Restore the SAL/OS state. This is sensitive to the layout of struct
713// ia64_sal_os_state in mca.h.
714//
715// r2 contains the return address, r3 contains either
716// IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
717//
718// In addition to the SAL to OS state, this routine restores all the
719// registers that appear in struct pt_regs and struct switch_stack,
720// excluding those in the PAL minstate area.
721//
722//--
723
724ia64_state_restore:
725 // Restore the switch_stack data that is not in minstate nor pt_regs.
726 add regs=MCA_SWITCH_STACK_OFFSET, r3
727 mov b0=r2 // save return address
728 ;;
729 GET_IA64_MCA_DATA(temp2)
730 ;;
731 add regs=temp2, regs
732 ;;
733 add temp1=SW(F2), regs
734 add temp2=SW(F3), regs
735 ;;
736 ldf.fill f2=[temp1],32
737 ldf.fill f3=[temp2],32
738 ;;
739 ldf.fill f4=[temp1],32
740 ldf.fill f5=[temp2],32
741 ;;
742 ldf.fill f12=[temp1],32
743 ldf.fill f13=[temp2],32
744 ;;
745 ldf.fill f14=[temp1],32
746 ldf.fill f15=[temp2],32
747 ;;
748 ldf.fill f16=[temp1],32
749 ldf.fill f17=[temp2],32
750 ;;
751 ldf.fill f18=[temp1],32
752 ldf.fill f19=[temp2],32
753 ;;
754 ldf.fill f20=[temp1],32
755 ldf.fill f21=[temp2],32
756 ;;
757 ldf.fill f22=[temp1],32
758 ldf.fill f23=[temp2],32
759 ;;
760 ldf.fill f24=[temp1],32
761 ldf.fill f25=[temp2],32
762 ;;
763 ldf.fill f26=[temp1],32
764 ldf.fill f27=[temp2],32
765 ;;
766 ldf.fill f28=[temp1],32
767 ldf.fill f29=[temp2],32
768 ;;
769 ldf.fill f30=[temp1],SW(B2)-SW(F30)
770 ldf.fill f31=[temp2],SW(B3)-SW(F31)
771 ;;
772 ld8 temp3=[temp1],16 // restore b2
773 ld8 temp4=[temp2],16 // restore b3
774 ;;
775 mov b2=temp3
776 mov b3=temp4
777 ld8 temp3=[temp1],SW(AR_LC)-SW(B4) // restore b4
778 ld8 temp4=[temp2] // restore b5
779 ;;
780 mov b4=temp3
781 mov b5=temp4
782 ld8 temp3=[temp1] // restore ar.lc
783 ;;
784 mov ar.lc=temp3
785
786 // Restore the pt_regs data that is not in minstate. The previous code
787 // left regs at switch_stack.
788 add regs=MCA_PT_REGS_OFFSET-MCA_SWITCH_STACK_OFFSET, regs
789 ;;
790 add temp1=PT(B6), regs
791 add temp2=PT(B7), regs
792 ;;
793 ld8 temp3=[temp1],PT(AR_CSD)-PT(B6) // restore b6
794 ld8 temp4=[temp2],PT(AR_SSD)-PT(B7) // restore b7
795 ;;
796 mov b6=temp3
797 mov b7=temp4
798 ld8 temp3=[temp1],PT(AR_UNAT)-PT(AR_CSD) // restore ar.csd
799 ld8 temp4=[temp2],PT(AR_PFS)-PT(AR_SSD) // restore ar.ssd
800 ;;
801 mov ar.csd=temp3
802 mov ar.ssd=temp4
803 ld8 temp3=[temp1] // restore ar.unat
804 add temp1=PT(AR_CCV)-PT(AR_UNAT), temp1
805 ld8 temp4=[temp2],PT(AR_FPSR)-PT(AR_PFS) // restore ar.pfs
806 ;;
807 mov ar.unat=temp3
808 mov ar.pfs=temp4
809 // ar.rnat, ar.bspstore, loadrs are restore in ia64_old_stack.
810 ld8 temp3=[temp1],PT(F6)-PT(AR_CCV) // restore ar.ccv
811 ld8 temp4=[temp2],PT(F7)-PT(AR_FPSR) // restore ar.fpsr
812 ;;
813 mov ar.ccv=temp3
814 mov ar.fpsr=temp4
815 ldf.fill f6=[temp1],PT(F8)-PT(F6)
816 ldf.fill f7=[temp2],PT(F9)-PT(F7)
817 ;;
818 ldf.fill f8=[temp1],PT(F10)-PT(F8)
819 ldf.fill f9=[temp2],PT(F11)-PT(F9)
820 ;;
821 ldf.fill f10=[temp1]
822 ldf.fill f11=[temp2]
823
824 // Restore the SAL to OS state. The previous code left regs at pt_regs.
825 add regs=MCA_SOS_OFFSET-MCA_PT_REGS_OFFSET, regs
826 ;;
Keith Owensd270acb2006-04-07 18:08:11 +1000827 add temp1=SOS(SAL_RA), regs
828 add temp2=SOS(SAL_GP), regs
Keith Owens7f613c72005-09-11 17:22:53 +1000829 ;;
830 ld8 r12=[temp1],16 // sal_ra
831 ld8 r9=[temp2],16 // sal_gp
832 ;;
Keith Owens20bb8682005-09-22 18:49:15 +1000833 ld8 r22=[temp1],16 // pal_min_state, virtual
Keith Owens8cab7cc2006-04-07 16:34:34 +1000834 ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
Keith Owens7f613c72005-09-11 17:22:53 +1000835 ;;
Keith Owens20bb8682005-09-22 18:49:15 +1000836 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
837 ld8 r20=[temp2],16 // prev_task
838 ;;
Keith Owens7f613c72005-09-11 17:22:53 +1000839 ld8 temp3=[temp1],16 // cr.isr
840 ld8 temp4=[temp2],16 // cr.ifa
841 ;;
842 mov cr.isr=temp3
843 mov cr.ifa=temp4
844 ld8 temp3=[temp1],16 // cr.itir
845 ld8 temp4=[temp2],16 // cr.iipa
846 ;;
847 mov cr.itir=temp3
848 mov cr.iipa=temp4
Keith Owensd270acb2006-04-07 18:08:11 +1000849 ld8 temp3=[temp1] // cr.iim
850 ld8 temp4=[temp2] // cr.iha
851 add temp1=SOS(OS_STATUS), regs
852 add temp2=SOS(CONTEXT), regs
Keith Owens7f613c72005-09-11 17:22:53 +1000853 ;;
854 mov cr.iim=temp3
855 mov cr.iha=temp4
Francois Wellenrieter8a4b7b62006-01-13 14:01:01 -0800856 dep r22=0,r22,62,1 // pal_min_state, physical, uncached
Keith Owens8cab7cc2006-04-07 16:34:34 +1000857 mov IA64_KR(CURRENT)=r13
Keith Owens7f613c72005-09-11 17:22:53 +1000858 ld8 r8=[temp1] // os_status
859 ld8 r10=[temp2] // context
860
Keith Owens20bb8682005-09-22 18:49:15 +1000861 /* Wire IA64_TR_CURRENT_STACK to the stack that we are resuming to. To
862 * avoid any dependencies on the algorithm in ia64_switch_to(), just
863 * purge any existing CURRENT_STACK mapping and insert the new one.
864 *
Keith Owens8cab7cc2006-04-07 16:34:34 +1000865 * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
Keith Owens20bb8682005-09-22 18:49:15 +1000866 * prev_IA64_KR_CURRENT, these values may have been changed by the C
867 * code. Do not use r8, r9, r10, r22, they contain values ready for
868 * the return to SAL.
869 */
870
871 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
872 ;;
873 shl r15=r15,IA64_GRANULE_SHIFT
874 ;;
875 dep r15=-1,r15,61,3 // virtual granule
876 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
877 ;;
878 ptr.d r15,r18
879 ;;
880 srlz.d
881
Keith Owens8cab7cc2006-04-07 16:34:34 +1000882 extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
Keith Owens20bb8682005-09-22 18:49:15 +1000883 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
884 movl r21=PAGE_KERNEL // page properties
885 ;;
886 mov IA64_KR(CURRENT_STACK)=r16
887 cmp.ne p6,p0=RGN_KERNEL,r19 // new stack is in the kernel region?
888 or r21=r20,r21 // construct PA | page properties
889(p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
890 ;;
891 mov cr.itir=r18
Keith Owens8cab7cc2006-04-07 16:34:34 +1000892 mov cr.ifa=r13
Keith Owens20bb8682005-09-22 18:49:15 +1000893 mov r20=IA64_TR_CURRENT_STACK
894 ;;
895 itr.d dtr[r20]=r21
896 ;;
897 srlz.d
8981:
899
Keith Owens7f613c72005-09-11 17:22:53 +1000900 br.sptk b0
901
902//EndStub//////////////////////////////////////////////////////////////////////
903
904
905//++
906// Name:
907// ia64_new_stack()
908//
909// Stub Description:
910//
911// Switch to the MCA/INIT stack.
912//
913// r2 contains the return address, r3 contains either
914// IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
915//
916// On entry RBS is still on the original stack, this routine switches RBS
917// to use the MCA/INIT stack.
918//
919// On entry, sos->pal_min_state is physical, on exit it is virtual.
920//
921//--
922
923ia64_new_stack:
924 add regs=MCA_PT_REGS_OFFSET, r3
Keith Owensd270acb2006-04-07 18:08:11 +1000925 add temp2=MCA_SOS_OFFSET+SOS(PAL_MIN_STATE), r3
Keith Owens7f613c72005-09-11 17:22:53 +1000926 mov b0=r2 // save return address
927 GET_IA64_MCA_DATA(temp1)
928 invala
929 ;;
930 add temp2=temp2, temp1 // struct ia64_sal_os_state.pal_min_state on MCA or INIT stack
931 add regs=regs, temp1 // struct pt_regs on MCA or INIT stack
932 ;;
933 // Address of minstate area provided by PAL is physical, uncacheable.
934 // Convert to Linux virtual address in region 6 for C code.
935 ld8 ms=[temp2] // pal_min_state, physical
936 ;;
937 dep temp1=-1,ms,62,2 // set region 6
938 mov temp3=IA64_RBS_OFFSET-MCA_PT_REGS_OFFSET
939 ;;
940 st8 [temp2]=temp1 // pal_min_state, virtual
941
942 add temp4=temp3, regs // start of bspstore on new stack
943 ;;
944 mov ar.bspstore=temp4 // switch RBS to MCA/INIT stack
945 ;;
946 flushrs // must be first in group
947 br.sptk b0
948
949//EndStub//////////////////////////////////////////////////////////////////////
950
951
952//++
953// Name:
954// ia64_old_stack()
955//
956// Stub Description:
957//
958// Switch to the old stack.
959//
960// r2 contains the return address, r3 contains either
961// IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
962//
963// On entry, pal_min_state is virtual, on exit it is physical.
964//
965// On entry RBS is on the MCA/INIT stack, this routine switches RBS
966// back to the previous stack.
967//
968// The psr is set to all zeroes. SAL return requires either all zeroes or
969// just psr.mc set. Leaving psr.mc off allows INIT to be issued if this
970// code does not perform correctly.
971//
972// The dirty registers at the time of the event were flushed to the
973// MCA/INIT stack in ia64_pt_regs_save(). Restore the dirty registers
974// before reverting to the previous bspstore.
975//--
976
977ia64_old_stack:
978 add regs=MCA_PT_REGS_OFFSET, r3
979 mov b0=r2 // save return address
980 GET_IA64_MCA_DATA(temp2)
981 LOAD_PHYSICAL(p0,temp1,1f)
982 ;;
983 mov cr.ipsr=r0
984 mov cr.ifs=r0
985 mov cr.iip=temp1
986 ;;
987 invala
988 rfi
9891:
990
991 add regs=regs, temp2 // struct pt_regs on MCA or INIT stack
992 ;;
993 add temp1=PT(LOADRS), regs
994 ;;
995 ld8 temp2=[temp1],PT(AR_BSPSTORE)-PT(LOADRS) // restore loadrs
996 ;;
997 ld8 temp3=[temp1],PT(AR_RNAT)-PT(AR_BSPSTORE) // restore ar.bspstore
998 mov ar.rsc=temp2
999 ;;
1000 loadrs
1001 ld8 temp4=[temp1] // restore ar.rnat
1002 ;;
1003 mov ar.bspstore=temp3 // back to old stack
1004 ;;
1005 mov ar.rnat=temp4
1006 ;;
1007
1008 br.sptk b0
1009
1010//EndStub//////////////////////////////////////////////////////////////////////
1011
1012
1013//++
1014// Name:
1015// ia64_set_kernel_registers()
1016//
1017// Stub Description:
1018//
1019// Set the registers that are required by the C code in order to run on an
1020// MCA/INIT stack.
1021//
1022// r2 contains the return address, r3 contains either
1023// IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
1024//
1025//--
1026
1027ia64_set_kernel_registers:
1028 add temp3=MCA_SP_OFFSET, r3
Keith Owensd270acb2006-04-07 18:08:11 +10001029 add temp4=MCA_SOS_OFFSET+SOS(OS_GP), r3
Keith Owens7f613c72005-09-11 17:22:53 +10001030 mov b0=r2 // save return address
1031 GET_IA64_MCA_DATA(temp1)
1032 ;;
1033 add temp4=temp4, temp1 // &struct ia64_sal_os_state.os_gp
1034 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
1035 add r13=temp1, r3 // set current to start of MCA/INIT stack
Keith Owens20bb8682005-09-22 18:49:15 +10001036 add r20=temp1, r3 // physical start of MCA/INIT stack
Keith Owens7f613c72005-09-11 17:22:53 +10001037 ;;
1038 ld8 r1=[temp4] // OS GP from SAL OS state
1039 ;;
1040 DATA_PA_TO_VA(r1,temp1)
1041 DATA_PA_TO_VA(r12,temp2)
1042 DATA_PA_TO_VA(r13,temp3)
1043 ;;
1044 mov IA64_KR(CURRENT)=r13
1045
Keith Owens20bb8682005-09-22 18:49:15 +10001046 /* Wire IA64_TR_CURRENT_STACK to the MCA/INIT handler stack. To avoid
1047 * any dependencies on the algorithm in ia64_switch_to(), just purge
1048 * any existing CURRENT_STACK mapping and insert the new one.
1049 */
1050
1051 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1052 ;;
1053 shl r16=r16,IA64_GRANULE_SHIFT
1054 ;;
1055 dep r16=-1,r16,61,3 // virtual granule
1056 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1057 ;;
1058 ptr.d r16,r18
1059 ;;
1060 srlz.d
1061
1062 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1063 movl r21=PAGE_KERNEL // page properties
1064 ;;
1065 mov IA64_KR(CURRENT_STACK)=r16
1066 or r21=r20,r21 // construct PA | page properties
1067 ;;
1068 mov cr.itir=r18
1069 mov cr.ifa=r13
1070 mov r20=IA64_TR_CURRENT_STACK
1071 ;;
1072 itr.d dtr[r20]=r21
1073 ;;
1074 srlz.d
Keith Owens7f613c72005-09-11 17:22:53 +10001075
1076 br.sptk b0
1077
1078//EndStub//////////////////////////////////////////////////////////////////////
1079
1080#undef ms
1081#undef regs
1082#undef temp1
1083#undef temp2
1084#undef temp3
1085#undef temp4
1086
1087
1088// Support function for mca.c, it is here to avoid using inline asm. Given the
1089// address of an rnat slot, if that address is below the current ar.bspstore
1090// then return the contents of that slot, otherwise return the contents of
1091// ar.rnat.
1092GLOBAL_ENTRY(ia64_get_rnat)
1093 alloc r14=ar.pfs,1,0,0,0
1094 mov ar.rsc=0
1095 ;;
1096 mov r14=ar.bspstore
1097 ;;
1098 cmp.lt p6,p7=in0,r14
1099 ;;
1100(p6) ld8 r8=[in0]
1101(p7) mov r8=ar.rnat
1102 mov ar.rsc=3
1103 br.ret.sptk.many rp
1104END(ia64_get_rnat)