1 /* $Id: entry64.S,v 1.7 2002/02/09 19:49:31 davem Exp $
2 * entry64.S: Solaris syscall emulation entry point.
4 * Copyright (C) 1996,1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
9 #include <linux/errno.h>
14 #include <asm/ptrace.h>
16 #include <asm/signal.h>
17 #include <asm/pgtable.h>
18 #include <asm/processor.h>
19 #include <asm/thread_info.h>
23 #define NR_SYSCALLS 256
26 solaris_syscall_trace:
27 add %sp, PTREGS_OFF, %o0
38 add %sp, PTREGS_OFF, %o0
41 /* Solaris is a big system which needs to be able to do all the things
42 * in Inf+1 different ways */
49 movrz %g1, 256, %g1 /* Ensure we don't loop forever */
52 ba,pt %xcc, solaris_sparc_syscall
53 exen: lduwa [%o0] ASI_S, %i5
55 exenf: ba,pt %xcc, solaris_sparc_syscall
58 /* For shared binaries, binfmt_elf32 already sets up personality
59 and exec_domain. This is to handle static binaries as well */
66 linux_syscall_for_solaris:
67 sethi %hi(sys_call_table32), %l6
68 or %l6, %lo(sys_call_table32), %l6
73 /* Solaris system calls enter here... */
75 .globl solaris_sparc_syscall, entry64_personality_patch
76 solaris_sparc_syscall:
77 entry64_personality_patch:
80 bg,pn %icc, solaris_unimplemented
82 sethi %hi(solaris_sys_table), %l7
83 or %l7, %lo(solaris_sys_table), %l7
84 brz,pn %g1, solaris_sucks
88 bne,pn %icc, solaris_reg
92 ldx [%g6 + TI_FLAGS], %l5
94 bleu,a,pn %xcc, linux_syscall_for_solaris
98 add %sp, PTREGS_OFF, %o0
102 andcc %l5, _TIF_SYSCALL_TRACE, %g0
103 bne,pn %icc, solaris_syscall_trace
108 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
109 ldx [%g6 + TI_FLAGS], %l6
111 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
112 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
113 cmp %o0, -ERESTART_RESTARTBLOCK
116 andcc %l6, _TIF_SYSCALL_TRACE, %l6
118 /* System call success, clear Carry condition code. */
120 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
121 bne,pn %icc, solaris_syscall_trace2
122 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
127 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
129 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
131 /* When tnpc & 1, this comes from setcontext and we don't want to advance pc */
134 stx %l1, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc&~3
137 /* System call failure, set Carry condition code.
138 * Also, get abs(errno) to return to the process.
142 cmp %o0, ERANGE /* 0-ERANGE are identity mapped */
146 sethi %hi(solaris_err_table), %l6
148 or %l6, %lo(solaris_err_table), %l6
149 ldsw [%l6 + %o0], %o0
150 1: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
152 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
153 bne,pn %icc, solaris_syscall_trace2
154 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
158 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
160 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
162 solaris_syscall_trace2:
163 add %sp, PTREGS_OFF, %o0
166 add %l1, 0x4, %l2 /* npc = npc+4 */
170 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
172 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
174 /* This one is tricky, so that's why we do it in assembly */
175 .globl solaris_sigsuspend
177 call do_sol_sigsuspend
179 brlz,pn %o0, ret_from_solaris
182 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
183 b,pt %xcc, ret_from_solaris
186 .globl solaris_getpid
191 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
192 b,pt %xcc, ret_from_solaris
195 .globl solaris_getuid
200 stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
201 b,pt %xcc, ret_from_solaris
204 .globl solaris_getgid
209 stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
210 b,pt %xcc, ret_from_solaris
213 .globl solaris_unimplemented
214 solaris_unimplemented:
215 call do_sol_unimplemented
216 add %sp, PTREGS_OFF, %o0
217 ba,pt %xcc, ret_from_solaris
220 .section __ex_table,"a"