2 // assembly portion of the IA64 MCA handling
4 // Mods by cfleck to integrate into kernel build
5 // 00/03/15 davidm Added various stop bits to get a clean compile
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
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
16 // 04/11/12 Russ Anderson <rja@sgi.com>
17 // Added per cpu MCA/INIT stack save areas.
19 // 12/08/05 Keith Owens <kaos@sgi.com>
20 // Use per cpu MCA/INIT stacks for all data.
22 #include <linux/config.h>
23 #include <linux/threads.h>
25 #include <asm/asmmacro.h>
26 #include <asm/pgtable.h>
27 #include <asm/processor.h>
28 #include <asm/mca_asm.h>
33 #define GET_IA64_MCA_DATA(reg) \
34 GET_THIS_PADDR(reg, ia64_mca_data) \
38 .global ia64_do_tlb_purge
39 .global ia64_os_mca_dispatch
40 .global ia64_os_init_dispatch_monarch
41 .global ia64_os_init_dispatch_slave
46 //StartMain////////////////////////////////////////////////////////////////////
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.
56 #define O(member) IA64_CPUINFO_##member##_OFFSET
58 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
60 addl r17=O(PTCE_STRIDE),r2
61 addl r2=O(PTCE_BASE),r2
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]
67 ld4 r20=[r2] // r20=ptce_count[1]
68 ld4 r22=[r17] // r22=ptce_stride[1]
77 (p7) br.cond.dpnt.few 4f
90 srlz.i // srlz.i implies srlz.d
93 // Now purge addresses formerly mapped by TR registers
94 // 1. Purge ITR&DTR for kernel.
96 mov r18=KERNEL_TR_PAGE_SHIFT<<2
105 // 2. Purge DTR for PERCPU data.
107 mov r18=PERCPU_PAGE_SHIFT<<2
113 // 3. Purge ITR for PAL code.
114 GET_THIS_PADDR(r2, ia64_mca_pal_base)
117 mov r18=IA64_GRANULE_SHIFT<<2
123 // 4. Purge DTR for stack.
124 mov r16=IA64_KR(CURRENT_STACK)
126 shl r16=r16,IA64_GRANULE_SHIFT
130 mov r18=IA64_GRANULE_SHIFT<<2
136 // Now branch away to caller.
140 //EndMain//////////////////////////////////////////////////////////////////////
142 //StartMain////////////////////////////////////////////////////////////////////
144 ia64_os_mca_dispatch:
145 // Serialize all MCA processing
147 LOAD_PHYSICAL(p0,r2,ia64_mca_serialize);;
151 (p6) br ia64_os_mca_spin
153 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
159 GET_IA64_MCA_DATA(r2)
160 // Using MCA stack, struct ia64_sal_os_state, variable proc_state_param
162 add r3=IA64_MCA_CPU_MCA_STACK_OFFSET+MCA_SOS_OFFSET+SOS(PROC_STATE_PARAM), r2
164 ld8 r18=[r3] // Get processor state parameter on existing PALE_CHECK.
167 (p7) br.spnt done_tlb_purge_and_reload
169 // The following code purges TC and TR entries. Then reload all TC entries.
170 // Purge percpu data TC entries.
171 begin_tlb_purge_and_reload:
172 movl r18=ia64_reload_tr;;
173 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
175 br.sptk.many ia64_do_tlb_purge;;
178 // 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
185 mov r16=IA64_TR_KERNEL
189 dep r17=0,r19,0, KERNEL_TR_PAGE_SHIFT
200 // 2. Reload DTR register for PERCPU data.
201 GET_THIS_PADDR(r2, ia64_mca_per_cpu_pte)
203 movl r16=PERCPU_ADDR // vaddr
204 movl r18=PERCPU_PAGE_SHIFT<<2
209 ld8 r18=[r2] // load per-CPU PTE
210 mov r16=IA64_TR_PERCPU_DATA;
216 // 3. Reload ITR for PAL code.
217 GET_THIS_PADDR(r2, ia64_mca_pal_pte)
219 ld8 r18=[r2] // load PAL PTE
221 GET_THIS_PADDR(r2, ia64_mca_pal_base)
223 ld8 r16=[r2] // load PAL vaddr
224 mov r19=IA64_GRANULE_SHIFT<<2
228 mov r20=IA64_TR_PALCODE
234 // 4. Reload DTR for stack.
235 mov r16=IA64_KR(CURRENT_STACK)
237 shl r16=r16,IA64_GRANULE_SHIFT
244 mov r19=IA64_GRANULE_SHIFT<<2
248 mov r20=IA64_TR_CURRENT_STACK
254 done_tlb_purge_and_reload:
256 // 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
262 // 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
268 // This must be done in physical mode
269 GET_IA64_MCA_DATA(r2)
273 // Enter virtual mode from physical mode
274 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_begin, r4)
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.
280 ENTRY(ia64_os_mca_virtual_begin)
285 mov ar.rsc=3 // set eager mode for C handler
286 mov r2=r7 // see GET_IA64_MCA_DATA above
289 // Call virtual mode handler
290 alloc r14=ar.pfs,0,0,3,0
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
299 // Revert back to physical mode before going back to SAL
300 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_mca_virtual_end, r4)
301 ia64_os_mca_virtual_end:
303 END(ia64_os_mca_virtual_begin)
305 // 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
312 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
317 mov b0=r12 // SAL_CHECK return address
320 LOAD_PHYSICAL(p0,r3,ia64_mca_serialize);;
325 //EndMain//////////////////////////////////////////////////////////////////////
327 //StartMain////////////////////////////////////////////////////////////////////
330 // 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.
336 ia64_os_init_dispatch_monarch:
337 mov r19=1 // Bow, bow, ye lower middle classes!
338 br.sptk ia64_os_init_dispatch
340 ia64_os_init_dispatch_slave:
341 mov r19=0 // <igor>yeth, mathter</igor>
343 ia64_os_init_dispatch:
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
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
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
362 // This must be done in physical mode
363 GET_IA64_MCA_DATA(r2)
367 // Enter virtual mode from physical mode
368 VIRTUAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_begin, r4)
370 // 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.
374 ENTRY(ia64_os_init_virtual_begin)
379 mov ar.rsc=3 // set eager mode for C handler
380 mov r2=r7 // see GET_IA64_MCA_DATA above
383 // Call virtual mode handler
384 alloc r14=ar.pfs,0,0,3,0
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
393 // Revert back to physical mode before going back to SAL
394 PHYSICAL_MODE_ENTER(r2, r3, ia64_os_init_virtual_end, r4)
395 ia64_os_init_virtual_end:
397 END(ia64_os_init_virtual_begin)
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
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
411 mov b0=r12 // SAL_CHECK return address
414 //EndMain//////////////////////////////////////////////////////////////////////
416 // common defines for the stubs
419 #define temp1 r2 /* careful, it overlaps with input registers */
420 #define temp2 r3 /* careful, it overlaps with input registers */
431 // Save the state that is not in minstate. This is sensitive to the layout of
432 // struct ia64_sal_os_state in mca.h.
434 // r2 contains the return address, r3 contains either
435 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
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.
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
447 // r11 MCA - rendevzous state, INIT - reason code
448 // r12 sal return address
450 // r18 processor state parameter
451 // r19 monarch flag, set by the caller of this routine
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.
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
469 GET_IA64_MCA_DATA(temp2)
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
474 mov regs=temp1 // save the start of sos
475 st8 [temp1]=r1,16 // os_gp
476 st8 [temp2]=r8,16 // pal_proc
478 st8 [temp1]=r9,16 // sal_proc
479 st8 [temp2]=r11,16 // rv_rc
482 st8 [temp1]=r18 // proc_state_param
483 st8 [temp2]=r19 // monarch
484 mov r6=IA64_KR(CURRENT)
485 add temp1=SOS(SAL_RA), regs
486 add temp2=SOS(SAL_GP), regs
488 st8 [temp1]=r12,16 // sal_ra
489 st8 [temp2]=r10,16 // sal_gp
492 st8 [temp1]=r17,16 // pal_min_state
493 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
494 mov r6=IA64_KR(CURRENT_STACK)
496 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
497 st8 [temp2]=r0,16 // prev_task, starts off as NULL
500 st8 [temp1]=r12,16 // cr.isr
501 st8 [temp2]=r6,16 // cr.ifa
504 st8 [temp1]=r12,16 // cr.itir
505 st8 [temp2]=r11,16 // cr.iipa
508 st8 [temp1]=r12 // cr.iim
509 (p1) mov r12=IA64_MCA_COLD_BOOT
510 (p2) mov r12=IA64_INIT_WARM_BOOT
512 add temp1=SOS(OS_STATUS), regs
514 st8 [temp2]=r6 // cr.iha
515 add temp2=SOS(CONTEXT), regs
516 st8 [temp1]=r12 // os_status, default is cold boot
517 mov r6=IA64_MCA_SAME_CONTEXT
519 st8 [temp2]=r6 // context, default is same context
521 // Save the pt_regs data that is not in minstate. The previous code
523 add regs=MCA_PT_REGS_OFFSET-MCA_SOS_OFFSET, regs
525 add temp1=PT(B6), regs
528 add temp2=PT(B7), regs
530 st8 [temp1]=temp3,PT(AR_CSD)-PT(B6) // save b6
531 st8 [temp2]=temp4,PT(AR_SSD)-PT(B7) // save b7
534 cover // must be last in group
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
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
544 mov temp4=ar.bspstore
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
550 sub temp3=temp3, temp4 // ar.bsp - ar.bspstore
553 shl temp3=temp3,16 // compute ar.rsc to be used for "loadrs"
555 st8 [temp1]=temp3,PT(AR_CCV)-PT(LOADRS) // save loadrs
556 st8 [temp2]=temp4,PT(F6)-PT(AR_FPSR) // save ar.fpsr
559 st8 [temp1]=temp3,PT(F7)-PT(AR_CCV) // save ar.ccv
560 stf.spill [temp2]=f6,PT(F8)-PT(F6)
562 stf.spill [temp1]=f7,PT(F9)-PT(F7)
563 stf.spill [temp2]=f8,PT(F10)-PT(F8)
565 stf.spill [temp1]=f9,PT(F11)-PT(F9)
566 stf.spill [temp2]=f10
568 stf.spill [temp1]=f11
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
574 add temp1=SW(F2), regs
575 add temp2=SW(F3), regs
577 stf.spill [temp1]=f2,32
578 stf.spill [temp2]=f3,32
580 stf.spill [temp1]=f4,32
581 stf.spill [temp2]=f5,32
583 stf.spill [temp1]=f12,32
584 stf.spill [temp2]=f13,32
586 stf.spill [temp1]=f14,32
587 stf.spill [temp2]=f15,32
589 stf.spill [temp1]=f16,32
590 stf.spill [temp2]=f17,32
592 stf.spill [temp1]=f18,32
593 stf.spill [temp2]=f19,32
595 stf.spill [temp1]=f20,32
596 stf.spill [temp2]=f21,32
598 stf.spill [temp1]=f22,32
599 stf.spill [temp2]=f23,32
601 stf.spill [temp1]=f24,32
602 stf.spill [temp2]=f25,32
604 stf.spill [temp1]=f26,32
605 stf.spill [temp2]=f27,32
607 stf.spill [temp1]=f28,32
608 stf.spill [temp2]=f29,32
610 stf.spill [temp1]=f30,SW(B2)-SW(F30)
611 stf.spill [temp2]=f31,SW(B3)-SW(F31)
615 st8 [temp1]=temp3,16 // save b2
616 st8 [temp2]=temp4,16 // save b3
620 st8 [temp1]=temp3,SW(AR_LC)-SW(B4) // save b4
621 st8 [temp2]=temp4 // save b5
624 st8 [temp1]=temp3 // save ar.lc
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
630 // Remove this code in September 2006, that gives platforms a year to
631 // fix their proms and get their customers updated.
703 //EndStub//////////////////////////////////////////////////////////////////////
708 // ia64_state_restore()
712 // Restore the SAL/OS state. This is sensitive to the layout of struct
713 // ia64_sal_os_state in mca.h.
715 // r2 contains the return address, r3 contains either
716 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
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.
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
729 GET_IA64_MCA_DATA(temp2)
733 add temp1=SW(F2), regs
734 add temp2=SW(F3), regs
736 ldf.fill f2=[temp1],32
737 ldf.fill f3=[temp2],32
739 ldf.fill f4=[temp1],32
740 ldf.fill f5=[temp2],32
742 ldf.fill f12=[temp1],32
743 ldf.fill f13=[temp2],32
745 ldf.fill f14=[temp1],32
746 ldf.fill f15=[temp2],32
748 ldf.fill f16=[temp1],32
749 ldf.fill f17=[temp2],32
751 ldf.fill f18=[temp1],32
752 ldf.fill f19=[temp2],32
754 ldf.fill f20=[temp1],32
755 ldf.fill f21=[temp2],32
757 ldf.fill f22=[temp1],32
758 ldf.fill f23=[temp2],32
760 ldf.fill f24=[temp1],32
761 ldf.fill f25=[temp2],32
763 ldf.fill f26=[temp1],32
764 ldf.fill f27=[temp2],32
766 ldf.fill f28=[temp1],32
767 ldf.fill f29=[temp2],32
769 ldf.fill f30=[temp1],SW(B2)-SW(F30)
770 ldf.fill f31=[temp2],SW(B3)-SW(F31)
772 ld8 temp3=[temp1],16 // restore b2
773 ld8 temp4=[temp2],16 // restore b3
777 ld8 temp3=[temp1],SW(AR_LC)-SW(B4) // restore b4
778 ld8 temp4=[temp2] // restore b5
782 ld8 temp3=[temp1] // restore ar.lc
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
790 add temp1=PT(B6), regs
791 add temp2=PT(B7), regs
793 ld8 temp3=[temp1],PT(AR_CSD)-PT(B6) // restore b6
794 ld8 temp4=[temp2],PT(AR_SSD)-PT(B7) // restore b7
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
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
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
815 ldf.fill f6=[temp1],PT(F8)-PT(F6)
816 ldf.fill f7=[temp2],PT(F9)-PT(F7)
818 ldf.fill f8=[temp1],PT(F10)-PT(F8)
819 ldf.fill f9=[temp2],PT(F11)-PT(F9)
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
827 add temp1=SOS(SAL_RA), regs
828 add temp2=SOS(SAL_GP), regs
830 ld8 r12=[temp1],16 // sal_ra
831 ld8 r9=[temp2],16 // sal_gp
833 ld8 r22=[temp1],16 // pal_min_state, virtual
834 ld8 r13=[temp2],16 // prev_IA64_KR_CURRENT
836 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
837 ld8 r20=[temp2],16 // prev_task
839 ld8 temp3=[temp1],16 // cr.isr
840 ld8 temp4=[temp2],16 // cr.ifa
844 ld8 temp3=[temp1],16 // cr.itir
845 ld8 temp4=[temp2],16 // cr.iipa
849 ld8 temp3=[temp1] // cr.iim
850 ld8 temp4=[temp2] // cr.iha
851 add temp1=SOS(OS_STATUS), regs
852 add temp2=SOS(CONTEXT), regs
856 dep r22=0,r22,62,1 // pal_min_state, physical, uncached
857 mov IA64_KR(CURRENT)=r13
858 ld8 r8=[temp1] // os_status
859 ld8 r10=[temp2] // context
861 /* 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.
865 * r16 contains prev_IA64_KR_CURRENT_STACK, r13 contains
866 * 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
871 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
873 shl r15=r15,IA64_GRANULE_SHIFT
875 dep r15=-1,r15,61,3 // virtual granule
876 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
882 extr.u r19=r13,61,3 // r13 = prev_IA64_KR_CURRENT
883 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
884 movl r21=PAGE_KERNEL // page properties
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:(
893 mov r20=IA64_TR_CURRENT_STACK
902 //EndStub//////////////////////////////////////////////////////////////////////
911 // Switch to the MCA/INIT stack.
913 // r2 contains the return address, r3 contains either
914 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
916 // On entry RBS is still on the original stack, this routine switches RBS
917 // to use the MCA/INIT stack.
919 // On entry, sos->pal_min_state is physical, on exit it is virtual.
924 add regs=MCA_PT_REGS_OFFSET, r3
925 add temp2=MCA_SOS_OFFSET+SOS(PAL_MIN_STATE), r3
926 mov b0=r2 // save return address
927 GET_IA64_MCA_DATA(temp1)
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
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
937 dep temp1=-1,ms,62,2 // set region 6
938 mov temp3=IA64_RBS_OFFSET-MCA_PT_REGS_OFFSET
940 st8 [temp2]=temp1 // pal_min_state, virtual
942 add temp4=temp3, regs // start of bspstore on new stack
944 mov ar.bspstore=temp4 // switch RBS to MCA/INIT stack
946 flushrs // must be first in group
949 //EndStub//////////////////////////////////////////////////////////////////////
958 // Switch to the old stack.
960 // r2 contains the return address, r3 contains either
961 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
963 // On entry, pal_min_state is virtual, on exit it is physical.
965 // On entry RBS is on the MCA/INIT stack, this routine switches RBS
966 // back to the previous stack.
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.
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.
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)
991 add regs=regs, temp2 // struct pt_regs on MCA or INIT stack
993 add temp1=PT(LOADRS), regs
995 ld8 temp2=[temp1],PT(AR_BSPSTORE)-PT(LOADRS) // restore loadrs
997 ld8 temp3=[temp1],PT(AR_RNAT)-PT(AR_BSPSTORE) // restore ar.bspstore
1001 ld8 temp4=[temp1] // restore ar.rnat
1003 mov ar.bspstore=temp3 // back to old stack
1010 //EndStub//////////////////////////////////////////////////////////////////////
1015 // ia64_set_kernel_registers()
1017 // Stub Description:
1019 // Set the registers that are required by the C code in order to run on an
1022 // r2 contains the return address, r3 contains either
1023 // IA64_MCA_CPU_MCA_STACK_OFFSET or IA64_MCA_CPU_INIT_STACK_OFFSET.
1027 ia64_set_kernel_registers:
1028 add temp3=MCA_SP_OFFSET, r3
1029 add temp4=MCA_SOS_OFFSET+SOS(OS_GP), r3
1030 mov b0=r2 // save return address
1031 GET_IA64_MCA_DATA(temp1)
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
1036 add r20=temp1, r3 // physical start of MCA/INIT stack
1038 ld8 r1=[temp4] // OS GP from SAL OS state
1040 DATA_PA_TO_VA(r1,temp1)
1041 DATA_PA_TO_VA(r12,temp2)
1042 DATA_PA_TO_VA(r13,temp3)
1044 mov IA64_KR(CURRENT)=r13
1046 /* 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.
1051 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1053 shl r16=r16,IA64_GRANULE_SHIFT
1055 dep r16=-1,r16,61,3 // virtual granule
1056 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1062 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1063 movl r21=PAGE_KERNEL // page properties
1065 mov IA64_KR(CURRENT_STACK)=r16
1066 or r21=r20,r21 // construct PA | page properties
1070 mov r20=IA64_TR_CURRENT_STACK
1078 //EndStub//////////////////////////////////////////////////////////////////////
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
1092 GLOBAL_ENTRY(ia64_get_rnat)
1093 alloc r14=ar.pfs,1,0,0,0
1098 cmp.lt p6,p7=in0,r14