1 /* arch/sparc/kernel/entry.S: Sparc trap low-level entry points.
3 * Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
4 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
6 * Copyright (C) 1996-1999 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au)
10 #include <linux/errno.h>
15 #include <asm/contregs.h>
16 #include <asm/ptrace.h>
17 #include <asm/asm-offsets.h>
19 #include <asm/vaddrs.h>
21 #include <asm/pgtable.h>
22 #include <asm/pgtsun4c.h>
23 #include <asm/winmacro.h>
24 #include <asm/signal.h>
27 #include <asm/thread_info.h>
28 #include <asm/param.h>
29 #include <asm/unistd.h>
31 #include <asm/asmmacro.h>
35 /* These are just handy. */
36 #define _SV save %sp, -STACKFRAME_SZ, %sp
39 #define FLUSH_ALL_KERNEL_WINDOWS \
40 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
41 _RS; _RS; _RS; _RS; _RS; _RS; _RS;
47 .globl arch_kgdb_breakpoint
48 .type arch_kgdb_breakpoint,#function
53 .size arch_kgdb_breakpoint,.-arch_kgdb_breakpoint
56 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
61 * This code cannot touch registers %l0 %l1 and %l2
62 * because SAVE_ALL depends on their values. It depends
63 * on %l3 also, but we regenerate it before a call.
64 * Other registers are:
65 * %l3 -- base address of fdc registers
67 * %l5 -- scratch for ld/st address
69 * %l7 -- scratch [floppy byte, ld/st address, aux. data]
72 /* Do we have work to do? */
73 sethi %hi(doing_pdma), %l7
74 ld [%l7 + %lo(doing_pdma)], %l7
79 /* Load fdc register base */
80 sethi %hi(fdc_status), %l3
81 ld [%l3 + %lo(fdc_status)], %l3
83 /* Setup register addresses */
84 sethi %hi(pdma_vaddr), %l5 ! transfer buffer
85 ld [%l5 + %lo(pdma_vaddr)], %l4
86 sethi %hi(pdma_size), %l5 ! bytes to go
87 ld [%l5 + %lo(pdma_size)], %l6
91 andcc %l7, 0x80, %g0 ! Does fifo still have data
92 bz floppy_fifo_emptied ! fifo has been emptied...
93 andcc %l7, 0x20, %g0 ! in non-dma mode still?
94 bz floppy_overrun ! nope, overrun
95 andcc %l7, 0x40, %g0 ! 0=write 1=read
99 /* Ok, actually read this byte */
110 /* Ok, actually write this byte */
117 /* fall through... */
119 sethi %hi(pdma_vaddr), %l5
120 st %l4, [%l5 + %lo(pdma_vaddr)]
121 sethi %hi(pdma_size), %l5
122 st %l6, [%l5 + %lo(pdma_size)]
123 /* Flip terminal count pin */
124 set auxio_register, %l7
127 set sparc_cpu_model, %l5
129 subcc %l5, 1, %g0 /* enum { sun4c = 1 }; */
145 /* Kill some time so the bits set */
151 /* Prevent recursion */
152 sethi %hi(doing_pdma), %l7
154 st %g0, [%l7 + %lo(doing_pdma)]
156 /* We emptied the FIFO, but we haven't read everything
157 * as of yet. Store the current transfer address and
158 * bytes left to read so we can continue when the next
162 sethi %hi(pdma_vaddr), %l5
163 st %l4, [%l5 + %lo(pdma_vaddr)]
164 sethi %hi(pdma_size), %l7
165 st %l6, [%l7 + %lo(pdma_size)]
167 /* Restore condition codes */
175 sethi %hi(pdma_vaddr), %l5
176 st %l4, [%l5 + %lo(pdma_vaddr)]
177 sethi %hi(pdma_size), %l5
178 st %l6, [%l5 + %lo(pdma_size)]
179 /* Prevent recursion */
180 sethi %hi(doing_pdma), %l7
181 st %g0, [%l7 + %lo(doing_pdma)]
183 /* fall through... */
188 /* Set all IRQs off. */
195 mov 11, %o0 ! floppy irq level (unused anyway)
196 mov %g0, %o1 ! devid is not used in fast interrupts
197 call sparc_floppy_irq
198 add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs
202 #endif /* (CONFIG_BLK_DEV_FD) */
204 /* Bad trap handler */
205 .globl bad_trap_handler
212 add %sp, STACKFRAME_SZ, %o0 ! pt_regs
214 mov %l7, %o1 ! trap number
218 /* For now all IRQ's not registered get sent here. handler_irq() will
219 * see if a routine is registered to handle this interrupt and if not
220 * it will say so on the console.
224 .globl real_irq_entry, patch_handler_irq
229 .globl patchme_maybe_smp_msg
232 patchme_maybe_smp_msg:
243 mov %l7, %o0 ! irq level
246 add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
247 or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq
248 wr %g2, PSR_ET, %psr ! keep ET up
254 /* SMP per-cpu ticker interrupts are handled specially. */
256 bne real_irq_continue+4
262 call smp4m_percpu_timer_interrupt
263 add %sp, STACKFRAME_SZ, %o0
268 /* Here is where we check for possible SMP IPI passed to us
269 * on some level other than 15 which is the NMI and only used
270 * for cross calls. That has a separate entry point below.
272 * IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
275 GET_PROCESSOR4M_ID(o3)
276 sethi %hi(sun4m_irq_percpu), %l5
278 or %l5, %lo(sun4m_irq_percpu), %o5
279 sethi %hi(0x70000000), %o2 ! Check all soft-IRQs
281 ld [%o1 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
286 st %o2, [%o1 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x70000000
288 ld [%o1 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
295 srl %o3, 28, %o2 ! shift for simpler checks below
296 maybe_smp4m_msg_check_single:
298 beq,a maybe_smp4m_msg_check_mask
300 call smp_call_function_single_interrupt
303 maybe_smp4m_msg_check_mask:
304 beq,a maybe_smp4m_msg_check_resched
306 call smp_call_function_interrupt
309 maybe_smp4m_msg_check_resched:
310 /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
311 beq,a maybe_smp4m_msg_out
313 call smp_resched_interrupt
319 .globl linux_trap_ipi15
322 sethi %hi(0x80000000), %o2
323 GET_PROCESSOR4M_ID(o0)
324 sethi %hi(sun4m_irq_percpu), %l5
325 or %l5, %lo(sun4m_irq_percpu), %o5
328 ld [%o5 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
330 be 1f ! Must be an NMI async memory error
331 st %o2, [%o5 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x80000000
333 ld [%o5 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
340 call smp4m_cross_call_irq
342 b ret_trap_lockless_ipi
345 /* NMI async memory error handling. */
346 sethi %hi(0x80000000), %l4
347 sethi %hi(sun4m_irq_global), %o5
348 ld [%o5 + %lo(sun4m_irq_global)], %l5
349 st %l4, [%l5 + 0x0c] ! sun4m_irq_global->mask_set=0x80000000
351 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
360 st %l4, [%l5 + 0x08] ! sun4m_irq_global->mask_clear=0x80000000
362 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
367 /* SMP per-cpu ticker interrupts are handled specially. */
371 sethi %hi(CC_ICLR), %o0
372 sethi %hi(1 << 14), %o1
373 or %o0, %lo(CC_ICLR), %o0
374 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 14 in MXCC's ICLR */
379 call smp4d_percpu_timer_interrupt
380 add %sp, STACKFRAME_SZ, %o0
386 .globl linux_trap_ipi15_sun4d
387 linux_trap_ipi15_sun4d:
389 sethi %hi(CC_BASE), %o4
390 sethi %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
391 or %o4, (CC_EREG - CC_BASE), %o0
392 ldda [%o0] ASI_M_MXCC, %o0
395 sethi %hi(BB_STAT2), %o2
396 lduba [%o2] ASI_M_CTL, %o2
397 andcc %o2, BB_STAT2_MASK, %g0
399 or %o4, (CC_ICLR - CC_BASE), %o0
400 sethi %hi(1 << 15), %o1
401 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 15 in MXCC's ICLR */
407 call smp4d_cross_call_irq
409 b ret_trap_lockless_ipi
416 lduha [%l4] ASI_M_MXCC, %l5
417 sethi %hi(1 << 15), %l7
419 stha %l5, [%l4] ASI_M_MXCC
423 #ifdef CONFIG_SPARC_LEON
425 .extern leon_ipi_interrupt
426 /* SMP per-cpu IPI interrupts are handled specially. */
434 call leonsmp_ipi_interrupt
435 add %sp, STACKFRAME_SZ, %o1 ! pt_regs
441 .globl linux_trap_ipi15_leon
442 linux_trap_ipi15_leon:
449 call leon_cross_call_irq
451 b ret_trap_lockless_ipi
454 #endif /* CONFIG_SPARC_LEON */
456 #endif /* CONFIG_SMP */
458 /* This routine handles illegal instructions and privileged
459 * instruction attempts from user code.
462 .globl bad_instruction
464 sethi %hi(0xc1f80000), %l4
466 sethi %hi(0x81d80000), %l7
472 wr %l0, PSR_ET, %psr ! re-enable traps
475 add %sp, STACKFRAME_SZ, %o0
478 call do_illegal_instruction
483 1: /* unimplemented flush - just skip */
488 .globl priv_instruction
495 add %sp, STACKFRAME_SZ, %o0
498 call do_priv_instruction
503 /* This routine handles unaligned data accesses. */
507 andcc %l0, PSR_PS, %g0
517 call kernel_unaligned_trap
518 add %sp, STACKFRAME_SZ, %o0
525 wr %l0, PSR_ET, %psr ! re-enable traps
529 call user_unaligned_trap
530 add %sp, STACKFRAME_SZ, %o0
534 /* This routine handles floating point disabled traps. */
536 .globl fpd_trap_handler
540 wr %l0, PSR_ET, %psr ! re-enable traps
543 add %sp, STACKFRAME_SZ, %o0
551 /* This routine handles Floating Point Exceptions. */
553 .globl fpe_trap_handler
555 set fpsave_magic, %l5
558 sethi %hi(fpsave), %l5
559 or %l5, %lo(fpsave), %l5
562 sethi %hi(fpsave_catch2), %l5
563 or %l5, %lo(fpsave_catch2), %l5
569 sethi %hi(fpsave_catch), %l5
570 or %l5, %lo(fpsave_catch), %l5
579 wr %l0, PSR_ET, %psr ! re-enable traps
582 add %sp, STACKFRAME_SZ, %o0
590 /* This routine handles Tag Overflow Exceptions. */
592 .globl do_tag_overflow
596 wr %l0, PSR_ET, %psr ! re-enable traps
599 add %sp, STACKFRAME_SZ, %o0
602 call handle_tag_overflow
607 /* This routine handles Watchpoint Exceptions. */
613 wr %l0, PSR_ET, %psr ! re-enable traps
616 add %sp, STACKFRAME_SZ, %o0
619 call handle_watchpoint
624 /* This routine handles Register Access Exceptions. */
630 wr %l0, PSR_ET, %psr ! re-enable traps
633 add %sp, STACKFRAME_SZ, %o0
636 call handle_reg_access
641 /* This routine handles Co-Processor Disabled Exceptions. */
643 .globl do_cp_disabled
647 wr %l0, PSR_ET, %psr ! re-enable traps
650 add %sp, STACKFRAME_SZ, %o0
653 call handle_cp_disabled
658 /* This routine handles Co-Processor Exceptions. */
660 .globl do_cp_exception
664 wr %l0, PSR_ET, %psr ! re-enable traps
667 add %sp, STACKFRAME_SZ, %o0
670 call handle_cp_exception
675 /* This routine handles Hardware Divide By Zero Exceptions. */
681 wr %l0, PSR_ET, %psr ! re-enable traps
684 add %sp, STACKFRAME_SZ, %o0
687 call handle_hw_divzero
693 .globl do_flush_windows
700 andcc %l0, PSR_PS, %g0
704 call flush_user_windows
707 /* Advance over the trap instruction. */
708 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
710 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
711 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
715 .globl flush_patch_one
717 /* We get these for debugging routines using __builtin_return_address() */
720 FLUSH_ALL_KERNEL_WINDOWS
722 /* Advance over the trap instruction. */
723 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
725 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
726 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
730 /* The getcc software trap. The user wants the condition codes from
731 * the %psr in register %g1.
735 .globl getcc_trap_handler
737 srl %l0, 20, %g1 ! give user
738 and %g1, 0xf, %g1 ! only ICC bits in %psr
739 jmp %l2 ! advance over trap instruction
740 rett %l2 + 0x4 ! like this...
742 /* The setcc software trap. The user has condition codes in %g1
743 * that it would like placed in the %psr. Be careful not to flip
744 * any unintentional bits!
748 .globl setcc_trap_handler
752 andn %l0, %l5, %l0 ! clear ICC bits in %psr
753 and %l4, %l5, %l4 ! clear non-ICC bits in user value
754 or %l4, %l0, %l4 ! or them in... mix mix mix
756 wr %l4, 0x0, %psr ! set new %psr
757 WRITE_PAUSE ! TI scumbags...
759 jmp %l2 ! advance over trap instruction
760 rett %l2 + 0x4 ! like this...
764 .globl linux_trap_ipi15
768 /* Now it is safe to re-enable traps without recursion. */
773 /* Now call the c-code with the pt_regs frame ptr and the
774 * memory error registers as arguments. The ordering chosen
775 * here is due to unlatching semantics.
777 sethi %hi(AC_SYNC_ERR), %o0
779 lda [%o0] ASI_CONTROL, %o2 ! sync vaddr
781 lda [%o0] ASI_CONTROL, %o1 ! sync error
783 lda [%o0] ASI_CONTROL, %o4 ! async vaddr
785 lda [%o0] ASI_CONTROL, %o3 ! async error
787 add %sp, STACKFRAME_SZ, %o0
791 #endif /* CONFIG_SMP */
794 .globl invalid_segment_patch1_ff
795 .globl invalid_segment_patch2_ff
796 invalid_segment_patch1_ff: cmp %l4, 0xff
797 invalid_segment_patch2_ff: mov 0xff, %l3
800 .globl invalid_segment_patch1_1ff
801 .globl invalid_segment_patch2_1ff
802 invalid_segment_patch1_1ff: cmp %l4, 0x1ff
803 invalid_segment_patch2_1ff: mov 0x1ff, %l3
806 .globl num_context_patch1_16, num_context_patch2_16
807 num_context_patch1_16: mov 0x10, %l7
808 num_context_patch2_16: mov 0x10, %l7
811 .globl vac_linesize_patch_32
812 vac_linesize_patch_32: subcc %l7, 32, %l7
815 .globl vac_hwflush_patch1_on, vac_hwflush_patch2_on
818 * Ugly, but we can't use hardware flushing on the sun4 and we'd require
819 * two instructions (Anton)
821 vac_hwflush_patch1_on: addcc %l7, -PAGE_SIZE, %l7
823 vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG
825 .globl invalid_segment_patch1, invalid_segment_patch2
826 .globl num_context_patch1
827 .globl vac_linesize_patch, vac_hwflush_patch1
828 .globl vac_hwflush_patch2
836 lda [%l5] ASI_M_MMUREGS, %l6 ! read sfar first
837 lda [%l4] ASI_M_MMUREGS, %l5 ! read sfsr last
840 srl %l5, 6, %l5 ! and encode all info into l7
845 or %l6, %l7, %l7 ! l7 = [addr,write,txtfault]
851 and %o1, 1, %o1 ! arg2 = text_faultp
853 and %o2, 2, %o2 ! arg3 = writep
854 andn %o3, 0xfff, %o3 ! arg4 = faulting address
860 add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
865 .globl sys_nis_syscall
868 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
869 call c_sys_nis_syscall
876 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
882 st %g0, [%sp + STACKFRAME_SZ + PT_I2]
885 add %sp, STACKFRAME_SZ, %o0
888 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
891 .globl sys_sparc_pipe
894 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
899 .globl sys_sigaltstack
918 add %sp, STACKFRAME_SZ, %o0
920 ld [%curptr + TI_FLAGS], %l5
921 andcc %l5, _TIF_SYSCALL_TRACE, %g0
929 /* We don't want to muck with user registers like a
930 * normal syscall, just return.
935 .globl sys_rt_sigreturn
938 add %sp, STACKFRAME_SZ, %o0
940 ld [%curptr + TI_FLAGS], %l5
941 andcc %l5, _TIF_SYSCALL_TRACE, %g0
945 add %sp, STACKFRAME_SZ, %o0
950 /* We are returning to a signal handler. */
953 /* Now that we have a real sys_clone, sys_fork() is
954 * implemented in terms of it. Our _real_ implementation
955 * of SunOS vfork() will use sys_vfork().
957 * XXX These three should be consolidated into mostly shared
958 * XXX code just like on sparc64... -DaveM
961 .globl sys_fork, flush_patch_two
965 FLUSH_ALL_KERNEL_WINDOWS;
966 ld [%curptr + TI_TASK], %o4
969 mov SIGCHLD, %o0 ! arg0: clone flags
972 mov %fp, %o1 ! arg1: usp
973 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
974 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
979 /* Whee, kernel threads! */
980 .globl sys_clone, flush_patch_three
984 FLUSH_ALL_KERNEL_WINDOWS;
985 ld [%curptr + TI_TASK], %o4
989 /* arg0,1: flags,usp -- loaded already */
990 cmp %o1, 0x0 ! Is new_usp NULL?
994 mov %fp, %o1 ! yes, use callers usp
995 andn %o1, 7, %o1 ! no, align to 8 bytes
997 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
998 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
1003 /* Whee, real vfork! */
1004 .globl sys_vfork, flush_patch_four
1007 FLUSH_ALL_KERNEL_WINDOWS;
1008 ld [%curptr + TI_TASK], %o4
1013 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
1014 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1016 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1017 sethi %hi(sparc_do_fork), %l1
1019 jmpl %l1 + %lo(sparc_do_fork), %g0
1020 add %sp, STACKFRAME_SZ, %o2
1023 linux_sparc_ni_syscall:
1024 sethi %hi(sys_ni_syscall), %l7
1025 b syscall_is_too_hard
1026 or %l7, %lo(sys_ni_syscall), %l7
1036 linux_syscall_trace:
1037 add %sp, STACKFRAME_SZ, %o0
1050 .globl ret_from_fork
1053 ld [%g3 + TI_TASK], %o0
1055 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
1057 /* Linux native system calls enter here... */
1059 .globl linux_sparc_syscall
1060 linux_sparc_syscall:
1061 sethi %hi(PSR_SYSCALL), %l4
1063 /* Direct access to user regs, must faster. */
1064 cmp %g1, NR_syscalls
1065 bgeu linux_sparc_ni_syscall
1069 bne linux_fast_syscall
1070 /* Just do first insn from SAVE_ALL in the delay slot */
1072 syscall_is_too_hard:
1076 wr %l0, PSR_ET, %psr
1081 ld [%curptr + TI_FLAGS], %l5
1083 andcc %l5, _TIF_SYSCALL_TRACE, %g0
1085 bne linux_syscall_trace
1092 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1095 ld [%curptr + TI_FLAGS], %l6
1096 cmp %o0, -ERESTART_RESTARTBLOCK
1097 ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
1100 andcc %l6, _TIF_SYSCALL_TRACE, %g0
1102 /* System call success, clear Carry condition code. */
1105 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1106 bne linux_syscall_trace2
1107 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1108 add %l1, 0x4, %l2 /* npc = npc+4 */
1109 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1111 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1113 /* System call failure, set Carry condition code.
1114 * Also, get abs(errno) to return to the process.
1118 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1120 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1121 bne linux_syscall_trace2
1122 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1123 add %l1, 0x4, %l2 /* npc = npc+4 */
1124 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1126 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1128 linux_syscall_trace2:
1129 add %sp, STACKFRAME_SZ, %o0
1132 add %l1, 0x4, %l2 /* npc = npc+4 */
1133 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1135 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1138 /* Saving and restoring the FPU state is best done from lowlevel code.
1140 * void fpsave(unsigned long *fpregs, unsigned long *fsr,
1141 * void *fpqueue, unsigned long *fpqdepth)
1146 st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
1153 /* We have an fpqueue to save. */
1167 std %f0, [%o0 + 0x00]
1168 std %f2, [%o0 + 0x08]
1169 std %f4, [%o0 + 0x10]
1170 std %f6, [%o0 + 0x18]
1171 std %f8, [%o0 + 0x20]
1172 std %f10, [%o0 + 0x28]
1173 std %f12, [%o0 + 0x30]
1174 std %f14, [%o0 + 0x38]
1175 std %f16, [%o0 + 0x40]
1176 std %f18, [%o0 + 0x48]
1177 std %f20, [%o0 + 0x50]
1178 std %f22, [%o0 + 0x58]
1179 std %f24, [%o0 + 0x60]
1180 std %f26, [%o0 + 0x68]
1181 std %f28, [%o0 + 0x70]
1183 std %f30, [%o0 + 0x78]
1185 /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
1186 * code for pointing out this possible deadlock, while we save state
1187 * above we could trap on the fsr store so our low level fpu trap
1188 * code has to know how to deal with this.
1198 /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
1202 ldd [%o0 + 0x00], %f0
1203 ldd [%o0 + 0x08], %f2
1204 ldd [%o0 + 0x10], %f4
1205 ldd [%o0 + 0x18], %f6
1206 ldd [%o0 + 0x20], %f8
1207 ldd [%o0 + 0x28], %f10
1208 ldd [%o0 + 0x30], %f12
1209 ldd [%o0 + 0x38], %f14
1210 ldd [%o0 + 0x40], %f16
1211 ldd [%o0 + 0x48], %f18
1212 ldd [%o0 + 0x50], %f20
1213 ldd [%o0 + 0x58], %f22
1214 ldd [%o0 + 0x60], %f24
1215 ldd [%o0 + 0x68], %f26
1216 ldd [%o0 + 0x70], %f28
1217 ldd [%o0 + 0x78], %f30
1222 /* __ndelay and __udelay take two arguments:
1223 * 0 - nsecs or usecs to delay
1224 * 1 - per_cpu udelay_val (loops per jiffy)
1226 * Note that ndelay gives HZ times higher resolution but has a 10ms
1227 * limit. udelay can handle up to 1s.
1231 save %sp, -STACKFRAME_SZ, %sp
1233 call .umul ! round multiplier up so large ns ok
1234 mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
1236 mov %i1, %o1 ! udelay_val
1238 mov %o1, %o0 ! >>32 later for better resolution
1242 save %sp, -STACKFRAME_SZ, %sp
1244 sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
1246 or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
1248 mov %i1, %o1 ! udelay_val
1249 sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
1250 or %g0, %lo(0x028f4b62), %l0
1251 addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
1256 mov HZ, %o0 ! >>32 earlier for wider range
1267 /* Handle a software breakpoint */
1268 /* We have to inform parent that child has stopped */
1270 .globl breakpoint_trap
1274 wr %l0, PSR_ET, %psr
1277 st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
1278 call sparc_breakpoint
1279 add %sp, STACKFRAME_SZ, %o0
1285 .globl kgdb_trap_low
1286 .type kgdb_trap_low,#function
1290 wr %l0, PSR_ET, %psr
1294 add %sp, STACKFRAME_SZ, %o0
1297 .size kgdb_trap_low,.-kgdb_trap_low
1301 .globl flush_patch_exception
1302 flush_patch_exception:
1303 FLUSH_ALL_KERNEL_WINDOWS;
1305 jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
1306 mov 1, %g1 ! signal EFAULT condition
1309 .globl kill_user_windows, kuw_patch1_7win
1311 kuw_patch1_7win: sll %o3, 6, %o3
1313 /* No matter how much overhead this routine has in the worst
1314 * case scenerio, it is several times better than taking the
1315 * traps with the old method of just doing flush_user_windows().
1318 ld [%g6 + TI_UWINMASK], %o0 ! get current umask
1319 orcc %g0, %o0, %g0 ! if no bits set, we are done
1320 be 3f ! nothing to do
1321 rd %psr, %o5 ! must clear interrupts
1322 or %o5, PSR_PIL, %o4 ! or else that could change
1323 wr %o4, 0x0, %psr ! the uwinmask state
1324 WRITE_PAUSE ! burn them cycles
1326 ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
1327 orcc %g0, %o0, %g0 ! did an interrupt come in?
1328 be 4f ! yep, we are done
1329 rd %wim, %o3 ! get current wim
1330 srl %o3, 1, %o4 ! simulate a save
1332 sll %o3, 7, %o3 ! compute next wim
1333 or %o4, %o3, %o3 ! result
1334 andncc %o0, %o3, %o0 ! clean this bit in umask
1335 bne kuw_patch1 ! not done yet
1336 srl %o3, 1, %o4 ! begin another save simulation
1337 wr %o3, 0x0, %wim ! set the new wim
1338 st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
1340 wr %o5, 0x0, %psr ! re-enable interrupts
1341 WRITE_PAUSE ! burn baby burn
1344 st %g0, [%g6 + TI_W_SAVED] ! no windows saved
1347 .globl restore_current
1349 LOAD_CURRENT(g6, o0)
1353 #ifdef CONFIG_PCIC_PCI
1354 #include <asm/pcic.h>
1357 .globl linux_trap_ipi15_pcic
1358 linux_trap_ipi15_pcic:
1363 * First deactivate NMI
1364 * or we cannot drop ET, cannot get window spill traps.
1365 * The busy loop is necessary because the PIO error
1366 * sometimes does not go away quickly and we trap again.
1368 sethi %hi(pcic_regs), %o1
1369 ld [%o1 + %lo(pcic_regs)], %o2
1371 ! Get pending status for printouts later.
1372 ld [%o2 + PCI_SYS_INT_PENDING], %o0
1374 mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
1375 stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
1377 ld [%o2 + PCI_SYS_INT_PENDING], %o1
1378 andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
1382 or %l0, PSR_PIL, %l4
1385 wr %l4, PSR_ET, %psr
1389 add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
1392 .globl pcic_nmi_trap_patch
1393 pcic_nmi_trap_patch:
1394 sethi %hi(linux_trap_ipi15_pcic), %l3
1395 jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
1399 #endif /* CONFIG_PCIC_PCI */
1403 save %sp, -0x40, %sp
1404 save %sp, -0x40, %sp
1405 save %sp, -0x40, %sp
1406 save %sp, -0x40, %sp
1407 save %sp, -0x40, %sp
1408 save %sp, -0x40, %sp
1409 save %sp, -0x40, %sp
1419 /* End of entry.S */