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_on_kdump
44 .global ia64_os_init_dispatch_monarch
45 .global ia64_os_init_dispatch_slave
50 //StartMain////////////////////////////////////////////////////////////////////
53 * Just the TLB purge part is moved to a separate function
54 * so we can re-use the code for cpu hotplug code as well
55 * Caller should now setup b1, so we can branch once the
56 * tlb flush is complete.
60 #define O(member) IA64_CPUINFO_##member##_OFFSET
62 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
64 addl r17=O(PTCE_STRIDE),r2
65 addl r2=O(PTCE_BASE),r2
67 ld8 r18=[r2],(O(PTCE_COUNT)-O(PTCE_BASE));; // r18=ptce_base
68 ld4 r19=[r2],4 // r19=ptce_count[0]
69 ld4 r21=[r17],4 // r21=ptce_stride[0]
71 ld4 r20=[r2] // r20=ptce_count[1]
72 ld4 r22=[r17] // r22=ptce_stride[1]
81 (p7) br.cond.dpnt.few 4f
94 srlz.i // srlz.i implies srlz.d
97 // Now purge addresses formerly mapped by TR registers
98 // 1. Purge ITR&DTR for kernel.
100 mov r18=KERNEL_TR_PAGE_SHIFT<<2
109 // 3. Purge ITR for PAL code.
110 GET_THIS_PADDR(r2, ia64_mca_pal_base)
113 mov r18=IA64_GRANULE_SHIFT<<2
119 // 4. Purge DTR for stack.
120 mov r16=IA64_KR(CURRENT_STACK)
122 shl r16=r16,IA64_GRANULE_SHIFT
126 mov r18=IA64_GRANULE_SHIFT<<2
132 // Now branch away to caller.
136 //EndMain//////////////////////////////////////////////////////////////////////
138 //StartMain////////////////////////////////////////////////////////////////////
140 ia64_os_mca_dispatch:
141 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
142 LOAD_PHYSICAL(p0,r2,1f) // return address
143 mov r19=1 // All MCA events are treated as monarch (for now)
144 br.sptk ia64_state_save // save the state that is not in minstate
147 GET_IA64_MCA_DATA(r2)
148 // Using MCA stack, struct ia64_sal_os_state, variable proc_state_param
150 add r3=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET+SOS(PROC_STATE_PARAM), r2
152 ld8 r18=[r3] // Get processor state parameter on existing PALE_CHECK.
155 (p7) br.spnt done_tlb_purge_and_reload
157 // The following code purges TC and TR entries. Then reload all TC entries.
158 // Purge percpu data TC entries.
159 begin_tlb_purge_and_reload:
160 movl r18=ia64_reload_tr;;
161 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
163 br.sptk.many ia64_do_tlb_purge;;
166 // Finally reload the TR registers.
167 // 1. Reload DTR/ITR registers for kernel.
168 mov r18=KERNEL_TR_PAGE_SHIFT<<2
169 movl r17=KERNEL_START
173 mov r16=IA64_TR_KERNEL
177 dep r17=0,r19,0, KERNEL_TR_PAGE_SHIFT
188 // 3. Reload ITR for PAL code.
189 GET_THIS_PADDR(r2, ia64_mca_pal_pte)
191 ld8 r18=[r2] // load PAL PTE
193 GET_THIS_PADDR(r2, ia64_mca_pal_base)
195 ld8 r16=[r2] // load PAL vaddr
196 mov r19=IA64_GRANULE_SHIFT<<2
200 mov r20=IA64_TR_PALCODE
206 // 4. Reload DTR for stack.
207 mov r16=IA64_KR(CURRENT_STACK)
209 shl r16=r16,IA64_GRANULE_SHIFT
216 mov r19=IA64_GRANULE_SHIFT<<2
220 mov r20=IA64_TR_CURRENT_STACK
223 GET_THIS_PADDR(r2, ia64_mca_tr_reload)
231 done_tlb_purge_and_reload:
233 // switch to per cpu MCA stack
234 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
235 LOAD_PHYSICAL(p0,r2,1f) // return address
236 br.sptk ia64_new_stack
239 // everything saved, now we can set the kernel registers
240 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
241 LOAD_PHYSICAL(p0,r2,1f) // return address
242 br.sptk ia64_set_kernel_registers
245 // This must be done in physical mode
246 GET_IA64_MCA_DATA(r2)
250 // Enter virtual mode from physical mode
251 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_begin, r4)
253 // This code returns to SAL via SOS r2, in general SAL has no unwind
254 // data. To get a clean termination when backtracing the C MCA/INIT
255 // handler, set a dummy return address of 0 in this routine. That
256 // requires that ia64_os_mca_virtual_begin be a global function.
257 ENTRY(ia64_os_mca_virtual_begin)
262 mov ar.rsc=3 // set eager mode for C handler
263 mov r2=r7 // see GET_IA64_MCA_DATA above
266 // Call virtual mode handler
267 alloc r14=ar.pfs,0,0,3,0
271 add out0=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
272 add out1=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
273 add out2=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET, r2
274 br.call.sptk.many b0=ia64_mca_handler
276 // Revert back to physical mode before going back to SAL
277 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_end, r4)
278 ia64_os_mca_virtual_end:
280 END(ia64_os_mca_virtual_begin)
282 // switch back to previous stack
283 alloc r14=ar.pfs,0,0,0,0 // remove the MCA handler frame
284 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
285 LOAD_PHYSICAL(p0,r2,1f) // return address
286 br.sptk ia64_old_stack
289 mov r3=IA64_MCA_CPU_MCA_STACK_OFFSET // use the MCA stack
290 LOAD_PHYSICAL(p0,r2,1f) // return address
291 br.sptk ia64_state_restore // restore the SAL state
294 mov b0=r12 // SAL_CHECK return address
298 //EndMain//////////////////////////////////////////////////////////////////////
300 //StartMain////////////////////////////////////////////////////////////////////
303 // NOP init handler for kdump. In panic situation, we may receive INIT
304 // while kernel transition. Since we initialize registers on leave from
305 // current kernel, no longer monarch/slave handlers of current kernel in
306 // virtual mode are called safely.
307 // We can unregister these init handlers from SAL, however then the INIT
308 // will result in warmboot by SAL and we cannot retrieve the crashdump.
309 // Therefore register this NOP function to SAL, to prevent entering virtual
310 // mode and resulting warmboot by SAL.
312 ia64_os_init_on_kdump:
313 mov r8=r0 // IA64_INIT_RESUME
315 mov r22=r17 // *minstate
317 mov r10=r0 // return to same context
318 mov b0=r12 // SAL_CHECK return address
322 // SAL to OS entry point for INIT on all processors. This has been defined for
323 // registration purposes with SAL as a part of ia64_mca_init. Monarch and
324 // slave INIT have identical processing, except for the value of the
325 // sos->monarch flag in r19.
328 ia64_os_init_dispatch_monarch:
329 mov r19=1 // Bow, bow, ye lower middle classes!
330 br.sptk ia64_os_init_dispatch
332 ia64_os_init_dispatch_slave:
333 mov r19=0 // <igor>yeth, mathter</igor>
335 ia64_os_init_dispatch:
337 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
338 LOAD_PHYSICAL(p0,r2,1f) // return address
339 br.sptk ia64_state_save // save the state that is not in minstate
342 // switch to per cpu INIT stack
343 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
344 LOAD_PHYSICAL(p0,r2,1f) // return address
345 br.sptk ia64_new_stack
348 // everything saved, now we can set the kernel registers
349 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
350 LOAD_PHYSICAL(p0,r2,1f) // return address
351 br.sptk ia64_set_kernel_registers
354 // This must be done in physical mode
355 GET_IA64_MCA_DATA(r2)
359 // Enter virtual mode from physical mode
360 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_begin, r4)
362 // This code returns to SAL via SOS r2, in general SAL has no unwind
363 // data. To get a clean termination when backtracing the C MCA/INIT
364 // handler, set a dummy return address of 0 in this routine. That
365 // requires that ia64_os_init_virtual_begin be a global function.
366 ENTRY(ia64_os_init_virtual_begin)
371 mov ar.rsc=3 // set eager mode for C handler
372 mov r2=r7 // see GET_IA64_MCA_DATA above
375 // Call virtual mode handler
376 alloc r14=ar.pfs,0,0,3,0
380 add out0=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_PT_REGS_OFFSET, r2
381 add out1=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SWITCH_STACK_OFFSET, r2
382 add out2=IA64_MCA_CPU_INIT_STACK_OFFSET+MCA_SOS_OFFSET, r2
383 br.call.sptk.many b0=ia64_init_handler
385 // Revert back to physical mode before going back to SAL
386 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_end, r4)
387 ia64_os_init_virtual_end:
389 END(ia64_os_init_virtual_begin)
391 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
392 LOAD_PHYSICAL(p0,r2,1f) // return address
393 br.sptk ia64_state_restore // restore the SAL state
396 // switch back to previous stack
397 alloc r14=ar.pfs,0,0,0,0 // remove the INIT handler frame
398 mov r3=IA64_MCA_CPU_INIT_STACK_OFFSET // use the INIT stack
399 LOAD_PHYSICAL(p0,r2,1f) // return address
400 br.sptk ia64_old_stack
403 mov b0=r12 // SAL_CHECK return address
406 //EndMain//////////////////////////////////////////////////////////////////////
408 // common defines for the stubs
411 #define temp1 r2 /* careful, it overlaps with input registers */
412 #define temp2 r3 /* careful, it overlaps with input registers */
423 // Save the state that is not in minstate. This is sensitive to the layout of
424 // struct ia64_sal_os_state in mca.h.
426 // r2 contains the return address, r3 contains either
427 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
429 // The OS to SAL section of struct ia64_sal_os_state is set to a default
430 // value of cold boot (MCA) or warm boot (INIT) and return to the same
431 // context. ia64_sal_os_state is also used to hold some registers that
432 // need to be saved and restored across the stack switches.
434 // Most input registers to this stub come from PAL/SAL
435 // r1 os gp, physical
436 // r8 pal_proc entry point
437 // r9 sal_proc entry point
439 // r11 MCA - rendevzous state, INIT - reason code
440 // r12 sal return address
442 // r18 processor state parameter
443 // r19 monarch flag, set by the caller of this routine
445 // In addition to the SAL to OS state, this routine saves all the
446 // registers that appear in struct pt_regs and struct switch_stack,
447 // excluding those that are already in the PAL minstate area. This
448 // results in a partial pt_regs and switch_stack, the C code copies the
449 // remaining registers from PAL minstate to pt_regs and switch_stack. The
450 // resulting structures contain all the state of the original process when
451 // MCA/INIT occurred.
456 add regs=MCA_SOS_OFFSET, r3
457 add ms=MCA_SOS_OFFSET+8, r3
458 mov b0=r2 // save return address
459 cmp.eq p1,p2=IA64_MCA_CPU_MCA_STACK_OFFSET, r3
461 GET_IA64_MCA_DATA(temp2)
463 add temp1=temp2, regs // struct ia64_sal_os_state on MCA or INIT stack
464 add temp2=temp2, ms // struct ia64_sal_os_state+8 on MCA or INIT stack
466 mov regs=temp1 // save the start of sos
467 st8 [temp1]=r1,16 // os_gp
468 st8 [temp2]=r8,16 // pal_proc
470 st8 [temp1]=r9,16 // sal_proc
471 st8 [temp2]=r11,16 // rv_rc
474 st8 [temp1]=r18 // proc_state_param
475 st8 [temp2]=r19 // monarch
476 mov r6=IA64_KR(CURRENT)
477 add temp1=SOS(SAL_RA), regs
478 add temp2=SOS(SAL_GP), regs
480 st8 [temp1]=r12,16 // sal_ra
481 st8 [temp2]=r10,16 // sal_gp
484 st8 [temp1]=r17,16 // pal_min_state
485 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
486 mov r6=IA64_KR(CURRENT_STACK)
488 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
489 st8 [temp2]=r0,16 // prev_task, starts off as NULL
492 st8 [temp1]=r12,16 // cr.isr
493 st8 [temp2]=r6,16 // cr.ifa
496 st8 [temp1]=r12,16 // cr.itir
497 st8 [temp2]=r11,16 // cr.iipa
500 st8 [temp1]=r12 // cr.iim
501 (p1) mov r12=IA64_MCA_COLD_BOOT
502 (p2) mov r12=IA64_INIT_WARM_BOOT
504 add temp1=SOS(OS_STATUS), regs
506 st8 [temp2]=r6 // cr.iha
507 add temp2=SOS(CONTEXT), regs
508 st8 [temp1]=r12 // os_status, default is cold boot
509 mov r6=IA64_MCA_SAME_CONTEXT
511 st8 [temp2]=r6 // context, default is same context
513 // Save the pt_regs data that is not in minstate. The previous code
515 add regs=MCA_PT_REGS_OFFSET-MCA_SOS_OFFSET, regs
517 add temp1=PT(B6), regs
520 add temp2=PT(B7), regs
522 st8 [temp1]=temp3,PT(AR_CSD)-PT(B6) // save b6
523 st8 [temp2]=temp4,PT(AR_SSD)-PT(B7) // save b7
526 cover // must be last in group
528 st8 [temp1]=temp3,PT(AR_UNAT)-PT(AR_CSD) // save ar.csd
529 st8 [temp2]=temp4,PT(AR_PFS)-PT(AR_SSD) // save ar.ssd
533 st8 [temp1]=temp3,PT(AR_RNAT)-PT(AR_UNAT) // save ar.unat
534 st8 [temp2]=temp4,PT(AR_BSPSTORE)-PT(AR_PFS) // save ar.pfs
536 mov temp4=ar.bspstore
538 st8 [temp1]=temp3,PT(LOADRS)-PT(AR_RNAT) // save ar.rnat
539 st8 [temp2]=temp4,PT(AR_FPSR)-PT(AR_BSPSTORE) // save ar.bspstore
542 sub temp3=temp3, temp4 // ar.bsp - ar.bspstore
545 shl temp3=temp3,16 // compute ar.rsc to be used for "loadrs"
547 st8 [temp1]=temp3,PT(AR_CCV)-PT(LOADRS) // save loadrs
548 st8 [temp2]=temp4,PT(F6)-PT(AR_FPSR) // save ar.fpsr
551 st8 [temp1]=temp3,PT(F7)-PT(AR_CCV) // save ar.ccv
552 stf.spill [temp2]=f6,PT(F8)-PT(F6)
554 stf.spill [temp1]=f7,PT(F9)-PT(F7)
555 stf.spill [temp2]=f8,PT(F10)-PT(F8)
557 stf.spill [temp1]=f9,PT(F11)-PT(F9)
558 stf.spill [temp2]=f10
560 stf.spill [temp1]=f11
562 // Save the switch_stack data that is not in minstate nor pt_regs. The
563 // previous code left regs at pt_regs.
564 add regs=MCA_SWITCH_STACK_OFFSET-MCA_PT_REGS_OFFSET, regs
566 add temp1=SW(F2), regs
567 add temp2=SW(F3), regs
569 stf.spill [temp1]=f2,32
570 stf.spill [temp2]=f3,32
572 stf.spill [temp1]=f4,32
573 stf.spill [temp2]=f5,32
575 stf.spill [temp1]=f12,32
576 stf.spill [temp2]=f13,32
578 stf.spill [temp1]=f14,32
579 stf.spill [temp2]=f15,32
581 stf.spill [temp1]=f16,32
582 stf.spill [temp2]=f17,32
584 stf.spill [temp1]=f18,32
585 stf.spill [temp2]=f19,32
587 stf.spill [temp1]=f20,32
588 stf.spill [temp2]=f21,32
590 stf.spill [temp1]=f22,32
591 stf.spill [temp2]=f23,32
593 stf.spill [temp1]=f24,32
594 stf.spill [temp2]=f25,32
596 stf.spill [temp1]=f26,32
597 stf.spill [temp2]=f27,32
599 stf.spill [temp1]=f28,32
600 stf.spill [temp2]=f29,32
602 stf.spill [temp1]=f30,SW(B2)-SW(F30)
603 stf.spill [temp2]=f31,SW(B3)-SW(F31)
607 st8 [temp1]=temp3,16 // save b2
608 st8 [temp2]=temp4,16 // save b3
612 st8 [temp1]=temp3,SW(AR_LC)-SW(B4) // save b4
613 st8 [temp2]=temp4 // save b5
616 st8 [temp1]=temp3 // save ar.lc
618 // FIXME: Some proms are incorrectly accessing the minstate area as
619 // cached data. The C code uses region 6, uncached virtual. Ensure
620 // that there is no cache data lying around for the first 1K of the
622 // Remove this code in September 2006, that gives platforms a year to
623 // fix their proms and get their customers updated.
695 //EndStub//////////////////////////////////////////////////////////////////////
700 // ia64_state_restore()
704 // Restore the SAL/OS state. This is sensitive to the layout of struct
705 // ia64_sal_os_state in mca.h.
707 // r2 contains the return address, r3 contains either
708 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
710 // In addition to the SAL to OS state, this routine restores all the
711 // registers that appear in struct pt_regs and struct switch_stack,
712 // excluding those in the PAL minstate area.
717 // Restore the switch_stack data that is not in minstate nor pt_regs.
718 add regs=MCA_SWITCH_STACK_OFFSET, r3
719 mov b0=r2 // save return address
721 GET_IA64_MCA_DATA(temp2)
725 add temp1=SW(F2), regs
726 add temp2=SW(F3), regs
728 ldf.fill f2=[temp1],32
729 ldf.fill f3=[temp2],32
731 ldf.fill f4=[temp1],32
732 ldf.fill f5=[temp2],32
734 ldf.fill f12=[temp1],32
735 ldf.fill f13=[temp2],32
737 ldf.fill f14=[temp1],32
738 ldf.fill f15=[temp2],32
740 ldf.fill f16=[temp1],32
741 ldf.fill f17=[temp2],32
743 ldf.fill f18=[temp1],32
744 ldf.fill f19=[temp2],32
746 ldf.fill f20=[temp1],32
747 ldf.fill f21=[temp2],32
749 ldf.fill f22=[temp1],32
750 ldf.fill f23=[temp2],32
752 ldf.fill f24=[temp1],32
753 ldf.fill f25=[temp2],32
755 ldf.fill f26=[temp1],32
756 ldf.fill f27=[temp2],32
758 ldf.fill f28=[temp1],32
759 ldf.fill f29=[temp2],32
761 ldf.fill f30=[temp1],SW(B2)-SW(F30)
762 ldf.fill f31=[temp2],SW(B3)-SW(F31)
764 ld8 temp3=[temp1],16 // restore b2
765 ld8 temp4=[temp2],16 // restore b3
769 ld8 temp3=[temp1],SW(AR_LC)-SW(B4) // restore b4
770 ld8 temp4=[temp2] // restore b5
774 ld8 temp3=[temp1] // restore ar.lc
778 // Restore the pt_regs data that is not in minstate. The previous code
779 // left regs at switch_stack.
780 add regs=MCA_PT_REGS_OFFSET-MCA_SWITCH_STACK_OFFSET, regs
782 add temp1=PT(B6), regs
783 add temp2=PT(B7), regs
785 ld8 temp3=[temp1],PT(AR_CSD)-PT(B6) // restore b6
786 ld8 temp4=[temp2],PT(AR_SSD)-PT(B7) // restore b7
790 ld8 temp3=[temp1],PT(AR_UNAT)-PT(AR_CSD) // restore ar.csd
791 ld8 temp4=[temp2],PT(AR_PFS)-PT(AR_SSD) // restore ar.ssd
795 ld8 temp3=[temp1] // restore ar.unat
796 add temp1=PT(AR_CCV)-PT(AR_UNAT), temp1
797 ld8 temp4=[temp2],PT(AR_FPSR)-PT(AR_PFS) // restore ar.pfs
801 // ar.rnat, ar.bspstore, loadrs are restore in ia64_old_stack.
802 ld8 temp3=[temp1],PT(F6)-PT(AR_CCV) // restore ar.ccv
803 ld8 temp4=[temp2],PT(F7)-PT(AR_FPSR) // restore ar.fpsr
807 ldf.fill f6=[temp1],PT(F8)-PT(F6)
808 ldf.fill f7=[temp2],PT(F9)-PT(F7)
810 ldf.fill f8=[temp1],PT(F10)-PT(F8)
811 ldf.fill f9=[temp2],PT(F11)-PT(F9)
816 // Restore the SAL to OS state. The previous code left regs at pt_regs.
817 add regs=MCA_SOS_OFFSET-MCA_PT_REGS_OFFSET, regs
819 add temp1=SOS(SAL_RA), regs
820 add temp2=SOS(SAL_GP), regs
822 ld8 r12=[temp1],16 // sal_ra
823 ld8 r9=[temp2],16 // sal_gp
825 ld8 r22=[temp1],16 // pal_min_state, virtual
826 ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
828 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
829 ld8 r20=[temp2],16 // prev_task
831 ld8 temp3=[temp1],16 // cr.isr
832 ld8 temp4=[temp2],16 // cr.ifa
836 ld8 temp3=[temp1],16 // cr.itir
837 ld8 temp4=[temp2],16 // cr.iipa
841 ld8 temp3=[temp1] // cr.iim
842 ld8 temp4=[temp2] // cr.iha
843 add temp1=SOS(OS_STATUS), regs
844 add temp2=SOS(CONTEXT), regs
848 dep r22=0,r22,62,1 // pal_min_state, physical, uncached
849 mov IA64_KR(CURRENT)=r13
850 ld8 r8=[temp1] // os_status
851 ld8 r10=[temp2] // context
853 /* Wire IA64_TR_CURRENT_STACK to the stack that we are resuming to. To
854 * avoid any dependencies on the algorithm in ia64_switch_to(), just
855 * purge any existing CURRENT_STACK mapping and insert the new one.
857 * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
858 * prev_IA64_KR_CURRENT, these values may have been changed by the C
859 * code. Do not use r8, r9, r10, r22, they contain values ready for
863 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
865 shl r15=r15,IA64_GRANULE_SHIFT
867 dep r15=-1,r15,61,3 // virtual granule
868 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
874 extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
875 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
876 movl r21=PAGE_KERNEL // page properties
878 mov IA64_KR(CURRENT_STACK)=r16
879 cmp.ne p6,p0=RGN_KERNEL,r19 // new stack is in the kernel region?
880 or r21=r20,r21 // construct PA | page properties
881 (p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
885 mov r20=IA64_TR_CURRENT_STACK
894 //EndStub//////////////////////////////////////////////////////////////////////
903 // Switch to the MCA/INIT stack.
905 // r2 contains the return address, r3 contains either
906 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
908 // On entry RBS is still on the original stack, this routine switches RBS
909 // to use the MCA/INIT stack.
911 // On entry, sos->pal_min_state is physical, on exit it is virtual.
916 add regs=MCA_PT_REGS_OFFSET, r3
917 add temp2=MCA_SOS_OFFSET+SOS(PAL_MIN_STATE), r3
918 mov b0=r2 // save return address
919 GET_IA64_MCA_DATA(temp1)
922 add temp2=temp2, temp1 // struct ia64_sal_os_state.pal_min_state on MCA or INIT stack
923 add regs=regs, temp1 // struct pt_regs on MCA or INIT stack
925 // Address of minstate area provided by PAL is physical, uncacheable.
926 // Convert to Linux virtual address in region 6 for C code.
927 ld8 ms=[temp2] // pal_min_state, physical
929 dep temp1=-1,ms,62,2 // set region 6
930 mov temp3=IA64_RBS_OFFSET-MCA_PT_REGS_OFFSET
932 st8 [temp2]=temp1 // pal_min_state, virtual
934 add temp4=temp3, regs // start of bspstore on new stack
936 mov ar.bspstore=temp4 // switch RBS to MCA/INIT stack
938 flushrs // must be first in group
941 //EndStub//////////////////////////////////////////////////////////////////////
950 // Switch to the old stack.
952 // r2 contains the return address, r3 contains either
953 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
955 // On entry, pal_min_state is virtual, on exit it is physical.
957 // On entry RBS is on the MCA/INIT stack, this routine switches RBS
958 // back to the previous stack.
960 // The psr is set to all zeroes. SAL return requires either all zeroes or
961 // just psr.mc set. Leaving psr.mc off allows INIT to be issued if this
962 // code does not perform correctly.
964 // The dirty registers at the time of the event were flushed to the
965 // MCA/INIT stack in ia64_pt_regs_save(). Restore the dirty registers
966 // before reverting to the previous bspstore.
970 add regs=MCA_PT_REGS_OFFSET, r3
971 mov b0=r2 // save return address
972 GET_IA64_MCA_DATA(temp2)
973 LOAD_PHYSICAL(p0,temp1,1f)
983 add regs=regs, temp2 // struct pt_regs on MCA or INIT stack
985 add temp1=PT(LOADRS), regs
987 ld8 temp2=[temp1],PT(AR_BSPSTORE)-PT(LOADRS) // restore loadrs
989 ld8 temp3=[temp1],PT(AR_RNAT)-PT(AR_BSPSTORE) // restore ar.bspstore
993 ld8 temp4=[temp1] // restore ar.rnat
995 mov ar.bspstore=temp3 // back to old stack
1002 //EndStub//////////////////////////////////////////////////////////////////////
1007 // ia64_set_kernel_registers()
1009 // Stub Description:
1011 // Set the registers that are required by the C code in order to run on an
1014 // r2 contains the return address, r3 contains either
1015 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
1019 ia64_set_kernel_registers:
1020 add temp3=MCA_SP_OFFSET, r3
1021 mov b0=r2 // save return address
1022 GET_IA64_MCA_DATA(temp1)
1024 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
1025 add r13=temp1, r3 // set current to start of MCA/INIT stack
1026 add r20=temp1, r3 // physical start of MCA/INIT stack
1028 DATA_PA_TO_VA(r12,temp2)
1029 DATA_PA_TO_VA(r13,temp3)
1031 mov IA64_KR(CURRENT)=r13
1033 /* Wire IA64_TR_CURRENT_STACK to the MCA/INIT handler stack. To avoid
1034 * any dependencies on the algorithm in ia64_switch_to(), just purge
1035 * any existing CURRENT_STACK mapping and insert the new one.
1038 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1040 shl r16=r16,IA64_GRANULE_SHIFT
1042 dep r16=-1,r16,61,3 // virtual granule
1043 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1049 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1050 movl r21=PAGE_KERNEL // page properties
1052 mov IA64_KR(CURRENT_STACK)=r16
1053 or r21=r20,r21 // construct PA | page properties
1057 mov r20=IA64_TR_CURRENT_STACK
1059 movl r17=FPSR_DEFAULT
1061 mov.m ar.fpsr=r17 // set ar.fpsr to kernel default value
1069 //EndStub//////////////////////////////////////////////////////////////////////
1079 // Support function for mca.c, it is here to avoid using inline asm. Given the
1080 // address of an rnat slot, if that address is below the current ar.bspstore
1081 // then return the contents of that slot, otherwise return the contents of
1083 GLOBAL_ENTRY(ia64_get_rnat)
1084 alloc r14=ar.pfs,1,0,0,0
1089 cmp.lt p6,p7=in0,r14
1098 // void ia64_set_psr_mc(void)
1100 // Set psr.mc bit to mask MCA/INIT.
1101 GLOBAL_ENTRY(ia64_set_psr_mc)
1102 rsm psr.i | psr.ic // disable interrupts
1106 mov r14 = psr // get psr{36:35,31:0}
1109 dep r14 = -1, r14, PSR_MC, 1 // set psr.mc
1111 dep r14 = -1, r14, PSR_IC, 1 // set psr.ic
1113 dep r14 = -1, r14, PSR_BN, 1 // keep bank1 in use
1122 END(ia64_set_psr_mc)