3 * Purpose: assembly portion of the IA64 MCA handling
5 * Mods by cfleck to integrate into kernel build
7 * 2000-03-15 David Mosberger-Tang <davidm@hpl.hp.com>
8 * Added various stop bits to get a clean compile
10 * 2000-03-29 Chuck Fleckenstein <cfleck@co.intel.com>
11 * Added code to save INIT handoff state in pt_regs format,
12 * switch to temp kstack, switch modes, jump to C INIT handler
14 * 2002-01-04 J.Hall <jenna.s.hall@intel.com>
15 * Before entering virtual mode code:
16 * 1. Check for TLB CPU error
17 * 2. Restore current thread pointer to kr6
18 * 3. Move stack ptr 16 bytes to conform to C calling convention
20 * 2004-11-12 Russ Anderson <rja@sgi.com>
21 * Added per cpu MCA/INIT stack save areas.
23 * 2005-12-08 Keith Owens <kaos@sgi.com>
24 * Use per cpu MCA/INIT stacks for all data.
26 #include <linux/threads.h>
28 #include <asm/asmmacro.h>
29 #include <asm/pgtable.h>
30 #include <asm/processor.h>
31 #include <asm/mca_asm.h>
36 #define GET_IA64_MCA_DATA(reg) \
37 GET_THIS_PADDR(reg, ia64_mca_data) \
41 .global ia64_do_tlb_purge
42 .global ia64_os_mca_dispatch
43 .global ia64_os_init_dispatch_monarch
44 .global ia64_os_init_dispatch_slave
49 //StartMain////////////////////////////////////////////////////////////////////
52 * Just the TLB purge part is moved to a separate function
53 * so we can re-use the code for cpu hotplug code as well
54 * Caller should now setup b1, so we can branch once the
55 * tlb flush is complete.
59 #define O(member) IA64_CPUINFO_##member##_OFFSET
61 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
63 addl r17=O(PTCE_STRIDE),r2
64 addl r2=O(PTCE_BASE),r2
66 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
67 ld4 r19=[r2],4 // r19=ptce_count[0]
68 ld4 r21=[r17],4 // r21=ptce_stride[0]
70 ld4 r20=[r2] // r20=ptce_count[1]
71 ld4 r22=[r17] // r22=ptce_stride[1]
80 (p7) br.cond.dpnt.few 4f
93 srlz.i // srlz.i implies srlz.d
96 // Now purge addresses formerly mapped by TR registers
97 // 1. Purge ITR&DTR for kernel.
99 mov r18=KERNEL_TR_PAGE_SHIFT<<2
108 // 3. Purge ITR for PAL code.
109 GET_THIS_PADDR(r2, ia64_mca_pal_base)
112 mov r18=IA64_GRANULE_SHIFT<<2
118 // 4. Purge DTR for stack.
119 mov r16=IA64_KR(CURRENT_STACK)
121 shl r16=r16,IA64_GRANULE_SHIFT
125 mov r18=IA64_GRANULE_SHIFT<<2
131 // Now branch away to caller.
135 //EndMain//////////////////////////////////////////////////////////////////////
137 //StartMain////////////////////////////////////////////////////////////////////
139 ia64_os_mca_dispatch:
140 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
141 LOAD_PHYSICAL(p0,r2,1f) // return address
142 mov r19=1 // All MCA events are treated as monarch (for now)
143 br.sptk ia64_state_save // save the state that is not in minstate
146 GET_IA64_MCA_DATA(r2)
147 // Using MCA stack, struct ia64_sal_os_state, variable proc_state_param
149 add r3=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET+SOS(PROC_STATE_PARAM), r2
151 ld8 r18=[r3] // Get processor state parameter on existing PALE_CHECK.
154 (p7) br.spnt done_tlb_purge_and_reload
156 // The following code purges TC and TR entries. Then reload all TC entries.
157 // Purge percpu data TC entries.
158 begin_tlb_purge_and_reload:
159 movl r18=ia64_reload_tr;;
160 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
162 br.sptk.many ia64_do_tlb_purge;;
165 // Finally reload the TR registers.
166 // 1. Reload DTR/ITR registers for kernel.
167 mov r18=KERNEL_TR_PAGE_SHIFT<<2
168 movl r17=KERNEL_START
172 mov r16=IA64_TR_KERNEL
176 dep r17=0,r19,0, KERNEL_TR_PAGE_SHIFT
187 // 3. Reload ITR for PAL code.
188 GET_THIS_PADDR(r2, ia64_mca_pal_pte)
190 ld8 r18=[r2] // load PAL PTE
192 GET_THIS_PADDR(r2, ia64_mca_pal_base)
194 ld8 r16=[r2] // load PAL vaddr
195 mov r19=IA64_GRANULE_SHIFT<<2
199 mov r20=IA64_TR_PALCODE
205 // 4. Reload DTR for stack.
206 mov r16=IA64_KR(CURRENT_STACK)
208 shl r16=r16,IA64_GRANULE_SHIFT
215 mov r19=IA64_GRANULE_SHIFT<<2
219 mov r20=IA64_TR_CURRENT_STACK
222 GET_THIS_PADDR(r2, ia64_mca_tr_reload)
230 done_tlb_purge_and_reload:
232 // switch to per cpu MCA stack
233 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
234 LOAD_PHYSICAL(p0,r2,1f) // return address
235 br.sptk ia64_new_stack
238 // everything saved, now we can set the kernel registers
239 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
240 LOAD_PHYSICAL(p0,r2,1f) // return address
241 br.sptk ia64_set_kernel_registers
244 // This must be done in physical mode
245 GET_IA64_MCA_DATA(r2)
249 // Enter virtual mode from physical mode
250 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_begin, r4)
252 // This code returns to SAL via SOS r2, in general SAL has no unwind
253 // data. To get a clean termination when backtracing the C MCA/INIT
254 // handler, set a dummy return address of 0 in this routine. That
255 // requires that ia64_os_mca_virtual_begin be a global function.
256 ENTRY(ia64_os_mca_virtual_begin)
261 mov ar.rsc=3 // set eager mode for C handler
262 mov r2=r7 // see GET_IA64_MCA_DATA above
265 // Call virtual mode handler
266 alloc r14=ar.pfs,0,0,3,0
270 add out0=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
271 add out1=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
272 add out2=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET, r2
273 br.call.sptk.many b0=ia64_mca_handler
275 // Revert back to physical mode before going back to SAL
276 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_end, r4)
277 ia64_os_mca_virtual_end:
279 END(ia64_os_mca_virtual_begin)
281 // switch back to previous stack
282 alloc r14=ar.pfs,0,0,0,0 // remove the MCA handler frame
283 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
284 LOAD_PHYSICAL(p0,r2,1f) // return address
285 br.sptk ia64_old_stack
288 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
289 LOAD_PHYSICAL(p0,r2,1f) // return address
290 br.sptk ia64_state_restore // restore the SAL state
293 mov b0=r12 // SAL_CHECK return address
297 //EndMain//////////////////////////////////////////////////////////////////////
299 //StartMain////////////////////////////////////////////////////////////////////
302 // SAL to OS entry point for INIT on all processors. This has been defined for
303 // registration purposes with SAL as a part of ia64_mca_init. Monarch and
304 // slave INIT have identical processing, except for the value of the
305 // sos->monarch flag in r19.
308 ia64_os_init_dispatch_monarch:
309 mov r19=1 // Bow, bow, ye lower middle classes!
310 br.sptk ia64_os_init_dispatch
312 ia64_os_init_dispatch_slave:
313 mov r19=0 // <igor>yeth, mathter</igor>
315 ia64_os_init_dispatch:
317 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
318 LOAD_PHYSICAL(p0,r2,1f) // return address
319 br.sptk ia64_state_save // save the state that is not in minstate
322 // switch to per cpu INIT stack
323 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
324 LOAD_PHYSICAL(p0,r2,1f) // return address
325 br.sptk ia64_new_stack
328 // everything saved, now we can set the kernel registers
329 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
330 LOAD_PHYSICAL(p0,r2,1f) // return address
331 br.sptk ia64_set_kernel_registers
334 // This must be done in physical mode
335 GET_IA64_MCA_DATA(r2)
339 // Enter virtual mode from physical mode
340 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_begin, r4)
342 // This code returns to SAL via SOS r2, in general SAL has no unwind
343 // data. To get a clean termination when backtracing the C MCA/INIT
344 // handler, set a dummy return address of 0 in this routine. That
345 // requires that ia64_os_init_virtual_begin be a global function.
346 ENTRY(ia64_os_init_virtual_begin)
351 mov ar.rsc=3 // set eager mode for C handler
352 mov r2=r7 // see GET_IA64_MCA_DATA above
355 // Call virtual mode handler
356 alloc r14=ar.pfs,0,0,3,0
360 add out0=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
361 add out1=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
362 add out2=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SOS_OFFSET, r2
363 br.call.sptk.many b0=ia64_init_handler
365 // Revert back to physical mode before going back to SAL
366 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_end, r4)
367 ia64_os_init_virtual_end:
369 END(ia64_os_init_virtual_begin)
371 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
372 LOAD_PHYSICAL(p0,r2,1f) // return address
373 br.sptk ia64_state_restore // restore the SAL state
376 // switch back to previous stack
377 alloc r14=ar.pfs,0,0,0,0 // remove the INIT handler frame
378 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
379 LOAD_PHYSICAL(p0,r2,1f) // return address
380 br.sptk ia64_old_stack
383 mov b0=r12 // SAL_CHECK return address
386 //EndMain//////////////////////////////////////////////////////////////////////
388 // common defines for the stubs
391 #define temp1 r2 /* careful, it overlaps with input registers */
392 #define temp2 r3 /* careful, it overlaps with input registers */
403 // Save the state that is not in minstate. This is sensitive to the layout of
404 // struct ia64_sal_os_state in mca.h.
406 // r2 contains the return address, r3 contains either
407 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
409 // The OS to SAL section of struct ia64_sal_os_state is set to a default
410 // value of cold boot (MCA) or warm boot (INIT) and return to the same
411 // context. ia64_sal_os_state is also used to hold some registers that
412 // need to be saved and restored across the stack switches.
414 // Most input registers to this stub come from PAL/SAL
415 // r1 os gp, physical
416 // r8 pal_proc entry point
417 // r9 sal_proc entry point
419 // r11 MCA - rendevzous state, INIT - reason code
420 // r12 sal return address
422 // r18 processor state parameter
423 // r19 monarch flag, set by the caller of this routine
425 // In addition to the SAL to OS state, this routine saves all the
426 // registers that appear in struct pt_regs and struct switch_stack,
427 // excluding those that are already in the PAL minstate area. This
428 // results in a partial pt_regs and switch_stack, the C code copies the
429 // remaining registers from PAL minstate to pt_regs and switch_stack. The
430 // resulting structures contain all the state of the original process when
431 // MCA/INIT occurred.
436 add regs=MCA_SOS_OFFSET, r3
437 add ms=MCA_SOS_OFFSET+8, r3
438 mov b0=r2 // save return address
439 cmp.eq p1,p2=IA64_MCA_CPU_MCA_STACK_OFFSET, r3
441 GET_IA64_MCA_DATA(temp2)
443 add temp1=temp2, regs // struct ia64_sal_os_state on MCA or INIT stack
444 add temp2=temp2, ms // struct ia64_sal_os_state+8 on MCA or INIT stack
446 mov regs=temp1 // save the start of sos
447 st8 [temp1]=r1,16 // os_gp
448 st8 [temp2]=r8,16 // pal_proc
450 st8 [temp1]=r9,16 // sal_proc
451 st8 [temp2]=r11,16 // rv_rc
454 st8 [temp1]=r18 // proc_state_param
455 st8 [temp2]=r19 // monarch
456 mov r6=IA64_KR(CURRENT)
457 add temp1=SOS(SAL_RA), regs
458 add temp2=SOS(SAL_GP), regs
460 st8 [temp1]=r12,16 // sal_ra
461 st8 [temp2]=r10,16 // sal_gp
464 st8 [temp1]=r17,16 // pal_min_state
465 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
466 mov r6=IA64_KR(CURRENT_STACK)
468 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
469 st8 [temp2]=r0,16 // prev_task, starts off as NULL
472 st8 [temp1]=r12,16 // cr.isr
473 st8 [temp2]=r6,16 // cr.ifa
476 st8 [temp1]=r12,16 // cr.itir
477 st8 [temp2]=r11,16 // cr.iipa
480 st8 [temp1]=r12 // cr.iim
481 (p1) mov r12=IA64_MCA_COLD_BOOT
482 (p2) mov r12=IA64_INIT_WARM_BOOT
484 add temp1=SOS(OS_STATUS), regs
486 st8 [temp2]=r6 // cr.iha
487 add temp2=SOS(CONTEXT), regs
488 st8 [temp1]=r12 // os_status, default is cold boot
489 mov r6=IA64_MCA_SAME_CONTEXT
491 st8 [temp2]=r6 // context, default is same context
493 // Save the pt_regs data that is not in minstate. The previous code
495 add regs=MCA_PT_REGS_OFFSET-MCA_SOS_OFFSET, regs
497 add temp1=PT(B6), regs
500 add temp2=PT(B7), regs
502 st8 [temp1]=temp3,PT(AR_CSD)-PT(B6) // save b6
503 st8 [temp2]=temp4,PT(AR_SSD)-PT(B7) // save b7
506 cover // must be last in group
508 st8 [temp1]=temp3,PT(AR_UNAT)-PT(AR_CSD) // save ar.csd
509 st8 [temp2]=temp4,PT(AR_PFS)-PT(AR_SSD) // save ar.ssd
513 st8 [temp1]=temp3,PT(AR_RNAT)-PT(AR_UNAT) // save ar.unat
514 st8 [temp2]=temp4,PT(AR_BSPSTORE)-PT(AR_PFS) // save ar.pfs
516 mov temp4=ar.bspstore
518 st8 [temp1]=temp3,PT(LOADRS)-PT(AR_RNAT) // save ar.rnat
519 st8 [temp2]=temp4,PT(AR_FPSR)-PT(AR_BSPSTORE) // save ar.bspstore
522 sub temp3=temp3, temp4 // ar.bsp - ar.bspstore
525 shl temp3=temp3,16 // compute ar.rsc to be used for "loadrs"
527 st8 [temp1]=temp3,PT(AR_CCV)-PT(LOADRS) // save loadrs
528 st8 [temp2]=temp4,PT(F6)-PT(AR_FPSR) // save ar.fpsr
531 st8 [temp1]=temp3,PT(F7)-PT(AR_CCV) // save ar.ccv
532 stf.spill [temp2]=f6,PT(F8)-PT(F6)
534 stf.spill [temp1]=f7,PT(F9)-PT(F7)
535 stf.spill [temp2]=f8,PT(F10)-PT(F8)
537 stf.spill [temp1]=f9,PT(F11)-PT(F9)
538 stf.spill [temp2]=f10
540 stf.spill [temp1]=f11
542 // Save the switch_stack data that is not in minstate nor pt_regs. The
543 // previous code left regs at pt_regs.
544 add regs=MCA_SWITCH_STACK_OFFSET-MCA_PT_REGS_OFFSET, regs
546 add temp1=SW(F2), regs
547 add temp2=SW(F3), regs
549 stf.spill [temp1]=f2,32
550 stf.spill [temp2]=f3,32
552 stf.spill [temp1]=f4,32
553 stf.spill [temp2]=f5,32
555 stf.spill [temp1]=f12,32
556 stf.spill [temp2]=f13,32
558 stf.spill [temp1]=f14,32
559 stf.spill [temp2]=f15,32
561 stf.spill [temp1]=f16,32
562 stf.spill [temp2]=f17,32
564 stf.spill [temp1]=f18,32
565 stf.spill [temp2]=f19,32
567 stf.spill [temp1]=f20,32
568 stf.spill [temp2]=f21,32
570 stf.spill [temp1]=f22,32
571 stf.spill [temp2]=f23,32
573 stf.spill [temp1]=f24,32
574 stf.spill [temp2]=f25,32
576 stf.spill [temp1]=f26,32
577 stf.spill [temp2]=f27,32
579 stf.spill [temp1]=f28,32
580 stf.spill [temp2]=f29,32
582 stf.spill [temp1]=f30,SW(B2)-SW(F30)
583 stf.spill [temp2]=f31,SW(B3)-SW(F31)
587 st8 [temp1]=temp3,16 // save b2
588 st8 [temp2]=temp4,16 // save b3
592 st8 [temp1]=temp3,SW(AR_LC)-SW(B4) // save b4
593 st8 [temp2]=temp4 // save b5
596 st8 [temp1]=temp3 // save ar.lc
598 // FIXME: Some proms are incorrectly accessing the minstate area as
599 // cached data. The C code uses region 6, uncached virtual. Ensure
600 // that there is no cache data lying around for the first 1K of the
602 // Remove this code in September 2006, that gives platforms a year to
603 // fix their proms and get their customers updated.
675 //EndStub//////////////////////////////////////////////////////////////////////
680 // ia64_state_restore()
684 // Restore the SAL/OS state. This is sensitive to the layout of struct
685 // ia64_sal_os_state in mca.h.
687 // r2 contains the return address, r3 contains either
688 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
690 // In addition to the SAL to OS state, this routine restores all the
691 // registers that appear in struct pt_regs and struct switch_stack,
692 // excluding those in the PAL minstate area.
697 // Restore the switch_stack data that is not in minstate nor pt_regs.
698 add regs=MCA_SWITCH_STACK_OFFSET, r3
699 mov b0=r2 // save return address
701 GET_IA64_MCA_DATA(temp2)
705 add temp1=SW(F2), regs
706 add temp2=SW(F3), regs
708 ldf.fill f2=[temp1],32
709 ldf.fill f3=[temp2],32
711 ldf.fill f4=[temp1],32
712 ldf.fill f5=[temp2],32
714 ldf.fill f12=[temp1],32
715 ldf.fill f13=[temp2],32
717 ldf.fill f14=[temp1],32
718 ldf.fill f15=[temp2],32
720 ldf.fill f16=[temp1],32
721 ldf.fill f17=[temp2],32
723 ldf.fill f18=[temp1],32
724 ldf.fill f19=[temp2],32
726 ldf.fill f20=[temp1],32
727 ldf.fill f21=[temp2],32
729 ldf.fill f22=[temp1],32
730 ldf.fill f23=[temp2],32
732 ldf.fill f24=[temp1],32
733 ldf.fill f25=[temp2],32
735 ldf.fill f26=[temp1],32
736 ldf.fill f27=[temp2],32
738 ldf.fill f28=[temp1],32
739 ldf.fill f29=[temp2],32
741 ldf.fill f30=[temp1],SW(B2)-SW(F30)
742 ldf.fill f31=[temp2],SW(B3)-SW(F31)
744 ld8 temp3=[temp1],16 // restore b2
745 ld8 temp4=[temp2],16 // restore b3
749 ld8 temp3=[temp1],SW(AR_LC)-SW(B4) // restore b4
750 ld8 temp4=[temp2] // restore b5
754 ld8 temp3=[temp1] // restore ar.lc
758 // Restore the pt_regs data that is not in minstate. The previous code
759 // left regs at switch_stack.
760 add regs=MCA_PT_REGS_OFFSET-MCA_SWITCH_STACK_OFFSET, regs
762 add temp1=PT(B6), regs
763 add temp2=PT(B7), regs
765 ld8 temp3=[temp1],PT(AR_CSD)-PT(B6) // restore b6
766 ld8 temp4=[temp2],PT(AR_SSD)-PT(B7) // restore b7
770 ld8 temp3=[temp1],PT(AR_UNAT)-PT(AR_CSD) // restore ar.csd
771 ld8 temp4=[temp2],PT(AR_PFS)-PT(AR_SSD) // restore ar.ssd
775 ld8 temp3=[temp1] // restore ar.unat
776 add temp1=PT(AR_CCV)-PT(AR_UNAT), temp1
777 ld8 temp4=[temp2],PT(AR_FPSR)-PT(AR_PFS) // restore ar.pfs
781 // ar.rnat, ar.bspstore, loadrs are restore in ia64_old_stack.
782 ld8 temp3=[temp1],PT(F6)-PT(AR_CCV) // restore ar.ccv
783 ld8 temp4=[temp2],PT(F7)-PT(AR_FPSR) // restore ar.fpsr
787 ldf.fill f6=[temp1],PT(F8)-PT(F6)
788 ldf.fill f7=[temp2],PT(F9)-PT(F7)
790 ldf.fill f8=[temp1],PT(F10)-PT(F8)
791 ldf.fill f9=[temp2],PT(F11)-PT(F9)
796 // Restore the SAL to OS state. The previous code left regs at pt_regs.
797 add regs=MCA_SOS_OFFSET-MCA_PT_REGS_OFFSET, regs
799 add temp1=SOS(SAL_RA), regs
800 add temp2=SOS(SAL_GP), regs
802 ld8 r12=[temp1],16 // sal_ra
803 ld8 r9=[temp2],16 // sal_gp
805 ld8 r22=[temp1],16 // pal_min_state, virtual
806 ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
808 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
809 ld8 r20=[temp2],16 // prev_task
811 ld8 temp3=[temp1],16 // cr.isr
812 ld8 temp4=[temp2],16 // cr.ifa
816 ld8 temp3=[temp1],16 // cr.itir
817 ld8 temp4=[temp2],16 // cr.iipa
821 ld8 temp3=[temp1] // cr.iim
822 ld8 temp4=[temp2] // cr.iha
823 add temp1=SOS(OS_STATUS), regs
824 add temp2=SOS(CONTEXT), regs
828 dep r22=0,r22,62,1 // pal_min_state, physical, uncached
829 mov IA64_KR(CURRENT)=r13
830 ld8 r8=[temp1] // os_status
831 ld8 r10=[temp2] // context
833 /* Wire IA64_TR_CURRENT_STACK to the stack that we are resuming to. To
834 * avoid any dependencies on the algorithm in ia64_switch_to(), just
835 * purge any existing CURRENT_STACK mapping and insert the new one.
837 * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
838 * prev_IA64_KR_CURRENT, these values may have been changed by the C
839 * code. Do not use r8, r9, r10, r22, they contain values ready for
843 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
845 shl r15=r15,IA64_GRANULE_SHIFT
847 dep r15=-1,r15,61,3 // virtual granule
848 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
854 extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
855 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
856 movl r21=PAGE_KERNEL // page properties
858 mov IA64_KR(CURRENT_STACK)=r16
859 cmp.ne p6,p0=RGN_KERNEL,r19 // new stack is in the kernel region?
860 or r21=r20,r21 // construct PA | page properties
861 (p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
865 mov r20=IA64_TR_CURRENT_STACK
874 //EndStub//////////////////////////////////////////////////////////////////////
883 // Switch to the MCA/INIT stack.
885 // r2 contains the return address, r3 contains either
886 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
888 // On entry RBS is still on the original stack, this routine switches RBS
889 // to use the MCA/INIT stack.
891 // On entry, sos->pal_min_state is physical, on exit it is virtual.
896 add regs=MCA_PT_REGS_OFFSET, r3
897 add temp2=MCA_SOS_OFFSET+SOS(PAL_MIN_STATE), r3
898 mov b0=r2 // save return address
899 GET_IA64_MCA_DATA(temp1)
902 add temp2=temp2, temp1 // struct ia64_sal_os_state.pal_min_state on MCA or INIT stack
903 add regs=regs, temp1 // struct pt_regs on MCA or INIT stack
905 // Address of minstate area provided by PAL is physical, uncacheable.
906 // Convert to Linux virtual address in region 6 for C code.
907 ld8 ms=[temp2] // pal_min_state, physical
909 dep temp1=-1,ms,62,2 // set region 6
910 mov temp3=IA64_RBS_OFFSET-MCA_PT_REGS_OFFSET
912 st8 [temp2]=temp1 // pal_min_state, virtual
914 add temp4=temp3, regs // start of bspstore on new stack
916 mov ar.bspstore=temp4 // switch RBS to MCA/INIT stack
918 flushrs // must be first in group
921 //EndStub//////////////////////////////////////////////////////////////////////
930 // Switch to the old stack.
932 // r2 contains the return address, r3 contains either
933 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
935 // On entry, pal_min_state is virtual, on exit it is physical.
937 // On entry RBS is on the MCA/INIT stack, this routine switches RBS
938 // back to the previous stack.
940 // The psr is set to all zeroes. SAL return requires either all zeroes or
941 // just psr.mc set. Leaving psr.mc off allows INIT to be issued if this
942 // code does not perform correctly.
944 // The dirty registers at the time of the event were flushed to the
945 // MCA/INIT stack in ia64_pt_regs_save(). Restore the dirty registers
946 // before reverting to the previous bspstore.
950 add regs=MCA_PT_REGS_OFFSET, r3
951 mov b0=r2 // save return address
952 GET_IA64_MCA_DATA(temp2)
953 LOAD_PHYSICAL(p0,temp1,1f)
963 add regs=regs, temp2 // struct pt_regs on MCA or INIT stack
965 add temp1=PT(LOADRS), regs
967 ld8 temp2=[temp1],PT(AR_BSPSTORE)-PT(LOADRS) // restore loadrs
969 ld8 temp3=[temp1],PT(AR_RNAT)-PT(AR_BSPSTORE) // restore ar.bspstore
973 ld8 temp4=[temp1] // restore ar.rnat
975 mov ar.bspstore=temp3 // back to old stack
982 //EndStub//////////////////////////////////////////////////////////////////////
987 // ia64_set_kernel_registers()
991 // Set the registers that are required by the C code in order to run on an
994 // r2 contains the return address, r3 contains either
995 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
999 ia64_set_kernel_registers:
1000 add temp3=MCA_SP_OFFSET, r3
1001 mov b0=r2 // save return address
1002 GET_IA64_MCA_DATA(temp1)
1004 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
1005 add r13=temp1, r3 // set current to start of MCA/INIT stack
1006 add r20=temp1, r3 // physical start of MCA/INIT stack
1008 DATA_PA_TO_VA(r12,temp2)
1009 DATA_PA_TO_VA(r13,temp3)
1011 mov IA64_KR(CURRENT)=r13
1013 /* Wire IA64_TR_CURRENT_STACK to the MCA/INIT handler stack. To avoid
1014 * any dependencies on the algorithm in ia64_switch_to(), just purge
1015 * any existing CURRENT_STACK mapping and insert the new one.
1018 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1020 shl r16=r16,IA64_GRANULE_SHIFT
1022 dep r16=-1,r16,61,3 // virtual granule
1023 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1029 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1030 movl r21=PAGE_KERNEL // page properties
1032 mov IA64_KR(CURRENT_STACK)=r16
1033 or r21=r20,r21 // construct PA | page properties
1037 mov r20=IA64_TR_CURRENT_STACK
1039 movl r17=FPSR_DEFAULT
1041 mov.m ar.fpsr=r17 // set ar.fpsr to kernel default value
1049 //EndStub//////////////////////////////////////////////////////////////////////
1059 // Support function for mca.c, it is here to avoid using inline asm. Given the
1060 // address of an rnat slot, if that address is below the current ar.bspstore
1061 // then return the contents of that slot, otherwise return the contents of
1063 GLOBAL_ENTRY(ia64_get_rnat)
1064 alloc r14=ar.pfs,1,0,0,0
1069 cmp.lt p6,p7=in0,r14