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:
37 add %sp, PTREGS_OFF, %o0
40 /* Solaris is a big system which needs to be able to do all the things
41 * in Inf+1 different ways */
48 movrz %g1, 256, %g1 /* Ensure we don't loop forever */
51 ba,pt %xcc, solaris_sparc_syscall
52 exen: lduwa [%o0] ASI_S, %i5
54 exenf: ba,pt %xcc, solaris_sparc_syscall
57 /* For shared binaries, binfmt_elf32 already sets up personality
58 and exec_domain. This is to handle static binaries as well */
65 linux_syscall_for_solaris:
66 sethi %hi(sys_call_table32), %l6
67 or %l6, %lo(sys_call_table32), %l6
72 /* Solaris system calls enter here... */
74 .globl solaris_sparc_syscall, entry64_personality_patch
75 solaris_sparc_syscall:
76 entry64_personality_patch:
79 bg,pn %icc, solaris_unimplemented
81 sethi %hi(solaris_sys_table), %l7
82 or %l7, %lo(solaris_sys_table), %l7
83 brz,pn %g1, solaris_sucks
87 bne,pn %icc, solaris_reg
91 ldx [%g6 + TI_FLAGS], %l5
93 bleu,a,pn %xcc, linux_syscall_for_solaris
97 add %sp, PTREGS_OFF, %o0
101 andcc %l5, _TIF_SYSCALL_TRACE, %g0
102 bne,pn %icc, solaris_syscall_trace
107 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
108 ldx [%g6 + TI_FLAGS], %l6
110 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
111 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
112 cmp %o0, -ERESTART_RESTARTBLOCK
115 andcc %l6, _TIF_SYSCALL_TRACE, %l6
117 /* System call success, clear Carry condition code. */
119 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
120 bne,pn %icc, solaris_syscall_trace2
121 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
126 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
128 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
130 /* When tnpc & 1, this comes from setcontext and we don't want to advance pc */
133 stx %l1, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc&~3
136 /* System call failure, set Carry condition code.
137 * Also, get abs(errno) to return to the process.
141 cmp %o0, ERANGE /* 0-ERANGE are identity mapped */
145 sethi %hi(solaris_err_table), %l6
147 or %l6, %lo(solaris_err_table), %l6
148 ldsw [%l6 + %o0], %o0
149 1: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
151 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
152 bne,pn %icc, solaris_syscall_trace2
153 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
157 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
159 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
161 solaris_syscall_trace2:
163 add %l1, 0x4, %l2 /* npc = npc+4 */
167 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
169 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
171 /* This one is tricky, so that's why we do it in assembly */
172 .globl solaris_sigsuspend
174 call do_sol_sigsuspend
176 brlz,pn %o0, ret_from_solaris
179 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
181 .globl solaris_getpid
186 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
187 b,pt %xcc, ret_from_solaris
190 .globl solaris_getuid
195 stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
196 b,pt %xcc, ret_from_solaris
199 .globl solaris_getgid
204 stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
205 b,pt %xcc, ret_from_solaris
208 .globl solaris_unimplemented
209 solaris_unimplemented:
210 call do_sol_unimplemented
211 add %sp, PTREGS_OFF, %o0
212 ba,pt %xcc, ret_from_solaris
215 .section __ex_table,#alloc