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/linkage.h>
11 #include <linux/errno.h>
16 #include <asm/contregs.h>
17 #include <asm/ptrace.h>
18 #include <asm/asm-offsets.h>
20 #include <asm/vaddrs.h>
22 #include <asm/pgtable.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
134 /* Kill some time so the bits set */
140 /* Prevent recursion */
141 sethi %hi(doing_pdma), %l7
143 st %g0, [%l7 + %lo(doing_pdma)]
145 /* We emptied the FIFO, but we haven't read everything
146 * as of yet. Store the current transfer address and
147 * bytes left to read so we can continue when the next
151 sethi %hi(pdma_vaddr), %l5
152 st %l4, [%l5 + %lo(pdma_vaddr)]
153 sethi %hi(pdma_size), %l7
154 st %l6, [%l7 + %lo(pdma_size)]
156 /* Restore condition codes */
164 sethi %hi(pdma_vaddr), %l5
165 st %l4, [%l5 + %lo(pdma_vaddr)]
166 sethi %hi(pdma_size), %l5
167 st %l6, [%l5 + %lo(pdma_size)]
168 /* Prevent recursion */
169 sethi %hi(doing_pdma), %l7
170 st %g0, [%l7 + %lo(doing_pdma)]
172 /* fall through... */
177 /* Set all IRQs off. */
184 mov 11, %o0 ! floppy irq level (unused anyway)
185 mov %g0, %o1 ! devid is not used in fast interrupts
186 call sparc_floppy_irq
187 add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs
191 #endif /* (CONFIG_BLK_DEV_FD) */
193 /* Bad trap handler */
194 .globl bad_trap_handler
201 add %sp, STACKFRAME_SZ, %o0 ! pt_regs
203 mov %l7, %o1 ! trap number
207 /* For now all IRQ's not registered get sent here. handler_irq() will
208 * see if a routine is registered to handle this interrupt and if not
209 * it will say so on the console.
213 .globl real_irq_entry, patch_handler_irq
218 .globl patchme_maybe_smp_msg
221 patchme_maybe_smp_msg:
232 mov %l7, %o0 ! irq level
235 add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
236 or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq
237 wr %g2, PSR_ET, %psr ! keep ET up
243 /* SMP per-cpu ticker interrupts are handled specially. */
245 bne real_irq_continue+4
251 call smp4m_percpu_timer_interrupt
252 add %sp, STACKFRAME_SZ, %o0
257 #define GET_PROCESSOR4M_ID(reg) \
259 srl %reg, 12, %reg; \
262 /* Here is where we check for possible SMP IPI passed to us
263 * on some level other than 15 which is the NMI and only used
264 * for cross calls. That has a separate entry point below.
266 * IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
269 GET_PROCESSOR4M_ID(o3)
270 sethi %hi(sun4m_irq_percpu), %l5
272 or %l5, %lo(sun4m_irq_percpu), %o5
273 sethi %hi(0x70000000), %o2 ! Check all soft-IRQs
275 ld [%o1 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
280 st %o2, [%o1 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x70000000
282 ld [%o1 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
289 srl %o3, 28, %o2 ! shift for simpler checks below
290 maybe_smp4m_msg_check_single:
292 beq,a maybe_smp4m_msg_check_mask
294 call smp_call_function_single_interrupt
297 maybe_smp4m_msg_check_mask:
298 beq,a maybe_smp4m_msg_check_resched
300 call smp_call_function_interrupt
303 maybe_smp4m_msg_check_resched:
304 /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
305 beq,a maybe_smp4m_msg_out
307 call smp_resched_interrupt
313 .globl linux_trap_ipi15_sun4m
314 linux_trap_ipi15_sun4m:
316 sethi %hi(0x80000000), %o2
317 GET_PROCESSOR4M_ID(o0)
318 sethi %hi(sun4m_irq_percpu), %l5
319 or %l5, %lo(sun4m_irq_percpu), %o5
322 ld [%o5 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
324 be sun4m_nmi_error ! Must be an NMI async memory error
325 st %o2, [%o5 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x80000000
327 ld [%o5 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
334 call smp4m_cross_call_irq
336 b ret_trap_lockless_ipi
340 /* SMP per-cpu ticker interrupts are handled specially. */
344 sethi %hi(CC_ICLR), %o0
345 sethi %hi(1 << 14), %o1
346 or %o0, %lo(CC_ICLR), %o0
347 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 14 in MXCC's ICLR */
352 call smp4d_percpu_timer_interrupt
353 add %sp, STACKFRAME_SZ, %o0
359 .globl linux_trap_ipi15_sun4d
360 linux_trap_ipi15_sun4d:
362 sethi %hi(CC_BASE), %o4
363 sethi %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
364 or %o4, (CC_EREG - CC_BASE), %o0
365 ldda [%o0] ASI_M_MXCC, %o0
368 sethi %hi(BB_STAT2), %o2
369 lduba [%o2] ASI_M_CTL, %o2
370 andcc %o2, BB_STAT2_MASK, %g0
372 or %o4, (CC_ICLR - CC_BASE), %o0
373 sethi %hi(1 << 15), %o1
374 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 15 in MXCC's ICLR */
380 call smp4d_cross_call_irq
382 b ret_trap_lockless_ipi
389 lduha [%l4] ASI_M_MXCC, %l5
390 sethi %hi(1 << 15), %l7
392 stha %l5, [%l4] ASI_M_MXCC
397 .extern leon_ipi_interrupt
398 /* SMP per-cpu IPI interrupts are handled specially. */
406 call leonsmp_ipi_interrupt
407 add %sp, STACKFRAME_SZ, %o1 ! pt_regs
413 .globl linux_trap_ipi15_leon
414 linux_trap_ipi15_leon:
421 call leon_cross_call_irq
423 b ret_trap_lockless_ipi
426 #endif /* CONFIG_SMP */
428 /* This routine handles illegal instructions and privileged
429 * instruction attempts from user code.
432 .globl bad_instruction
434 sethi %hi(0xc1f80000), %l4
436 sethi %hi(0x81d80000), %l7
442 wr %l0, PSR_ET, %psr ! re-enable traps
445 add %sp, STACKFRAME_SZ, %o0
448 call do_illegal_instruction
453 1: /* unimplemented flush - just skip */
458 .globl priv_instruction
465 add %sp, STACKFRAME_SZ, %o0
468 call do_priv_instruction
473 /* This routine handles unaligned data accesses. */
477 andcc %l0, PSR_PS, %g0
487 call kernel_unaligned_trap
488 add %sp, STACKFRAME_SZ, %o0
495 wr %l0, PSR_ET, %psr ! re-enable traps
499 call user_unaligned_trap
500 add %sp, STACKFRAME_SZ, %o0
504 /* This routine handles floating point disabled traps. */
506 .globl fpd_trap_handler
510 wr %l0, PSR_ET, %psr ! re-enable traps
513 add %sp, STACKFRAME_SZ, %o0
521 /* This routine handles Floating Point Exceptions. */
523 .globl fpe_trap_handler
525 set fpsave_magic, %l5
528 sethi %hi(fpsave), %l5
529 or %l5, %lo(fpsave), %l5
532 sethi %hi(fpsave_catch2), %l5
533 or %l5, %lo(fpsave_catch2), %l5
539 sethi %hi(fpsave_catch), %l5
540 or %l5, %lo(fpsave_catch), %l5
549 wr %l0, PSR_ET, %psr ! re-enable traps
552 add %sp, STACKFRAME_SZ, %o0
560 /* This routine handles Tag Overflow Exceptions. */
562 .globl do_tag_overflow
566 wr %l0, PSR_ET, %psr ! re-enable traps
569 add %sp, STACKFRAME_SZ, %o0
572 call handle_tag_overflow
577 /* This routine handles Watchpoint Exceptions. */
583 wr %l0, PSR_ET, %psr ! re-enable traps
586 add %sp, STACKFRAME_SZ, %o0
589 call handle_watchpoint
594 /* This routine handles Register Access Exceptions. */
600 wr %l0, PSR_ET, %psr ! re-enable traps
603 add %sp, STACKFRAME_SZ, %o0
606 call handle_reg_access
611 /* This routine handles Co-Processor Disabled Exceptions. */
613 .globl do_cp_disabled
617 wr %l0, PSR_ET, %psr ! re-enable traps
620 add %sp, STACKFRAME_SZ, %o0
623 call handle_cp_disabled
628 /* This routine handles Co-Processor Exceptions. */
630 .globl do_cp_exception
634 wr %l0, PSR_ET, %psr ! re-enable traps
637 add %sp, STACKFRAME_SZ, %o0
640 call handle_cp_exception
645 /* This routine handles Hardware Divide By Zero Exceptions. */
651 wr %l0, PSR_ET, %psr ! re-enable traps
654 add %sp, STACKFRAME_SZ, %o0
657 call handle_hw_divzero
663 .globl do_flush_windows
670 andcc %l0, PSR_PS, %g0
674 call flush_user_windows
677 /* Advance over the trap instruction. */
678 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
680 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
681 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
685 .globl flush_patch_one
687 /* We get these for debugging routines using __builtin_return_address() */
690 FLUSH_ALL_KERNEL_WINDOWS
692 /* Advance over the trap instruction. */
693 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
695 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
696 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
700 /* The getcc software trap. The user wants the condition codes from
701 * the %psr in register %g1.
705 .globl getcc_trap_handler
707 srl %l0, 20, %g1 ! give user
708 and %g1, 0xf, %g1 ! only ICC bits in %psr
709 jmp %l2 ! advance over trap instruction
710 rett %l2 + 0x4 ! like this...
712 /* The setcc software trap. The user has condition codes in %g1
713 * that it would like placed in the %psr. Be careful not to flip
714 * any unintentional bits!
718 .globl setcc_trap_handler
722 andn %l0, %l5, %l0 ! clear ICC bits in %psr
723 and %l4, %l5, %l4 ! clear non-ICC bits in user value
724 or %l4, %l0, %l4 ! or them in... mix mix mix
726 wr %l4, 0x0, %psr ! set new %psr
727 WRITE_PAUSE ! TI scumbags...
729 jmp %l2 ! advance over trap instruction
730 rett %l2 + 0x4 ! like this...
733 /* NMI async memory error handling. */
734 sethi %hi(0x80000000), %l4
735 sethi %hi(sun4m_irq_global), %o5
736 ld [%o5 + %lo(sun4m_irq_global)], %l5
737 st %l4, [%l5 + 0x0c] ! sun4m_irq_global->mask_set=0x80000000
739 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
748 st %l4, [%l5 + 0x08] ! sun4m_irq_global->mask_clear=0x80000000
750 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
756 .globl linux_trap_ipi15_sun4m
757 linux_trap_ipi15_sun4m:
762 #endif /* CONFIG_SMP */
770 LEON_PI(lda [%l5] ASI_LEON_MMUREGS, %l6) ! read sfar first
771 SUN_PI_(lda [%l5] ASI_M_MMUREGS, %l6) ! read sfar first
773 LEON_PI(lda [%l4] ASI_LEON_MMUREGS, %l5) ! read sfsr last
774 SUN_PI_(lda [%l4] ASI_M_MMUREGS, %l5) ! read sfsr last
777 srl %l5, 6, %l5 ! and encode all info into l7
782 or %l6, %l7, %l7 ! l7 = [addr,write,txtfault]
788 and %o1, 1, %o1 ! arg2 = text_faultp
790 and %o2, 2, %o2 ! arg3 = writep
791 andn %o3, 0xfff, %o3 ! arg4 = faulting address
797 add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
802 .globl sys_nis_syscall
805 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
806 call c_sys_nis_syscall
815 .globl sys_sparc_pipe
818 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
834 add %sp, STACKFRAME_SZ, %o0
836 ld [%curptr + TI_FLAGS], %l5
837 andcc %l5, _TIF_SYSCALL_TRACE, %g0
845 /* We don't want to muck with user registers like a
846 * normal syscall, just return.
851 .globl sys_rt_sigreturn
854 add %sp, STACKFRAME_SZ, %o0
856 ld [%curptr + TI_FLAGS], %l5
857 andcc %l5, _TIF_SYSCALL_TRACE, %g0
861 add %sp, STACKFRAME_SZ, %o0
866 /* We are returning to a signal handler. */
869 /* Now that we have a real sys_clone, sys_fork() is
870 * implemented in terms of it. Our _real_ implementation
871 * of SunOS vfork() will use sys_vfork().
873 * XXX These three should be consolidated into mostly shared
874 * XXX code just like on sparc64... -DaveM
877 .globl sys_fork, flush_patch_two
881 FLUSH_ALL_KERNEL_WINDOWS;
882 ld [%curptr + TI_TASK], %o4
885 mov SIGCHLD, %o0 ! arg0: clone flags
888 mov %fp, %o1 ! arg1: usp
889 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
890 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
895 /* Whee, kernel threads! */
896 .globl sys_clone, flush_patch_three
900 FLUSH_ALL_KERNEL_WINDOWS;
901 ld [%curptr + TI_TASK], %o4
905 /* arg0,1: flags,usp -- loaded already */
906 cmp %o1, 0x0 ! Is new_usp NULL?
910 mov %fp, %o1 ! yes, use callers usp
911 andn %o1, 7, %o1 ! no, align to 8 bytes
913 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
914 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
919 /* Whee, real vfork! */
920 .globl sys_vfork, flush_patch_four
923 FLUSH_ALL_KERNEL_WINDOWS;
924 ld [%curptr + TI_TASK], %o4
929 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
930 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
932 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
933 sethi %hi(sparc_do_fork), %l1
935 jmpl %l1 + %lo(sparc_do_fork), %g0
936 add %sp, STACKFRAME_SZ, %o2
939 linux_sparc_ni_syscall:
940 sethi %hi(sys_ni_syscall), %l7
942 or %l7, %lo(sys_ni_syscall), %l7
945 add %sp, STACKFRAME_SZ, %o0
952 /* Syscall tracing can modify the registers. */
953 ld [%sp + STACKFRAME_SZ + PT_G1], %g1
954 sethi %hi(sys_call_table), %l7
955 ld [%sp + STACKFRAME_SZ + PT_I0], %i0
956 or %l7, %lo(sys_call_table), %l7
957 ld [%sp + STACKFRAME_SZ + PT_I1], %i1
958 ld [%sp + STACKFRAME_SZ + PT_I2], %i2
959 ld [%sp + STACKFRAME_SZ + PT_I3], %i3
960 ld [%sp + STACKFRAME_SZ + PT_I4], %i4
961 ld [%sp + STACKFRAME_SZ + PT_I5], %i5
978 ld [%g3 + TI_TASK], %o0
980 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
982 .globl ret_from_kernel_thread
983 ret_from_kernel_thread:
985 ld [%g3 + TI_TASK], %o0
986 ld [%sp + STACKFRAME_SZ + PT_G1], %l0
988 ld [%sp + STACKFRAME_SZ + PT_G2], %o0
990 ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
991 andn %l0, PSR_CWP, %l0
993 and %l1, PSR_CWP, %l1
995 st %l0, [%sp + STACKFRAME_SZ + PT_PSR]
999 /* Linux native system calls enter here... */
1001 .globl linux_sparc_syscall
1002 linux_sparc_syscall:
1003 sethi %hi(PSR_SYSCALL), %l4
1005 /* Direct access to user regs, must faster. */
1006 cmp %g1, NR_syscalls
1007 bgeu linux_sparc_ni_syscall
1015 wr %l0, PSR_ET, %psr
1020 ld [%curptr + TI_FLAGS], %l5
1022 andcc %l5, _TIF_SYSCALL_TRACE, %g0
1024 bne linux_syscall_trace
1031 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1034 ld [%curptr + TI_FLAGS], %l6
1035 cmp %o0, -ERESTART_RESTARTBLOCK
1036 ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
1039 andcc %l6, _TIF_SYSCALL_TRACE, %g0
1041 /* System call success, clear Carry condition code. */
1044 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1045 bne linux_syscall_trace2
1046 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1047 add %l1, 0x4, %l2 /* npc = npc+4 */
1048 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1050 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1052 /* System call failure, set Carry condition code.
1053 * Also, get abs(errno) to return to the process.
1057 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1059 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1060 bne linux_syscall_trace2
1061 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1062 add %l1, 0x4, %l2 /* npc = npc+4 */
1063 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1065 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1067 linux_syscall_trace2:
1068 add %sp, STACKFRAME_SZ, %o0
1071 add %l1, 0x4, %l2 /* npc = npc+4 */
1072 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1074 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1077 /* Saving and restoring the FPU state is best done from lowlevel code.
1079 * void fpsave(unsigned long *fpregs, unsigned long *fsr,
1080 * void *fpqueue, unsigned long *fpqdepth)
1085 st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
1092 /* We have an fpqueue to save. */
1106 std %f0, [%o0 + 0x00]
1107 std %f2, [%o0 + 0x08]
1108 std %f4, [%o0 + 0x10]
1109 std %f6, [%o0 + 0x18]
1110 std %f8, [%o0 + 0x20]
1111 std %f10, [%o0 + 0x28]
1112 std %f12, [%o0 + 0x30]
1113 std %f14, [%o0 + 0x38]
1114 std %f16, [%o0 + 0x40]
1115 std %f18, [%o0 + 0x48]
1116 std %f20, [%o0 + 0x50]
1117 std %f22, [%o0 + 0x58]
1118 std %f24, [%o0 + 0x60]
1119 std %f26, [%o0 + 0x68]
1120 std %f28, [%o0 + 0x70]
1122 std %f30, [%o0 + 0x78]
1124 /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
1125 * code for pointing out this possible deadlock, while we save state
1126 * above we could trap on the fsr store so our low level fpu trap
1127 * code has to know how to deal with this.
1137 /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
1141 ldd [%o0 + 0x00], %f0
1142 ldd [%o0 + 0x08], %f2
1143 ldd [%o0 + 0x10], %f4
1144 ldd [%o0 + 0x18], %f6
1145 ldd [%o0 + 0x20], %f8
1146 ldd [%o0 + 0x28], %f10
1147 ldd [%o0 + 0x30], %f12
1148 ldd [%o0 + 0x38], %f14
1149 ldd [%o0 + 0x40], %f16
1150 ldd [%o0 + 0x48], %f18
1151 ldd [%o0 + 0x50], %f20
1152 ldd [%o0 + 0x58], %f22
1153 ldd [%o0 + 0x60], %f24
1154 ldd [%o0 + 0x68], %f26
1155 ldd [%o0 + 0x70], %f28
1156 ldd [%o0 + 0x78], %f30
1161 /* __ndelay and __udelay take two arguments:
1162 * 0 - nsecs or usecs to delay
1163 * 1 - per_cpu udelay_val (loops per jiffy)
1165 * Note that ndelay gives HZ times higher resolution but has a 10ms
1166 * limit. udelay can handle up to 1s.
1170 save %sp, -STACKFRAME_SZ, %sp
1171 mov %i0, %o0 ! round multiplier up so large ns ok
1172 mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
1175 mov %i1, %o1 ! udelay_val
1179 mov %o1, %o0 ! >>32 later for better resolution
1183 save %sp, -STACKFRAME_SZ, %sp
1185 sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
1186 or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
1189 mov %i1, %o1 ! udelay_val
1192 sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
1193 or %g0, %lo(0x028f4b62), %l0
1194 addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
1198 mov HZ, %o0 ! >>32 earlier for wider range
1211 /* Handle a software breakpoint */
1212 /* We have to inform parent that child has stopped */
1214 .globl breakpoint_trap
1218 wr %l0, PSR_ET, %psr
1221 st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
1222 call sparc_breakpoint
1223 add %sp, STACKFRAME_SZ, %o0
1228 ENTRY(kgdb_trap_low)
1231 wr %l0, PSR_ET, %psr
1234 mov %l7, %o0 ! trap_level
1236 add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
1239 ENDPROC(kgdb_trap_low)
1243 .globl flush_patch_exception
1244 flush_patch_exception:
1245 FLUSH_ALL_KERNEL_WINDOWS;
1247 jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
1248 mov 1, %g1 ! signal EFAULT condition
1251 .globl kill_user_windows, kuw_patch1_7win
1253 kuw_patch1_7win: sll %o3, 6, %o3
1255 /* No matter how much overhead this routine has in the worst
1256 * case scenario, it is several times better than taking the
1257 * traps with the old method of just doing flush_user_windows().
1260 ld [%g6 + TI_UWINMASK], %o0 ! get current umask
1261 orcc %g0, %o0, %g0 ! if no bits set, we are done
1262 be 3f ! nothing to do
1263 rd %psr, %o5 ! must clear interrupts
1264 or %o5, PSR_PIL, %o4 ! or else that could change
1265 wr %o4, 0x0, %psr ! the uwinmask state
1266 WRITE_PAUSE ! burn them cycles
1268 ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
1269 orcc %g0, %o0, %g0 ! did an interrupt come in?
1270 be 4f ! yep, we are done
1271 rd %wim, %o3 ! get current wim
1272 srl %o3, 1, %o4 ! simulate a save
1274 sll %o3, 7, %o3 ! compute next wim
1275 or %o4, %o3, %o3 ! result
1276 andncc %o0, %o3, %o0 ! clean this bit in umask
1277 bne kuw_patch1 ! not done yet
1278 srl %o3, 1, %o4 ! begin another save simulation
1279 wr %o3, 0x0, %wim ! set the new wim
1280 st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
1282 wr %o5, 0x0, %psr ! re-enable interrupts
1283 WRITE_PAUSE ! burn baby burn
1286 st %g0, [%g6 + TI_W_SAVED] ! no windows saved
1289 .globl restore_current
1291 LOAD_CURRENT(g6, o0)
1295 #ifdef CONFIG_PCIC_PCI
1296 #include <asm/pcic.h>
1299 .globl linux_trap_ipi15_pcic
1300 linux_trap_ipi15_pcic:
1305 * First deactivate NMI
1306 * or we cannot drop ET, cannot get window spill traps.
1307 * The busy loop is necessary because the PIO error
1308 * sometimes does not go away quickly and we trap again.
1310 sethi %hi(pcic_regs), %o1
1311 ld [%o1 + %lo(pcic_regs)], %o2
1313 ! Get pending status for printouts later.
1314 ld [%o2 + PCI_SYS_INT_PENDING], %o0
1316 mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
1317 stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
1319 ld [%o2 + PCI_SYS_INT_PENDING], %o1
1320 andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
1324 or %l0, PSR_PIL, %l4
1327 wr %l4, PSR_ET, %psr
1331 add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
1334 .globl pcic_nmi_trap_patch
1335 pcic_nmi_trap_patch:
1336 sethi %hi(linux_trap_ipi15_pcic), %l3
1337 jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
1341 #endif /* CONFIG_PCIC_PCI */
1345 save %sp, -0x40, %sp
1346 save %sp, -0x40, %sp
1347 save %sp, -0x40, %sp
1348 save %sp, -0x40, %sp
1349 save %sp, -0x40, %sp
1350 save %sp, -0x40, %sp
1351 save %sp, -0x40, %sp
1362 ENTRY(hard_smp_processor_id)
1366 .section .cpuid_patch, "ax"
1367 /* Instruction location. */
1369 /* SUN4D implementation. */
1370 lda [%g0] ASI_M_VIKING_TMP1, %o0
1373 /* LEON implementation. */
1380 ENDPROC(hard_smp_processor_id)
1383 /* End of entry.S */