1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Purpose: assembly portion of the IA64 MCA handling
6 * Mods by cfleck to integrate into kernel build
8 * 2000-03-15 David Mosberger-Tang <davidm@hpl.hp.com>
9 * Added various stop bits to get a clean compile
11 * 2000-03-29 Chuck Fleckenstein <cfleck@co.intel.com>
12 * Added code to save INIT handoff state in pt_regs format,
13 * switch to temp kstack, switch modes, jump to C INIT handler
15 * 2002-01-04 J.Hall <jenna.s.hall@intel.com>
16 * Before entering virtual mode code:
17 * 1. Check for TLB CPU error
18 * 2. Restore current thread pointer to kr6
19 * 3. Move stack ptr 16 bytes to conform to C calling convention
21 * 2004-11-12 Russ Anderson <rja@sgi.com>
22 * Added per cpu MCA/INIT stack save areas.
24 * 2005-12-08 Keith Owens <kaos@sgi.com>
25 * Use per cpu MCA/INIT stacks for all data.
27 #include <linux/threads.h>
29 #include <asm/asmmacro.h>
30 #include <asm/pgtable.h>
31 #include <asm/processor.h>
32 #include <asm/mca_asm.h>
37 #define GET_IA64_MCA_DATA(reg) \
38 GET_THIS_PADDR(reg, ia64_mca_data) \
42 .global ia64_do_tlb_purge
43 .global ia64_os_mca_dispatch
44 .global ia64_os_init_on_kdump
45 .global ia64_os_init_dispatch_monarch
46 .global ia64_os_init_dispatch_slave
51 //StartMain////////////////////////////////////////////////////////////////////
54 * Just the TLB purge part is moved to a separate function
55 * so we can re-use the code for cpu hotplug code as well
56 * Caller should now setup b1, so we can branch once the
57 * tlb flush is complete.
61 #define O(member) IA64_CPUINFO_##member##_OFFSET
63 GET_THIS_PADDR(r2, ia64_cpu_info) // load phys addr of cpu_info into r2
65 addl r17=O(PTCE_STRIDE),r2
66 addl r2=O(PTCE_BASE),r2
68 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
69 ld4 r19=[r2],4 // r19=ptce_count[0]
70 ld4 r21=[r17],4 // r21=ptce_stride[0]
72 ld4 r20=[r2] // r20=ptce_count[1]
73 ld4 r22=[r17] // r22=ptce_stride[1]
82 (p7) br.cond.dpnt.few 4f
95 srlz.i // srlz.i implies srlz.d
98 // Now purge addresses formerly mapped by TR registers
99 // 1. Purge ITR&DTR for kernel.
100 movl r16=KERNEL_START
101 mov r18=KERNEL_TR_PAGE_SHIFT<<2
110 // 3. Purge ITR for PAL code.
111 GET_THIS_PADDR(r2, ia64_mca_pal_base)
114 mov r18=IA64_GRANULE_SHIFT<<2
120 // 4. Purge DTR for stack.
121 mov r16=IA64_KR(CURRENT_STACK)
123 shl r16=r16,IA64_GRANULE_SHIFT
127 mov r18=IA64_GRANULE_SHIFT<<2
133 // Now branch away to caller.
137 //EndMain//////////////////////////////////////////////////////////////////////
139 //StartMain////////////////////////////////////////////////////////////////////
141 ia64_os_mca_dispatch:
142 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
143 LOAD_PHYSICAL(p0,r2,1f) // return address
144 mov r19=1 // All MCA events are treated as monarch (for now)
145 br.sptk ia64_state_save // save the state that is not in minstate
148 GET_IA64_MCA_DATA(r2)
149 // Using MCA stack, struct ia64_sal_os_state, variable proc_state_param
151 add r3=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET+SOS(PROC_STATE_PARAM), r2
153 ld8 r18=[r3] // Get processor state parameter on existing PALE_CHECK.
156 (p7) br.spnt done_tlb_purge_and_reload
158 // The following code purges TC and TR entries. Then reload all TC entries.
159 // Purge percpu data TC entries.
160 begin_tlb_purge_and_reload:
161 movl r18=ia64_reload_tr;;
162 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
164 br.sptk.many ia64_do_tlb_purge;;
167 // Finally reload the TR registers.
168 // 1. Reload DTR/ITR registers for kernel.
169 mov r18=KERNEL_TR_PAGE_SHIFT<<2
170 movl r17=KERNEL_START
174 mov r16=IA64_TR_KERNEL
178 dep r17=0,r19,0, KERNEL_TR_PAGE_SHIFT
189 // 3. Reload ITR for PAL code.
190 GET_THIS_PADDR(r2, ia64_mca_pal_pte)
192 ld8 r18=[r2] // load PAL PTE
194 GET_THIS_PADDR(r2, ia64_mca_pal_base)
196 ld8 r16=[r2] // load PAL vaddr
197 mov r19=IA64_GRANULE_SHIFT<<2
201 mov r20=IA64_TR_PALCODE
207 // 4. Reload DTR for stack.
208 mov r16=IA64_KR(CURRENT_STACK)
210 shl r16=r16,IA64_GRANULE_SHIFT
217 mov r19=IA64_GRANULE_SHIFT<<2
221 mov r20=IA64_TR_CURRENT_STACK
224 GET_THIS_PADDR(r2, ia64_mca_tr_reload)
232 done_tlb_purge_and_reload:
234 // switch to per cpu MCA stack
235 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
236 LOAD_PHYSICAL(p0,r2,1f) // return address
237 br.sptk ia64_new_stack
240 // everything saved, now we can set the kernel registers
241 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
242 LOAD_PHYSICAL(p0,r2,1f) // return address
243 br.sptk ia64_set_kernel_registers
246 // This must be done in physical mode
247 GET_IA64_MCA_DATA(r2)
251 // Enter virtual mode from physical mode
252 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_begin, r4)
254 // This code returns to SAL via SOS r2, in general SAL has no unwind
255 // data. To get a clean termination when backtracing the C MCA/INIT
256 // handler, set a dummy return address of 0 in this routine. That
257 // requires that ia64_os_mca_virtual_begin be a global function.
258 ENTRY(ia64_os_mca_virtual_begin)
263 mov ar.rsc=3 // set eager mode for C handler
264 mov r2=r7 // see GET_IA64_MCA_DATA above
267 // Call virtual mode handler
268 alloc r14=ar.pfs,0,0,3,0
272 add out0=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
273 add out1=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
274 add out2=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET, r2
275 br.call.sptk.many b0=ia64_mca_handler
277 // Revert back to physical mode before going back to SAL
278 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_end, r4)
279 ia64_os_mca_virtual_end:
281 END(ia64_os_mca_virtual_begin)
283 // switch back to previous stack
284 alloc r14=ar.pfs,0,0,0,0 // remove the MCA handler frame
285 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
286 LOAD_PHYSICAL(p0,r2,1f) // return address
287 br.sptk ia64_old_stack
290 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
291 LOAD_PHYSICAL(p0,r2,1f) // return address
292 br.sptk ia64_state_restore // restore the SAL state
295 mov b0=r12 // SAL_CHECK return address
299 //EndMain//////////////////////////////////////////////////////////////////////
301 //StartMain////////////////////////////////////////////////////////////////////
304 // NOP init handler for kdump. In panic situation, we may receive INIT
305 // while kernel transition. Since we initialize registers on leave from
306 // current kernel, no longer monarch/slave handlers of current kernel in
307 // virtual mode are called safely.
308 // We can unregister these init handlers from SAL, however then the INIT
309 // will result in warmboot by SAL and we cannot retrieve the crashdump.
310 // Therefore register this NOP function to SAL, to prevent entering virtual
311 // mode and resulting warmboot by SAL.
313 ia64_os_init_on_kdump:
314 mov r8=r0 // IA64_INIT_RESUME
316 mov r22=r17 // *minstate
318 mov r10=r0 // return to same context
319 mov b0=r12 // SAL_CHECK return address
323 // SAL to OS entry point for INIT on all processors. This has been defined for
324 // registration purposes with SAL as a part of ia64_mca_init. Monarch and
325 // slave INIT have identical processing, except for the value of the
326 // sos->monarch flag in r19.
329 ia64_os_init_dispatch_monarch:
330 mov r19=1 // Bow, bow, ye lower middle classes!
331 br.sptk ia64_os_init_dispatch
333 ia64_os_init_dispatch_slave:
334 mov r19=0 // <igor>yeth, mathter</igor>
336 ia64_os_init_dispatch:
338 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
339 LOAD_PHYSICAL(p0,r2,1f) // return address
340 br.sptk ia64_state_save // save the state that is not in minstate
343 // switch to per cpu INIT stack
344 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
345 LOAD_PHYSICAL(p0,r2,1f) // return address
346 br.sptk ia64_new_stack
349 // everything saved, now we can set the kernel registers
350 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
351 LOAD_PHYSICAL(p0,r2,1f) // return address
352 br.sptk ia64_set_kernel_registers
355 // This must be done in physical mode
356 GET_IA64_MCA_DATA(r2)
360 // Enter virtual mode from physical mode
361 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_begin, r4)
363 // This code returns to SAL via SOS r2, in general SAL has no unwind
364 // data. To get a clean termination when backtracing the C MCA/INIT
365 // handler, set a dummy return address of 0 in this routine. That
366 // requires that ia64_os_init_virtual_begin be a global function.
367 ENTRY(ia64_os_init_virtual_begin)
372 mov ar.rsc=3 // set eager mode for C handler
373 mov r2=r7 // see GET_IA64_MCA_DATA above
376 // Call virtual mode handler
377 alloc r14=ar.pfs,0,0,3,0
381 add out0=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
382 add out1=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
383 add out2=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SOS_OFFSET, r2
384 br.call.sptk.many b0=ia64_init_handler
386 // Revert back to physical mode before going back to SAL
387 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_end, r4)
388 ia64_os_init_virtual_end:
390 END(ia64_os_init_virtual_begin)
392 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
393 LOAD_PHYSICAL(p0,r2,1f) // return address
394 br.sptk ia64_state_restore // restore the SAL state
397 // switch back to previous stack
398 alloc r14=ar.pfs,0,0,0,0 // remove the INIT handler frame
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_old_stack
404 mov b0=r12 // SAL_CHECK return address
407 //EndMain//////////////////////////////////////////////////////////////////////
409 // common defines for the stubs
412 #define temp1 r2 /* careful, it overlaps with input registers */
413 #define temp2 r3 /* careful, it overlaps with input registers */
424 // Save the state that is not in minstate. This is sensitive to the layout of
425 // struct ia64_sal_os_state in mca.h.
427 // r2 contains the return address, r3 contains either
428 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
430 // The OS to SAL section of struct ia64_sal_os_state is set to a default
431 // value of cold boot (MCA) or warm boot (INIT) and return to the same
432 // context. ia64_sal_os_state is also used to hold some registers that
433 // need to be saved and restored across the stack switches.
435 // Most input registers to this stub come from PAL/SAL
436 // r1 os gp, physical
437 // r8 pal_proc entry point
438 // r9 sal_proc entry point
440 // r11 MCA - rendevzous state, INIT - reason code
441 // r12 sal return address
443 // r18 processor state parameter
444 // r19 monarch flag, set by the caller of this routine
446 // In addition to the SAL to OS state, this routine saves all the
447 // registers that appear in struct pt_regs and struct switch_stack,
448 // excluding those that are already in the PAL minstate area. This
449 // results in a partial pt_regs and switch_stack, the C code copies the
450 // remaining registers from PAL minstate to pt_regs and switch_stack. The
451 // resulting structures contain all the state of the original process when
452 // MCA/INIT occurred.
457 add regs=MCA_SOS_OFFSET, r3
458 add ms=MCA_SOS_OFFSET+8, r3
459 mov b0=r2 // save return address
460 cmp.eq p1,p2=IA64_MCA_CPU_MCA_STACK_OFFSET, r3
462 GET_IA64_MCA_DATA(temp2)
464 add temp1=temp2, regs // struct ia64_sal_os_state on MCA or INIT stack
465 add temp2=temp2, ms // struct ia64_sal_os_state+8 on MCA or INIT stack
467 mov regs=temp1 // save the start of sos
468 st8 [temp1]=r1,16 // os_gp
469 st8 [temp2]=r8,16 // pal_proc
471 st8 [temp1]=r9,16 // sal_proc
472 st8 [temp2]=r11,16 // rv_rc
475 st8 [temp1]=r18 // proc_state_param
476 st8 [temp2]=r19 // monarch
477 mov r6=IA64_KR(CURRENT)
478 add temp1=SOS(SAL_RA), regs
479 add temp2=SOS(SAL_GP), regs
481 st8 [temp1]=r12,16 // sal_ra
482 st8 [temp2]=r10,16 // sal_gp
485 st8 [temp1]=r17,16 // pal_min_state
486 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
487 mov r6=IA64_KR(CURRENT_STACK)
489 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
490 st8 [temp2]=r0,16 // prev_task, starts off as NULL
493 st8 [temp1]=r12,16 // cr.isr
494 st8 [temp2]=r6,16 // cr.ifa
497 st8 [temp1]=r12,16 // cr.itir
498 st8 [temp2]=r11,16 // cr.iipa
501 st8 [temp1]=r12 // cr.iim
502 (p1) mov r12=IA64_MCA_COLD_BOOT
503 (p2) mov r12=IA64_INIT_WARM_BOOT
505 add temp1=SOS(OS_STATUS), regs
507 st8 [temp2]=r6 // cr.iha
508 add temp2=SOS(CONTEXT), regs
509 st8 [temp1]=r12 // os_status, default is cold boot
510 mov r6=IA64_MCA_SAME_CONTEXT
512 st8 [temp2]=r6 // context, default is same context
514 // Save the pt_regs data that is not in minstate. The previous code
516 add regs=MCA_PT_REGS_OFFSET-MCA_SOS_OFFSET, regs
518 add temp1=PT(B6), regs
521 add temp2=PT(B7), regs
523 st8 [temp1]=temp3,PT(AR_CSD)-PT(B6) // save b6
524 st8 [temp2]=temp4,PT(AR_SSD)-PT(B7) // save b7
527 cover // must be last in group
529 st8 [temp1]=temp3,PT(AR_UNAT)-PT(AR_CSD) // save ar.csd
530 st8 [temp2]=temp4,PT(AR_PFS)-PT(AR_SSD) // save ar.ssd
534 st8 [temp1]=temp3,PT(AR_RNAT)-PT(AR_UNAT) // save ar.unat
535 st8 [temp2]=temp4,PT(AR_BSPSTORE)-PT(AR_PFS) // save ar.pfs
537 mov temp4=ar.bspstore
539 st8 [temp1]=temp3,PT(LOADRS)-PT(AR_RNAT) // save ar.rnat
540 st8 [temp2]=temp4,PT(AR_FPSR)-PT(AR_BSPSTORE) // save ar.bspstore
543 sub temp3=temp3, temp4 // ar.bsp - ar.bspstore
546 shl temp3=temp3,16 // compute ar.rsc to be used for "loadrs"
548 st8 [temp1]=temp3,PT(AR_CCV)-PT(LOADRS) // save loadrs
549 st8 [temp2]=temp4,PT(F6)-PT(AR_FPSR) // save ar.fpsr
552 st8 [temp1]=temp3,PT(F7)-PT(AR_CCV) // save ar.ccv
553 stf.spill [temp2]=f6,PT(F8)-PT(F6)
555 stf.spill [temp1]=f7,PT(F9)-PT(F7)
556 stf.spill [temp2]=f8,PT(F10)-PT(F8)
558 stf.spill [temp1]=f9,PT(F11)-PT(F9)
559 stf.spill [temp2]=f10
561 stf.spill [temp1]=f11
563 // Save the switch_stack data that is not in minstate nor pt_regs. The
564 // previous code left regs at pt_regs.
565 add regs=MCA_SWITCH_STACK_OFFSET-MCA_PT_REGS_OFFSET, regs
567 add temp1=SW(F2), regs
568 add temp2=SW(F3), regs
570 stf.spill [temp1]=f2,32
571 stf.spill [temp2]=f3,32
573 stf.spill [temp1]=f4,32
574 stf.spill [temp2]=f5,32
576 stf.spill [temp1]=f12,32
577 stf.spill [temp2]=f13,32
579 stf.spill [temp1]=f14,32
580 stf.spill [temp2]=f15,32
582 stf.spill [temp1]=f16,32
583 stf.spill [temp2]=f17,32
585 stf.spill [temp1]=f18,32
586 stf.spill [temp2]=f19,32
588 stf.spill [temp1]=f20,32
589 stf.spill [temp2]=f21,32
591 stf.spill [temp1]=f22,32
592 stf.spill [temp2]=f23,32
594 stf.spill [temp1]=f24,32
595 stf.spill [temp2]=f25,32
597 stf.spill [temp1]=f26,32
598 stf.spill [temp2]=f27,32
600 stf.spill [temp1]=f28,32
601 stf.spill [temp2]=f29,32
603 stf.spill [temp1]=f30,SW(B2)-SW(F30)
604 stf.spill [temp2]=f31,SW(B3)-SW(F31)
608 st8 [temp1]=temp3,16 // save b2
609 st8 [temp2]=temp4,16 // save b3
613 st8 [temp1]=temp3,SW(AR_LC)-SW(B4) // save b4
614 st8 [temp2]=temp4 // save b5
617 st8 [temp1]=temp3 // save ar.lc
619 // FIXME: Some proms are incorrectly accessing the minstate area as
620 // cached data. The C code uses region 6, uncached virtual. Ensure
621 // that there is no cache data lying around for the first 1K of the
623 // Remove this code in September 2006, that gives platforms a year to
624 // fix their proms and get their customers updated.
696 //EndStub//////////////////////////////////////////////////////////////////////
701 // ia64_state_restore()
705 // Restore the SAL/OS state. This is sensitive to the layout of struct
706 // ia64_sal_os_state in mca.h.
708 // r2 contains the return address, r3 contains either
709 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
711 // In addition to the SAL to OS state, this routine restores all the
712 // registers that appear in struct pt_regs and struct switch_stack,
713 // excluding those in the PAL minstate area.
718 // Restore the switch_stack data that is not in minstate nor pt_regs.
719 add regs=MCA_SWITCH_STACK_OFFSET, r3
720 mov b0=r2 // save return address
722 GET_IA64_MCA_DATA(temp2)
726 add temp1=SW(F2), regs
727 add temp2=SW(F3), regs
729 ldf.fill f2=[temp1],32
730 ldf.fill f3=[temp2],32
732 ldf.fill f4=[temp1],32
733 ldf.fill f5=[temp2],32
735 ldf.fill f12=[temp1],32
736 ldf.fill f13=[temp2],32
738 ldf.fill f14=[temp1],32
739 ldf.fill f15=[temp2],32
741 ldf.fill f16=[temp1],32
742 ldf.fill f17=[temp2],32
744 ldf.fill f18=[temp1],32
745 ldf.fill f19=[temp2],32
747 ldf.fill f20=[temp1],32
748 ldf.fill f21=[temp2],32
750 ldf.fill f22=[temp1],32
751 ldf.fill f23=[temp2],32
753 ldf.fill f24=[temp1],32
754 ldf.fill f25=[temp2],32
756 ldf.fill f26=[temp1],32
757 ldf.fill f27=[temp2],32
759 ldf.fill f28=[temp1],32
760 ldf.fill f29=[temp2],32
762 ldf.fill f30=[temp1],SW(B2)-SW(F30)
763 ldf.fill f31=[temp2],SW(B3)-SW(F31)
765 ld8 temp3=[temp1],16 // restore b2
766 ld8 temp4=[temp2],16 // restore b3
770 ld8 temp3=[temp1],SW(AR_LC)-SW(B4) // restore b4
771 ld8 temp4=[temp2] // restore b5
775 ld8 temp3=[temp1] // restore ar.lc
779 // Restore the pt_regs data that is not in minstate. The previous code
780 // left regs at switch_stack.
781 add regs=MCA_PT_REGS_OFFSET-MCA_SWITCH_STACK_OFFSET, regs
783 add temp1=PT(B6), regs
784 add temp2=PT(B7), regs
786 ld8 temp3=[temp1],PT(AR_CSD)-PT(B6) // restore b6
787 ld8 temp4=[temp2],PT(AR_SSD)-PT(B7) // restore b7
791 ld8 temp3=[temp1],PT(AR_UNAT)-PT(AR_CSD) // restore ar.csd
792 ld8 temp4=[temp2],PT(AR_PFS)-PT(AR_SSD) // restore ar.ssd
796 ld8 temp3=[temp1] // restore ar.unat
797 add temp1=PT(AR_CCV)-PT(AR_UNAT), temp1
798 ld8 temp4=[temp2],PT(AR_FPSR)-PT(AR_PFS) // restore ar.pfs
802 // ar.rnat, ar.bspstore, loadrs are restore in ia64_old_stack.
803 ld8 temp3=[temp1],PT(F6)-PT(AR_CCV) // restore ar.ccv
804 ld8 temp4=[temp2],PT(F7)-PT(AR_FPSR) // restore ar.fpsr
808 ldf.fill f6=[temp1],PT(F8)-PT(F6)
809 ldf.fill f7=[temp2],PT(F9)-PT(F7)
811 ldf.fill f8=[temp1],PT(F10)-PT(F8)
812 ldf.fill f9=[temp2],PT(F11)-PT(F9)
817 // Restore the SAL to OS state. The previous code left regs at pt_regs.
818 add regs=MCA_SOS_OFFSET-MCA_PT_REGS_OFFSET, regs
820 add temp1=SOS(SAL_RA), regs
821 add temp2=SOS(SAL_GP), regs
823 ld8 r12=[temp1],16 // sal_ra
824 ld8 r9=[temp2],16 // sal_gp
826 ld8 r22=[temp1],16 // pal_min_state, virtual
827 ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
829 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
830 ld8 r20=[temp2],16 // prev_task
832 ld8 temp3=[temp1],16 // cr.isr
833 ld8 temp4=[temp2],16 // cr.ifa
837 ld8 temp3=[temp1],16 // cr.itir
838 ld8 temp4=[temp2],16 // cr.iipa
842 ld8 temp3=[temp1] // cr.iim
843 ld8 temp4=[temp2] // cr.iha
844 add temp1=SOS(OS_STATUS), regs
845 add temp2=SOS(CONTEXT), regs
849 dep r22=0,r22,62,1 // pal_min_state, physical, uncached
850 mov IA64_KR(CURRENT)=r13
851 ld8 r8=[temp1] // os_status
852 ld8 r10=[temp2] // context
854 /* Wire IA64_TR_CURRENT_STACK to the stack that we are resuming to. To
855 * avoid any dependencies on the algorithm in ia64_switch_to(), just
856 * purge any existing CURRENT_STACK mapping and insert the new one.
858 * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
859 * prev_IA64_KR_CURRENT, these values may have been changed by the C
860 * code. Do not use r8, r9, r10, r22, they contain values ready for
864 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
866 shl r15=r15,IA64_GRANULE_SHIFT
868 dep r15=-1,r15,61,3 // virtual granule
869 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
875 extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
876 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
877 movl r21=PAGE_KERNEL // page properties
879 mov IA64_KR(CURRENT_STACK)=r16
880 cmp.ne p6,p0=RGN_KERNEL,r19 // new stack is in the kernel region?
881 or r21=r20,r21 // construct PA | page properties
882 (p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
886 mov r20=IA64_TR_CURRENT_STACK
895 //EndStub//////////////////////////////////////////////////////////////////////
904 // Switch to the MCA/INIT stack.
906 // r2 contains the return address, r3 contains either
907 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
909 // On entry RBS is still on the original stack, this routine switches RBS
910 // to use the MCA/INIT stack.
912 // On entry, sos->pal_min_state is physical, on exit it is virtual.
917 add regs=MCA_PT_REGS_OFFSET, r3
918 add temp2=MCA_SOS_OFFSET+SOS(PAL_MIN_STATE), r3
919 mov b0=r2 // save return address
920 GET_IA64_MCA_DATA(temp1)
923 add temp2=temp2, temp1 // struct ia64_sal_os_state.pal_min_state on MCA or INIT stack
924 add regs=regs, temp1 // struct pt_regs on MCA or INIT stack
926 // Address of minstate area provided by PAL is physical, uncacheable.
927 // Convert to Linux virtual address in region 6 for C code.
928 ld8 ms=[temp2] // pal_min_state, physical
930 dep temp1=-1,ms,62,2 // set region 6
931 mov temp3=IA64_RBS_OFFSET-MCA_PT_REGS_OFFSET
933 st8 [temp2]=temp1 // pal_min_state, virtual
935 add temp4=temp3, regs // start of bspstore on new stack
937 mov ar.bspstore=temp4 // switch RBS to MCA/INIT stack
939 flushrs // must be first in group
942 //EndStub//////////////////////////////////////////////////////////////////////
951 // Switch to the old stack.
953 // r2 contains the return address, r3 contains either
954 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
956 // On entry, pal_min_state is virtual, on exit it is physical.
958 // On entry RBS is on the MCA/INIT stack, this routine switches RBS
959 // back to the previous stack.
961 // The psr is set to all zeroes. SAL return requires either all zeroes or
962 // just psr.mc set. Leaving psr.mc off allows INIT to be issued if this
963 // code does not perform correctly.
965 // The dirty registers at the time of the event were flushed to the
966 // MCA/INIT stack in ia64_pt_regs_save(). Restore the dirty registers
967 // before reverting to the previous bspstore.
971 add regs=MCA_PT_REGS_OFFSET, r3
972 mov b0=r2 // save return address
973 GET_IA64_MCA_DATA(temp2)
974 LOAD_PHYSICAL(p0,temp1,1f)
984 add regs=regs, temp2 // struct pt_regs on MCA or INIT stack
986 add temp1=PT(LOADRS), regs
988 ld8 temp2=[temp1],PT(AR_BSPSTORE)-PT(LOADRS) // restore loadrs
990 ld8 temp3=[temp1],PT(AR_RNAT)-PT(AR_BSPSTORE) // restore ar.bspstore
994 ld8 temp4=[temp1] // restore ar.rnat
996 mov ar.bspstore=temp3 // back to old stack
1003 //EndStub//////////////////////////////////////////////////////////////////////
1008 // ia64_set_kernel_registers()
1010 // Stub Description:
1012 // Set the registers that are required by the C code in order to run on an
1015 // r2 contains the return address, r3 contains either
1016 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
1020 ia64_set_kernel_registers:
1021 add temp3=MCA_SP_OFFSET, r3
1022 mov b0=r2 // save return address
1023 GET_IA64_MCA_DATA(temp1)
1025 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
1026 add r13=temp1, r3 // set current to start of MCA/INIT stack
1027 add r20=temp1, r3 // physical start of MCA/INIT stack
1029 DATA_PA_TO_VA(r12,temp2)
1030 DATA_PA_TO_VA(r13,temp3)
1032 mov IA64_KR(CURRENT)=r13
1034 /* Wire IA64_TR_CURRENT_STACK to the MCA/INIT handler stack. To avoid
1035 * any dependencies on the algorithm in ia64_switch_to(), just purge
1036 * any existing CURRENT_STACK mapping and insert the new one.
1039 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1041 shl r16=r16,IA64_GRANULE_SHIFT
1043 dep r16=-1,r16,61,3 // virtual granule
1044 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1050 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1051 movl r21=PAGE_KERNEL // page properties
1053 mov IA64_KR(CURRENT_STACK)=r16
1054 or r21=r20,r21 // construct PA | page properties
1058 mov r20=IA64_TR_CURRENT_STACK
1060 movl r17=FPSR_DEFAULT
1062 mov.m ar.fpsr=r17 // set ar.fpsr to kernel default value
1070 //EndStub//////////////////////////////////////////////////////////////////////
1080 // Support function for mca.c, it is here to avoid using inline asm. Given the
1081 // address of an rnat slot, if that address is below the current ar.bspstore
1082 // then return the contents of that slot, otherwise return the contents of
1084 GLOBAL_ENTRY(ia64_get_rnat)
1085 alloc r14=ar.pfs,1,0,0,0
1090 cmp.lt p6,p7=in0,r14
1099 // void ia64_set_psr_mc(void)
1101 // Set psr.mc bit to mask MCA/INIT.
1102 GLOBAL_ENTRY(ia64_set_psr_mc)
1103 rsm psr.i | psr.ic // disable interrupts
1107 mov r14 = psr // get psr{36:35,31:0}
1110 dep r14 = -1, r14, PSR_MC, 1 // set psr.mc
1112 dep r14 = -1, r14, PSR_IC, 1 // set psr.ic
1114 dep r14 = -1, r14, PSR_BN, 1 // keep bank1 in use
1123 END(ia64_set_psr_mc)