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>
32 #include <asm/export.h>
36 /* These are just handy. */
37 #define _SV save %sp, -STACKFRAME_SZ, %sp
40 #define FLUSH_ALL_KERNEL_WINDOWS \
41 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
42 _RS; _RS; _RS; _RS; _RS; _RS; _RS;
48 .globl arch_kgdb_breakpoint
49 .type arch_kgdb_breakpoint,#function
54 .size arch_kgdb_breakpoint,.-arch_kgdb_breakpoint
57 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
62 * This code cannot touch registers %l0 %l1 and %l2
63 * because SAVE_ALL depends on their values. It depends
64 * on %l3 also, but we regenerate it before a call.
65 * Other registers are:
66 * %l3 -- base address of fdc registers
68 * %l5 -- scratch for ld/st address
70 * %l7 -- scratch [floppy byte, ld/st address, aux. data]
73 /* Do we have work to do? */
74 sethi %hi(doing_pdma), %l7
75 ld [%l7 + %lo(doing_pdma)], %l7
80 /* Load fdc register base */
81 sethi %hi(fdc_status), %l3
82 ld [%l3 + %lo(fdc_status)], %l3
84 /* Setup register addresses */
85 sethi %hi(pdma_vaddr), %l5 ! transfer buffer
86 ld [%l5 + %lo(pdma_vaddr)], %l4
87 sethi %hi(pdma_size), %l5 ! bytes to go
88 ld [%l5 + %lo(pdma_size)], %l6
92 andcc %l7, 0x80, %g0 ! Does fifo still have data
93 bz floppy_fifo_emptied ! fifo has been emptied...
94 andcc %l7, 0x20, %g0 ! in non-dma mode still?
95 bz floppy_overrun ! nope, overrun
96 andcc %l7, 0x40, %g0 ! 0=write 1=read
100 /* Ok, actually read this byte */
111 /* Ok, actually write this byte */
118 /* fall through... */
120 sethi %hi(pdma_vaddr), %l5
121 st %l4, [%l5 + %lo(pdma_vaddr)]
122 sethi %hi(pdma_size), %l5
123 st %l6, [%l5 + %lo(pdma_size)]
124 /* Flip terminal count pin */
125 set auxio_register, %l7
135 /* Kill some time so the bits set */
141 /* Prevent recursion */
142 sethi %hi(doing_pdma), %l7
144 st %g0, [%l7 + %lo(doing_pdma)]
146 /* We emptied the FIFO, but we haven't read everything
147 * as of yet. Store the current transfer address and
148 * bytes left to read so we can continue when the next
152 sethi %hi(pdma_vaddr), %l5
153 st %l4, [%l5 + %lo(pdma_vaddr)]
154 sethi %hi(pdma_size), %l7
155 st %l6, [%l7 + %lo(pdma_size)]
157 /* Restore condition codes */
165 sethi %hi(pdma_vaddr), %l5
166 st %l4, [%l5 + %lo(pdma_vaddr)]
167 sethi %hi(pdma_size), %l5
168 st %l6, [%l5 + %lo(pdma_size)]
169 /* Prevent recursion */
170 sethi %hi(doing_pdma), %l7
171 st %g0, [%l7 + %lo(doing_pdma)]
173 /* fall through... */
178 /* Set all IRQs off. */
185 mov 11, %o0 ! floppy irq level (unused anyway)
186 mov %g0, %o1 ! devid is not used in fast interrupts
187 call sparc_floppy_irq
188 add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs
192 #endif /* (CONFIG_BLK_DEV_FD) */
194 /* Bad trap handler */
195 .globl bad_trap_handler
202 add %sp, STACKFRAME_SZ, %o0 ! pt_regs
204 mov %l7, %o1 ! trap number
208 /* For now all IRQ's not registered get sent here. handler_irq() will
209 * see if a routine is registered to handle this interrupt and if not
210 * it will say so on the console.
214 .globl real_irq_entry, patch_handler_irq
219 .globl patchme_maybe_smp_msg
222 patchme_maybe_smp_msg:
233 mov %l7, %o0 ! irq level
236 add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
237 or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq
238 wr %g2, PSR_ET, %psr ! keep ET up
244 /* SMP per-cpu ticker interrupts are handled specially. */
246 bne real_irq_continue+4
252 call smp4m_percpu_timer_interrupt
253 add %sp, STACKFRAME_SZ, %o0
258 #define GET_PROCESSOR4M_ID(reg) \
260 srl %reg, 12, %reg; \
263 /* Here is where we check for possible SMP IPI passed to us
264 * on some level other than 15 which is the NMI and only used
265 * for cross calls. That has a separate entry point below.
267 * IPIs are sent on Level 12, 13 and 14. See IRQ_IPI_*.
270 GET_PROCESSOR4M_ID(o3)
271 sethi %hi(sun4m_irq_percpu), %l5
273 or %l5, %lo(sun4m_irq_percpu), %o5
274 sethi %hi(0x70000000), %o2 ! Check all soft-IRQs
276 ld [%o1 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
281 st %o2, [%o1 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x70000000
283 ld [%o1 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
290 srl %o3, 28, %o2 ! shift for simpler checks below
291 maybe_smp4m_msg_check_single:
293 beq,a maybe_smp4m_msg_check_mask
295 call smp_call_function_single_interrupt
298 maybe_smp4m_msg_check_mask:
299 beq,a maybe_smp4m_msg_check_resched
301 call smp_call_function_interrupt
304 maybe_smp4m_msg_check_resched:
305 /* rescheduling is done in RESTORE_ALL regardless, but incr stats */
306 beq,a maybe_smp4m_msg_out
308 call smp_resched_interrupt
314 .globl linux_trap_ipi15_sun4m
315 linux_trap_ipi15_sun4m:
317 sethi %hi(0x80000000), %o2
318 GET_PROCESSOR4M_ID(o0)
319 sethi %hi(sun4m_irq_percpu), %l5
320 or %l5, %lo(sun4m_irq_percpu), %o5
323 ld [%o5 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
325 be sun4m_nmi_error ! Must be an NMI async memory error
326 st %o2, [%o5 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x80000000
328 ld [%o5 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
335 call smp4m_cross_call_irq
337 b ret_trap_lockless_ipi
341 /* SMP per-cpu ticker interrupts are handled specially. */
345 sethi %hi(CC_ICLR), %o0
346 sethi %hi(1 << 14), %o1
347 or %o0, %lo(CC_ICLR), %o0
348 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 14 in MXCC's ICLR */
353 call smp4d_percpu_timer_interrupt
354 add %sp, STACKFRAME_SZ, %o0
360 .globl linux_trap_ipi15_sun4d
361 linux_trap_ipi15_sun4d:
363 sethi %hi(CC_BASE), %o4
364 sethi %hi(MXCC_ERR_ME|MXCC_ERR_PEW|MXCC_ERR_ASE|MXCC_ERR_PEE), %o2
365 or %o4, (CC_EREG - CC_BASE), %o0
366 ldda [%o0] ASI_M_MXCC, %o0
369 sethi %hi(BB_STAT2), %o2
370 lduba [%o2] ASI_M_CTL, %o2
371 andcc %o2, BB_STAT2_MASK, %g0
373 or %o4, (CC_ICLR - CC_BASE), %o0
374 sethi %hi(1 << 15), %o1
375 stha %o1, [%o0] ASI_M_MXCC /* Clear PIL 15 in MXCC's ICLR */
381 call smp4d_cross_call_irq
383 b ret_trap_lockless_ipi
390 lduha [%l4] ASI_M_MXCC, %l5
391 sethi %hi(1 << 15), %l7
393 stha %l5, [%l4] ASI_M_MXCC
398 .extern leon_ipi_interrupt
399 /* SMP per-cpu IPI interrupts are handled specially. */
407 call leonsmp_ipi_interrupt
408 add %sp, STACKFRAME_SZ, %o1 ! pt_regs
414 .globl linux_trap_ipi15_leon
415 linux_trap_ipi15_leon:
422 call leon_cross_call_irq
424 b ret_trap_lockless_ipi
427 #endif /* CONFIG_SMP */
429 /* This routine handles illegal instructions and privileged
430 * instruction attempts from user code.
433 .globl bad_instruction
435 sethi %hi(0xc1f80000), %l4
437 sethi %hi(0x81d80000), %l7
443 wr %l0, PSR_ET, %psr ! re-enable traps
446 add %sp, STACKFRAME_SZ, %o0
449 call do_illegal_instruction
454 1: /* unimplemented flush - just skip */
459 .globl priv_instruction
466 add %sp, STACKFRAME_SZ, %o0
469 call do_priv_instruction
474 /* This routine handles unaligned data accesses. */
478 andcc %l0, PSR_PS, %g0
488 call kernel_unaligned_trap
489 add %sp, STACKFRAME_SZ, %o0
496 wr %l0, PSR_ET, %psr ! re-enable traps
500 call user_unaligned_trap
501 add %sp, STACKFRAME_SZ, %o0
505 /* This routine handles floating point disabled traps. */
507 .globl fpd_trap_handler
511 wr %l0, PSR_ET, %psr ! re-enable traps
514 add %sp, STACKFRAME_SZ, %o0
522 /* This routine handles Floating Point Exceptions. */
524 .globl fpe_trap_handler
526 set fpsave_magic, %l5
529 sethi %hi(fpsave), %l5
530 or %l5, %lo(fpsave), %l5
533 sethi %hi(fpsave_catch2), %l5
534 or %l5, %lo(fpsave_catch2), %l5
540 sethi %hi(fpsave_catch), %l5
541 or %l5, %lo(fpsave_catch), %l5
550 wr %l0, PSR_ET, %psr ! re-enable traps
553 add %sp, STACKFRAME_SZ, %o0
561 /* This routine handles Tag Overflow Exceptions. */
563 .globl do_tag_overflow
567 wr %l0, PSR_ET, %psr ! re-enable traps
570 add %sp, STACKFRAME_SZ, %o0
573 call handle_tag_overflow
578 /* This routine handles Watchpoint Exceptions. */
584 wr %l0, PSR_ET, %psr ! re-enable traps
587 add %sp, STACKFRAME_SZ, %o0
590 call handle_watchpoint
595 /* This routine handles Register Access Exceptions. */
601 wr %l0, PSR_ET, %psr ! re-enable traps
604 add %sp, STACKFRAME_SZ, %o0
607 call handle_reg_access
612 /* This routine handles Co-Processor Disabled Exceptions. */
614 .globl do_cp_disabled
618 wr %l0, PSR_ET, %psr ! re-enable traps
621 add %sp, STACKFRAME_SZ, %o0
624 call handle_cp_disabled
629 /* This routine handles Co-Processor Exceptions. */
631 .globl do_cp_exception
635 wr %l0, PSR_ET, %psr ! re-enable traps
638 add %sp, STACKFRAME_SZ, %o0
641 call handle_cp_exception
646 /* This routine handles Hardware Divide By Zero Exceptions. */
652 wr %l0, PSR_ET, %psr ! re-enable traps
655 add %sp, STACKFRAME_SZ, %o0
658 call handle_hw_divzero
664 .globl do_flush_windows
671 andcc %l0, PSR_PS, %g0
675 call flush_user_windows
678 /* Advance over the trap instruction. */
679 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
681 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
682 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
686 .globl flush_patch_one
688 /* We get these for debugging routines using __builtin_return_address() */
691 FLUSH_ALL_KERNEL_WINDOWS
693 /* Advance over the trap instruction. */
694 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1
696 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
697 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
701 /* The getcc software trap. The user wants the condition codes from
702 * the %psr in register %g1.
706 .globl getcc_trap_handler
708 srl %l0, 20, %g1 ! give user
709 and %g1, 0xf, %g1 ! only ICC bits in %psr
710 jmp %l2 ! advance over trap instruction
711 rett %l2 + 0x4 ! like this...
713 /* The setcc software trap. The user has condition codes in %g1
714 * that it would like placed in the %psr. Be careful not to flip
715 * any unintentional bits!
719 .globl setcc_trap_handler
723 andn %l0, %l5, %l0 ! clear ICC bits in %psr
724 and %l4, %l5, %l4 ! clear non-ICC bits in user value
725 or %l4, %l0, %l4 ! or them in... mix mix mix
727 wr %l4, 0x0, %psr ! set new %psr
728 WRITE_PAUSE ! TI scumbags...
730 jmp %l2 ! advance over trap instruction
731 rett %l2 + 0x4 ! like this...
734 /* NMI async memory error handling. */
735 sethi %hi(0x80000000), %l4
736 sethi %hi(sun4m_irq_global), %o5
737 ld [%o5 + %lo(sun4m_irq_global)], %l5
738 st %l4, [%l5 + 0x0c] ! sun4m_irq_global->mask_set=0x80000000
740 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
749 st %l4, [%l5 + 0x08] ! sun4m_irq_global->mask_clear=0x80000000
751 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
757 .globl linux_trap_ipi15_sun4m
758 linux_trap_ipi15_sun4m:
763 #endif /* CONFIG_SMP */
771 LEON_PI(lda [%l5] ASI_LEON_MMUREGS, %l6) ! read sfar first
772 SUN_PI_(lda [%l5] ASI_M_MMUREGS, %l6) ! read sfar first
774 LEON_PI(lda [%l4] ASI_LEON_MMUREGS, %l5) ! read sfsr last
775 SUN_PI_(lda [%l4] ASI_M_MMUREGS, %l5) ! read sfsr last
778 srl %l5, 6, %l5 ! and encode all info into l7
783 or %l6, %l7, %l7 ! l7 = [addr,write,txtfault]
789 and %o1, 1, %o1 ! arg2 = text_faultp
791 and %o2, 2, %o2 ! arg3 = writep
792 andn %o3, 0xfff, %o3 ! arg4 = faulting address
798 add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr
803 .globl sys_nis_syscall
806 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
807 call c_sys_nis_syscall
816 .globl sys_sparc_pipe
819 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
835 add %sp, STACKFRAME_SZ, %o0
837 ld [%curptr + TI_FLAGS], %l5
838 andcc %l5, _TIF_SYSCALL_TRACE, %g0
846 /* We don't want to muck with user registers like a
847 * normal syscall, just return.
852 .globl sys_rt_sigreturn
855 add %sp, STACKFRAME_SZ, %o0
857 ld [%curptr + TI_FLAGS], %l5
858 andcc %l5, _TIF_SYSCALL_TRACE, %g0
862 add %sp, STACKFRAME_SZ, %o0
867 /* We are returning to a signal handler. */
870 /* Now that we have a real sys_clone, sys_fork() is
871 * implemented in terms of it. Our _real_ implementation
872 * of SunOS vfork() will use sys_vfork().
874 * XXX These three should be consolidated into mostly shared
875 * XXX code just like on sparc64... -DaveM
878 .globl sys_fork, flush_patch_two
882 FLUSH_ALL_KERNEL_WINDOWS;
883 ld [%curptr + TI_TASK], %o4
886 mov SIGCHLD, %o0 ! arg0: clone flags
889 mov %fp, %o1 ! arg1: usp
890 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
891 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
896 /* Whee, kernel threads! */
897 .globl sys_clone, flush_patch_three
901 FLUSH_ALL_KERNEL_WINDOWS;
902 ld [%curptr + TI_TASK], %o4
906 /* arg0,1: flags,usp -- loaded already */
907 cmp %o1, 0x0 ! Is new_usp NULL?
911 mov %fp, %o1 ! yes, use callers usp
912 andn %o1, 7, %o1 ! no, align to 8 bytes
914 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
915 add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr
920 /* Whee, real vfork! */
921 .globl sys_vfork, flush_patch_four
924 FLUSH_ALL_KERNEL_WINDOWS;
925 ld [%curptr + TI_TASK], %o4
930 std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr]
931 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
933 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
934 sethi %hi(sparc_do_fork), %l1
936 jmpl %l1 + %lo(sparc_do_fork), %g0
937 add %sp, STACKFRAME_SZ, %o2
940 linux_sparc_ni_syscall:
941 sethi %hi(sys_ni_syscall), %l7
943 or %l7, %lo(sys_ni_syscall), %l7
946 add %sp, STACKFRAME_SZ, %o0
953 /* Syscall tracing can modify the registers. */
954 ld [%sp + STACKFRAME_SZ + PT_G1], %g1
955 sethi %hi(sys_call_table), %l7
956 ld [%sp + STACKFRAME_SZ + PT_I0], %i0
957 or %l7, %lo(sys_call_table), %l7
958 ld [%sp + STACKFRAME_SZ + PT_I1], %i1
959 ld [%sp + STACKFRAME_SZ + PT_I2], %i2
960 ld [%sp + STACKFRAME_SZ + PT_I3], %i3
961 ld [%sp + STACKFRAME_SZ + PT_I4], %i4
962 ld [%sp + STACKFRAME_SZ + PT_I5], %i5
979 ld [%g3 + TI_TASK], %o0
981 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
983 .globl ret_from_kernel_thread
984 ret_from_kernel_thread:
986 ld [%g3 + TI_TASK], %o0
987 ld [%sp + STACKFRAME_SZ + PT_G1], %l0
989 ld [%sp + STACKFRAME_SZ + PT_G2], %o0
991 ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
992 andn %l0, PSR_CWP, %l0
994 and %l1, PSR_CWP, %l1
996 st %l0, [%sp + STACKFRAME_SZ + PT_PSR]
1000 /* Linux native system calls enter here... */
1002 .globl linux_sparc_syscall
1003 linux_sparc_syscall:
1004 sethi %hi(PSR_SYSCALL), %l4
1006 /* Direct access to user regs, must faster. */
1007 cmp %g1, NR_syscalls
1008 bgeu linux_sparc_ni_syscall
1016 wr %l0, PSR_ET, %psr
1021 ld [%curptr + TI_FLAGS], %l5
1023 andcc %l5, _TIF_SYSCALL_TRACE, %g0
1025 bne linux_syscall_trace
1032 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1035 ld [%curptr + TI_FLAGS], %l6
1036 cmp %o0, -ERESTART_RESTARTBLOCK
1037 ld [%sp + STACKFRAME_SZ + PT_PSR], %g3
1040 andcc %l6, _TIF_SYSCALL_TRACE, %g0
1042 /* System call success, clear Carry condition code. */
1045 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1046 bne linux_syscall_trace2
1047 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1048 add %l1, 0x4, %l2 /* npc = npc+4 */
1049 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1051 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1053 /* System call failure, set Carry condition code.
1054 * Also, get abs(errno) to return to the process.
1058 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1060 st %g3, [%sp + STACKFRAME_SZ + PT_PSR]
1061 bne linux_syscall_trace2
1062 ld [%sp + STACKFRAME_SZ + PT_NPC], %l1 /* pc = npc */
1063 add %l1, 0x4, %l2 /* npc = npc+4 */
1064 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1066 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1068 linux_syscall_trace2:
1069 add %sp, STACKFRAME_SZ, %o0
1072 add %l1, 0x4, %l2 /* npc = npc+4 */
1073 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
1075 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1078 /* Saving and restoring the FPU state is best done from lowlevel code.
1080 * void fpsave(unsigned long *fpregs, unsigned long *fsr,
1081 * void *fpqueue, unsigned long *fpqdepth)
1086 st %fsr, [%o1] ! this can trap on us if fpu is in bogon state
1093 /* We have an fpqueue to save. */
1107 std %f0, [%o0 + 0x00]
1108 std %f2, [%o0 + 0x08]
1109 std %f4, [%o0 + 0x10]
1110 std %f6, [%o0 + 0x18]
1111 std %f8, [%o0 + 0x20]
1112 std %f10, [%o0 + 0x28]
1113 std %f12, [%o0 + 0x30]
1114 std %f14, [%o0 + 0x38]
1115 std %f16, [%o0 + 0x40]
1116 std %f18, [%o0 + 0x48]
1117 std %f20, [%o0 + 0x50]
1118 std %f22, [%o0 + 0x58]
1119 std %f24, [%o0 + 0x60]
1120 std %f26, [%o0 + 0x68]
1121 std %f28, [%o0 + 0x70]
1123 std %f30, [%o0 + 0x78]
1125 /* Thanks for Theo Deraadt and the authors of the Sprite/netbsd/openbsd
1126 * code for pointing out this possible deadlock, while we save state
1127 * above we could trap on the fsr store so our low level fpu trap
1128 * code has to know how to deal with this.
1138 /* void fpload(unsigned long *fpregs, unsigned long *fsr); */
1142 ldd [%o0 + 0x00], %f0
1143 ldd [%o0 + 0x08], %f2
1144 ldd [%o0 + 0x10], %f4
1145 ldd [%o0 + 0x18], %f6
1146 ldd [%o0 + 0x20], %f8
1147 ldd [%o0 + 0x28], %f10
1148 ldd [%o0 + 0x30], %f12
1149 ldd [%o0 + 0x38], %f14
1150 ldd [%o0 + 0x40], %f16
1151 ldd [%o0 + 0x48], %f18
1152 ldd [%o0 + 0x50], %f20
1153 ldd [%o0 + 0x58], %f22
1154 ldd [%o0 + 0x60], %f24
1155 ldd [%o0 + 0x68], %f26
1156 ldd [%o0 + 0x70], %f28
1157 ldd [%o0 + 0x78], %f30
1162 /* __ndelay and __udelay take two arguments:
1163 * 0 - nsecs or usecs to delay
1164 * 1 - per_cpu udelay_val (loops per jiffy)
1166 * Note that ndelay gives HZ times higher resolution but has a 10ms
1167 * limit. udelay can handle up to 1s.
1171 save %sp, -STACKFRAME_SZ, %sp
1172 mov %i0, %o0 ! round multiplier up so large ns ok
1173 mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
1176 mov %i1, %o1 ! udelay_val
1180 mov %o1, %o0 ! >>32 later for better resolution
1184 save %sp, -STACKFRAME_SZ, %sp
1186 sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
1187 or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
1190 mov %i1, %o1 ! udelay_val
1193 sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
1194 or %g0, %lo(0x028f4b62), %l0
1195 addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
1199 mov HZ, %o0 ! >>32 earlier for wider range
1211 EXPORT_SYMBOL(__udelay)
1212 EXPORT_SYMBOL(__ndelay)
1214 /* Handle a software breakpoint */
1215 /* We have to inform parent that child has stopped */
1217 .globl breakpoint_trap
1221 wr %l0, PSR_ET, %psr
1224 st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls
1225 call sparc_breakpoint
1226 add %sp, STACKFRAME_SZ, %o0
1231 ENTRY(kgdb_trap_low)
1234 wr %l0, PSR_ET, %psr
1237 mov %l7, %o0 ! trap_level
1239 add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
1242 ENDPROC(kgdb_trap_low)
1246 .globl flush_patch_exception
1247 flush_patch_exception:
1248 FLUSH_ALL_KERNEL_WINDOWS;
1250 jmpl %o7 + 0xc, %g0 ! see asm-sparc/processor.h
1251 mov 1, %g1 ! signal EFAULT condition
1254 .globl kill_user_windows, kuw_patch1_7win
1256 kuw_patch1_7win: sll %o3, 6, %o3
1258 /* No matter how much overhead this routine has in the worst
1259 * case scenario, it is several times better than taking the
1260 * traps with the old method of just doing flush_user_windows().
1263 ld [%g6 + TI_UWINMASK], %o0 ! get current umask
1264 orcc %g0, %o0, %g0 ! if no bits set, we are done
1265 be 3f ! nothing to do
1266 rd %psr, %o5 ! must clear interrupts
1267 or %o5, PSR_PIL, %o4 ! or else that could change
1268 wr %o4, 0x0, %psr ! the uwinmask state
1269 WRITE_PAUSE ! burn them cycles
1271 ld [%g6 + TI_UWINMASK], %o0 ! get consistent state
1272 orcc %g0, %o0, %g0 ! did an interrupt come in?
1273 be 4f ! yep, we are done
1274 rd %wim, %o3 ! get current wim
1275 srl %o3, 1, %o4 ! simulate a save
1277 sll %o3, 7, %o3 ! compute next wim
1278 or %o4, %o3, %o3 ! result
1279 andncc %o0, %o3, %o0 ! clean this bit in umask
1280 bne kuw_patch1 ! not done yet
1281 srl %o3, 1, %o4 ! begin another save simulation
1282 wr %o3, 0x0, %wim ! set the new wim
1283 st %g0, [%g6 + TI_UWINMASK] ! clear uwinmask
1285 wr %o5, 0x0, %psr ! re-enable interrupts
1286 WRITE_PAUSE ! burn baby burn
1289 st %g0, [%g6 + TI_W_SAVED] ! no windows saved
1292 .globl restore_current
1294 LOAD_CURRENT(g6, o0)
1298 #ifdef CONFIG_PCIC_PCI
1299 #include <asm/pcic.h>
1302 .globl linux_trap_ipi15_pcic
1303 linux_trap_ipi15_pcic:
1308 * First deactivate NMI
1309 * or we cannot drop ET, cannot get window spill traps.
1310 * The busy loop is necessary because the PIO error
1311 * sometimes does not go away quickly and we trap again.
1313 sethi %hi(pcic_regs), %o1
1314 ld [%o1 + %lo(pcic_regs)], %o2
1316 ! Get pending status for printouts later.
1317 ld [%o2 + PCI_SYS_INT_PENDING], %o0
1319 mov PCI_SYS_INT_PENDING_CLEAR_ALL, %o1
1320 stb %o1, [%o2 + PCI_SYS_INT_PENDING_CLEAR]
1322 ld [%o2 + PCI_SYS_INT_PENDING], %o1
1323 andcc %o1, ((PCI_SYS_INT_PENDING_PIO|PCI_SYS_INT_PENDING_PCI)>>24), %g0
1327 or %l0, PSR_PIL, %l4
1330 wr %l4, PSR_ET, %psr
1334 add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs
1337 .globl pcic_nmi_trap_patch
1338 pcic_nmi_trap_patch:
1339 sethi %hi(linux_trap_ipi15_pcic), %l3
1340 jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0
1344 #endif /* CONFIG_PCIC_PCI */
1348 save %sp, -0x40, %sp
1349 save %sp, -0x40, %sp
1350 save %sp, -0x40, %sp
1351 save %sp, -0x40, %sp
1352 save %sp, -0x40, %sp
1353 save %sp, -0x40, %sp
1354 save %sp, -0x40, %sp
1365 ENTRY(hard_smp_processor_id)
1369 .section .cpuid_patch, "ax"
1370 /* Instruction location. */
1372 /* SUN4D implementation. */
1373 lda [%g0] ASI_M_VIKING_TMP1, %o0
1376 /* LEON implementation. */
1383 ENDPROC(hard_smp_processor_id)
1386 /* End of entry.S */