xref: /titanic_52/usr/src/uts/sparc/v9/ml/syscall_trap.s (revision 023e71de9e5670cebc23dd51162833661d3d2d3b)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*023e71deSHaik Aftandilian * Common Development and Distribution License (the "License").
6*023e71deSHaik Aftandilian * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate/*
22*023e71deSHaik Aftandilian * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate/*
277c478bd9Sstevel@tonic-gate * System call trap handler.
287c478bd9Sstevel@tonic-gate */
297c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
307c478bd9Sstevel@tonic-gate#include <sys/machpcb.h>
317c478bd9Sstevel@tonic-gate#include <sys/machthread.h>
327c478bd9Sstevel@tonic-gate#include <sys/syscall.h>
337c478bd9Sstevel@tonic-gate#include <sys/trap.h>
347c478bd9Sstevel@tonic-gate#include <sys/machtrap.h>
357c478bd9Sstevel@tonic-gate#include <sys/pcb.h>
367c478bd9Sstevel@tonic-gate#include <sys/machparam.h>
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate#if !defined(lint) && !defined(__lint)
397c478bd9Sstevel@tonic-gate#include "assym.h"
407c478bd9Sstevel@tonic-gate#endif
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate#ifdef TRAPTRACE
437c478bd9Sstevel@tonic-gate#include <sys/traptrace.h>
447c478bd9Sstevel@tonic-gate#endif /* TRAPTRACE */
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate/*ARGSUSED*/
497c478bd9Sstevel@tonic-gatevoid
507c478bd9Sstevel@tonic-gatesyscall_trap(struct regs *rp)	/* for tags only; not called from C */
517c478bd9Sstevel@tonic-gate{}
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate#else /* lint */
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate#if (1 << SYSENT_SHIFT) != SYSENT_SIZE
567c478bd9Sstevel@tonic-gate#error	"SYSENT_SHIFT does not correspond to size of sysent structure"
577c478bd9Sstevel@tonic-gate#endif
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate/*
607c478bd9Sstevel@tonic-gate * Native System call trap handler.
617c478bd9Sstevel@tonic-gate *
627c478bd9Sstevel@tonic-gate * We branch here from sys_trap when a 64-bit system call occurs.
637c478bd9Sstevel@tonic-gate *
647c478bd9Sstevel@tonic-gate * Entry:
657c478bd9Sstevel@tonic-gate *	%o0 = regs
667c478bd9Sstevel@tonic-gate *
677c478bd9Sstevel@tonic-gate * Usage:
687c478bd9Sstevel@tonic-gate *	%l0 = saved return address
697c478bd9Sstevel@tonic-gate *	%l1 = saved regs
707c478bd9Sstevel@tonic-gate *	%l2 = lwp
717c478bd9Sstevel@tonic-gate */
727c478bd9Sstevel@tonic-gate	ENTRY_NP(syscall_trap)
737c478bd9Sstevel@tonic-gate	ldn	[THREAD_REG + T_CPU], %g1	! get cpu pointer
747c478bd9Sstevel@tonic-gate	mov	%o7, %l0			! save return addr
757c478bd9Sstevel@tonic-gate	!
767c478bd9Sstevel@tonic-gate	! If the trapping thread has the address mask bit set, then it's
777c478bd9Sstevel@tonic-gate	!   a 32-bit process, and has no business calling 64-bit syscalls.
787c478bd9Sstevel@tonic-gate	!
797c478bd9Sstevel@tonic-gate	ldx	[%o0 + TSTATE_OFF], %l1		! saved %tstate.am is that
807c478bd9Sstevel@tonic-gate	andcc	%l1, TSTATE_AM, %l1		!   of the trapping proc
817c478bd9Sstevel@tonic-gate	bne,pn	%xcc, _syscall_ill		!
827c478bd9Sstevel@tonic-gate	mov	%o0, %l1			! save reg pointer
837c478bd9Sstevel@tonic-gate	mov	%i0, %o0			! copy 1st arg
847c478bd9Sstevel@tonic-gate	mov	%i1, %o1			! copy 2nd arg
857c478bd9Sstevel@tonic-gate	ldx	[%g1 + CPU_STATS_SYS_SYSCALL], %g2
867c478bd9Sstevel@tonic-gate	inc	%g2				! cpu_stats.sys.syscall++
877c478bd9Sstevel@tonic-gate	stx	%g2, [%g1 + CPU_STATS_SYS_SYSCALL]
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate	!
907c478bd9Sstevel@tonic-gate	! Set new state for LWP
917c478bd9Sstevel@tonic-gate	!
927c478bd9Sstevel@tonic-gate	ldn	[THREAD_REG + T_LWP], %l2
937c478bd9Sstevel@tonic-gate	mov	LWP_SYS, %g3
947c478bd9Sstevel@tonic-gate	mov	%i2, %o2			! copy 3rd arg
957c478bd9Sstevel@tonic-gate	stb	%g3, [%l2 + LWP_STATE]
967c478bd9Sstevel@tonic-gate	mov	%i3, %o3			! copy 4th arg
977c478bd9Sstevel@tonic-gate	ldx	[%l2 + LWP_RU_SYSC], %g2	! pesky statistics
987c478bd9Sstevel@tonic-gate	mov	%i4, %o4			! copy 5th arg
997c478bd9Sstevel@tonic-gate	addx	%g2, 1, %g2
1007c478bd9Sstevel@tonic-gate	stx	%g2, [%l2 + LWP_RU_SYSC]
1017c478bd9Sstevel@tonic-gate	mov	%i5, %o5			! copy 6th arg
1027c478bd9Sstevel@tonic-gate	! args for direct syscalls now set up
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate#ifdef TRAPTRACE
1057c478bd9Sstevel@tonic-gate	!
1067c478bd9Sstevel@tonic-gate	! make trap trace entry - helps in debugging
1077c478bd9Sstevel@tonic-gate	!
1087c478bd9Sstevel@tonic-gate	rdpr	%pstate, %l3
1097c478bd9Sstevel@tonic-gate	andn	%l3, PSTATE_IE | PSTATE_AM, %g3
1107c478bd9Sstevel@tonic-gate	wrpr	%g0, %g3, %pstate		! disable interrupt
1117c478bd9Sstevel@tonic-gate	TRACE_PTR(%g3, %g2)			! get trace pointer
112*023e71deSHaik Aftandilian	GET_TRACE_TICK(%g1, %g2)
1137c478bd9Sstevel@tonic-gate	stxa	%g1, [%g3 + TRAP_ENT_TICK]%asi
1147c478bd9Sstevel@tonic-gate	ldx	[%l1 + G1_OFF], %g1		! get syscall code
1157c478bd9Sstevel@tonic-gate	TRACE_SAVE_TL_VAL(%g3, %g1)
1167c478bd9Sstevel@tonic-gate	TRACE_SAVE_GL_VAL(%g3, %g0)
1177c478bd9Sstevel@tonic-gate	set	TT_SC_ENTR, %g2
1187c478bd9Sstevel@tonic-gate	stha	%g2, [%g3 + TRAP_ENT_TT]%asi
1197c478bd9Sstevel@tonic-gate	stxa	%g7, [%g3 + TRAP_ENT_TSTATE]%asi ! save thread in tstate space
1207c478bd9Sstevel@tonic-gate	stna	%sp, [%g3 + TRAP_ENT_SP]%asi
1217c478bd9Sstevel@tonic-gate	stna	%o0, [%g3 + TRAP_ENT_F1]%asi
1227c478bd9Sstevel@tonic-gate	stna	%o1, [%g3 + TRAP_ENT_F2]%asi
1237c478bd9Sstevel@tonic-gate	stna	%o2, [%g3 + TRAP_ENT_F3]%asi
1247c478bd9Sstevel@tonic-gate	stna	%o3, [%g3 + TRAP_ENT_F4]%asi
1257c478bd9Sstevel@tonic-gate	stna	%o4, [%g3 + TRAP_ENT_TPC]%asi
1267c478bd9Sstevel@tonic-gate	stna	%o5, [%g3 + TRAP_ENT_TR]%asi
1277c478bd9Sstevel@tonic-gate	TRACE_NEXT(%g3, %g2, %g1)		! set new trace pointer
1287c478bd9Sstevel@tonic-gate	wrpr	%g0, %l3, %pstate		! enable interrupt
1297c478bd9Sstevel@tonic-gate#endif /* TRAPTRACE */
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate	!
1327c478bd9Sstevel@tonic-gate	! Test for pre-system-call handling
1337c478bd9Sstevel@tonic-gate	!
1347c478bd9Sstevel@tonic-gate	ldub	[THREAD_REG + T_PRE_SYS], %g3	! pre-syscall proc?
1357c478bd9Sstevel@tonic-gate#ifdef SYSCALLTRACE
1367c478bd9Sstevel@tonic-gate	sethi	%hi(syscalltrace), %g4
1377c478bd9Sstevel@tonic-gate	ld	[%g4 + %lo(syscalltrace)], %g4
1387c478bd9Sstevel@tonic-gate	orcc	%g3, %g4, %g0			! pre_syscall OR syscalltrace?
1397c478bd9Sstevel@tonic-gate#else
1407c478bd9Sstevel@tonic-gate	tst	%g3				! is pre_syscall flag set?
1417c478bd9Sstevel@tonic-gate#endif /* SYSCALLTRACE */
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate	bnz,pn	%icc, _syscall_pre
1447c478bd9Sstevel@tonic-gate	nop
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate	! Fast path invocation of new_mstate
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate	mov	LMS_USER, %o0
1497c478bd9Sstevel@tonic-gate	call	syscall_mstate
1507c478bd9Sstevel@tonic-gate	mov	LMS_SYSTEM, %o1
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate	ldx	[%l1 + O0_OFF], %o0		! restore %o0
1537c478bd9Sstevel@tonic-gate	ldx	[%l1 + O1_OFF], %o1		! restore %o1
1547c478bd9Sstevel@tonic-gate	ldx	[%l1 + O2_OFF], %o2
1557c478bd9Sstevel@tonic-gate	ldx     [%l1 + O3_OFF], %o3
1567c478bd9Sstevel@tonic-gate	ldx     [%l1 + O4_OFF], %o4
1577c478bd9Sstevel@tonic-gate	ldx	[%l1 + O5_OFF], %o5
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate	! lwp_arg now set up
1607c478bd9Sstevel@tonic-gate3:
1617c478bd9Sstevel@tonic-gate	!
1627c478bd9Sstevel@tonic-gate	! Call the handler.  The %o's and lwp_arg have been set up.
1637c478bd9Sstevel@tonic-gate	!
1647c478bd9Sstevel@tonic-gate	ldx	[%l1 + G1_OFF], %g1		! get code
1657c478bd9Sstevel@tonic-gate	set	sysent, %g3			! load address of vector table
1667c478bd9Sstevel@tonic-gate	cmp	%g1, NSYSCALL			! check range
1677c478bd9Sstevel@tonic-gate	sth	%g1, [THREAD_REG + T_SYSNUM]	! save syscall code
1687c478bd9Sstevel@tonic-gate	bgeu,pn	%ncc, _syscall_ill
1697c478bd9Sstevel@tonic-gate	  sll	%g1, SYSENT_SHIFT, %g4			! delay - get index
1707c478bd9Sstevel@tonic-gate	add	%g3, %g4, %l4
1717c478bd9Sstevel@tonic-gate	ldn	[%l4 + SY_CALLC], %g3		! load system call handler
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate	call	%g3				! call system call handler
1747c478bd9Sstevel@tonic-gate	  nop
1757c478bd9Sstevel@tonic-gate	!
1767c478bd9Sstevel@tonic-gate	! If handler returns two ints, then we need to split the 64-bit
1777c478bd9Sstevel@tonic-gate	! return value in %o0 into %o0 and %o1
1787c478bd9Sstevel@tonic-gate	!
1797c478bd9Sstevel@tonic-gate	lduh	[%l4 + SY_FLAGS], %l4		! load sy_flags
1807c478bd9Sstevel@tonic-gate	andcc	%l4, SE_32RVAL2, %g0		! check for 2 x 32-bit
1817c478bd9Sstevel@tonic-gate	bz,pt	%xcc, 5f
1827c478bd9Sstevel@tonic-gate	  nop
1837c478bd9Sstevel@tonic-gate	srl	%o0, 0, %o1			! lower 32-bits into %o1
1847c478bd9Sstevel@tonic-gate	srlx	%o0, 32, %o0			! upper 32-bits into %o0
1857c478bd9Sstevel@tonic-gate5:
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate#ifdef TRAPTRACE
1887c478bd9Sstevel@tonic-gate	!
1897c478bd9Sstevel@tonic-gate	! make trap trace entry for return - helps in debugging
1907c478bd9Sstevel@tonic-gate	!
1917c478bd9Sstevel@tonic-gate	rdpr	%pstate, %g5
1927c478bd9Sstevel@tonic-gate	andn	%g5, PSTATE_IE | PSTATE_AM, %g4
1937c478bd9Sstevel@tonic-gate	wrpr	%g0, %g4, %pstate		! disable interrupt
1947c478bd9Sstevel@tonic-gate	TRACE_PTR(%g4, %g2)			! get trace pointer
195*023e71deSHaik Aftandilian	GET_TRACE_TICK(%g2, %g3)
1967c478bd9Sstevel@tonic-gate	stxa	%g2, [%g4 + TRAP_ENT_TICK]%asi
1977c478bd9Sstevel@tonic-gate	lduh	[THREAD_REG + T_SYSNUM], %g2
1987c478bd9Sstevel@tonic-gate	TRACE_SAVE_TL_VAL(%g4, %g2)
1997c478bd9Sstevel@tonic-gate	TRACE_SAVE_GL_VAL(%g4, %g0)
2007c478bd9Sstevel@tonic-gate	mov	TT_SC_RET, %g2			! system call return code
2017c478bd9Sstevel@tonic-gate	stha	%g2, [%g4 + TRAP_ENT_TT]%asi
2027c478bd9Sstevel@tonic-gate	ldn	[%l1 + nPC_OFF], %g2		! get saved npc (new pc)
2037c478bd9Sstevel@tonic-gate	stna	%g2, [%g4 + TRAP_ENT_TPC]%asi
2047c478bd9Sstevel@tonic-gate	ldx	[%l1 + TSTATE_OFF], %g2		! get saved tstate
2057c478bd9Sstevel@tonic-gate	stxa	%g2, [%g4 + TRAP_ENT_TSTATE]%asi
2067c478bd9Sstevel@tonic-gate	stna	%sp, [%g4 + TRAP_ENT_SP]%asi
2077c478bd9Sstevel@tonic-gate	stna	THREAD_REG, [%g4 + TRAP_ENT_TR]%asi
2087c478bd9Sstevel@tonic-gate	stna	%o0, [%g4 + TRAP_ENT_F1]%asi
2097c478bd9Sstevel@tonic-gate	stna	%o1, [%g4 + TRAP_ENT_F2]%asi
2107c478bd9Sstevel@tonic-gate	stna	%g0, [%g4 + TRAP_ENT_F3]%asi
2117c478bd9Sstevel@tonic-gate	stna	%g0, [%g4 + TRAP_ENT_F4]%asi
2127c478bd9Sstevel@tonic-gate	TRACE_NEXT(%g4, %g2, %g3)		! set new trace pointer
2137c478bd9Sstevel@tonic-gate	wrpr	%g0, %g5, %pstate		! enable interrupt
2147c478bd9Sstevel@tonic-gate#endif /* TRAPTRACE */
2157c478bd9Sstevel@tonic-gate	!
2167c478bd9Sstevel@tonic-gate	! Check for post-syscall processing.
2177c478bd9Sstevel@tonic-gate	! This tests all members of the union containing t_astflag, t_post_sys,
2187c478bd9Sstevel@tonic-gate	! and t_sig_check with one test.
2197c478bd9Sstevel@tonic-gate	!
2207c478bd9Sstevel@tonic-gate	ld	[THREAD_REG + T_POST_SYS_AST], %g1
2217c478bd9Sstevel@tonic-gate#ifdef SYSCALLTRACE
2227c478bd9Sstevel@tonic-gate	sethi	%hi(syscalltrace), %g4
2237c478bd9Sstevel@tonic-gate	ld	[%g4 + %lo(syscalltrace)], %g4
2247c478bd9Sstevel@tonic-gate	orcc	%g4, %g1, %g0			! OR in syscalltrace
2257c478bd9Sstevel@tonic-gate#else
2267c478bd9Sstevel@tonic-gate	tst	%g1				! need post-processing?
2277c478bd9Sstevel@tonic-gate#endif /* SYSCALLTRACE */
2287c478bd9Sstevel@tonic-gate	bnz,pn	%icc, _syscall_post		! yes - post_syscall or AST set
2297c478bd9Sstevel@tonic-gate	mov	LWP_USER, %g1
2307c478bd9Sstevel@tonic-gate	stb	%g1, [%l2 + LWP_STATE]		! set lwp_state
2317c478bd9Sstevel@tonic-gate	stx	%o0, [%l1 + O0_OFF]		! set rp->r_o0
2327c478bd9Sstevel@tonic-gate	stx	%o1, [%l1 + O1_OFF]		! set rp->r_o1
2337c478bd9Sstevel@tonic-gate	clrh	[THREAD_REG + T_SYSNUM]		! clear syscall code
2347c478bd9Sstevel@tonic-gate	ldx	[%l1 + TSTATE_OFF], %g1		! get saved tstate
2357c478bd9Sstevel@tonic-gate	ldn	[%l1 + nPC_OFF], %g2		! get saved npc (new pc)
2367c478bd9Sstevel@tonic-gate	mov	CCR_IC, %g3
2377c478bd9Sstevel@tonic-gate	sllx	%g3, TSTATE_CCR_SHIFT, %g3
2387c478bd9Sstevel@tonic-gate	add	%g2, 4, %g4			! calc new npc
2397c478bd9Sstevel@tonic-gate	andn	%g1, %g3, %g1			! clear carry bit for no error
2407c478bd9Sstevel@tonic-gate	stn	%g2, [%l1 + PC_OFF]
2417c478bd9Sstevel@tonic-gate	stn	%g4, [%l1 + nPC_OFF]
2427c478bd9Sstevel@tonic-gate	stx	%g1, [%l1 + TSTATE_OFF]
2437c478bd9Sstevel@tonic-gate
2447c478bd9Sstevel@tonic-gate	! Switch mstate back on the way out
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate	mov	LMS_SYSTEM, %o0
2477c478bd9Sstevel@tonic-gate	call	syscall_mstate
2487c478bd9Sstevel@tonic-gate	mov	LMS_USER, %o1
2497c478bd9Sstevel@tonic-gate	jmp	%l0 + 8
2507c478bd9Sstevel@tonic-gate	 nop
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate_syscall_pre:
2537c478bd9Sstevel@tonic-gate	ldx	[%l1 + G1_OFF], %g1
2547c478bd9Sstevel@tonic-gate	call	pre_syscall			! abort = pre_syscall(arg0)
2557c478bd9Sstevel@tonic-gate	sth	%g1, [THREAD_REG + T_SYSNUM]
2567c478bd9Sstevel@tonic-gate
2577c478bd9Sstevel@tonic-gate	brnz,pn	%o0, _syscall_post		! did it abort?
2587c478bd9Sstevel@tonic-gate	nop
2597c478bd9Sstevel@tonic-gate	ldx	[%l1 + O0_OFF], %o0		! reload args
2607c478bd9Sstevel@tonic-gate	ldx	[%l1 + O1_OFF], %o1
2617c478bd9Sstevel@tonic-gate	ldx	[%l1 + O2_OFF], %o2
2627c478bd9Sstevel@tonic-gate	ldx	[%l1 + O3_OFF], %o3
2637c478bd9Sstevel@tonic-gate	ldx	[%l1 + O4_OFF], %o4
2647c478bd9Sstevel@tonic-gate	ba,pt	%xcc, 3b
2657c478bd9Sstevel@tonic-gate	ldx	[%l1 + O5_OFF], %o5
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate	!
2687c478bd9Sstevel@tonic-gate	! Floating-point trap was pending at start of system call.
2697c478bd9Sstevel@tonic-gate	! Here with:
2707c478bd9Sstevel@tonic-gate	!	%l3 = mpcb_flags
2717c478bd9Sstevel@tonic-gate	!
2727c478bd9Sstevel@tonic-gate_syscall_fp:
2737c478bd9Sstevel@tonic-gate	andn	%l3, FP_TRAPPED, %l3
2747c478bd9Sstevel@tonic-gate	st	%l3, [%sp + STACK_BIAS + MPCB_FLAGS] 	! clear FP_TRAPPED
2757c478bd9Sstevel@tonic-gate	jmp	%l0 + 8				! return to user_rtt
2767c478bd9Sstevel@tonic-gate	clrh	[THREAD_REG + T_SYSNUM]		! clear syscall code
2777c478bd9Sstevel@tonic-gate
2787c478bd9Sstevel@tonic-gate	!
2797c478bd9Sstevel@tonic-gate	! illegal system call - syscall number out of range
2807c478bd9Sstevel@tonic-gate	!
2817c478bd9Sstevel@tonic-gate_syscall_ill:
2827c478bd9Sstevel@tonic-gate	call	nosys
2837c478bd9Sstevel@tonic-gate	nop
2847c478bd9Sstevel@tonic-gate	!
2857c478bd9Sstevel@tonic-gate	! Post-syscall with special processing needed.
2867c478bd9Sstevel@tonic-gate	!
2877c478bd9Sstevel@tonic-gate_syscall_post:
2887c478bd9Sstevel@tonic-gate	call	post_syscall			! post_syscall(rvals)
2897c478bd9Sstevel@tonic-gate	nop
2907c478bd9Sstevel@tonic-gate	jmp	%l0 + 8				! return to user_rtt
2917c478bd9Sstevel@tonic-gate	nop
2927c478bd9Sstevel@tonic-gate	SET_SIZE(syscall_trap)
2937c478bd9Sstevel@tonic-gate#endif	/* lint */
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gatevoid
2987c478bd9Sstevel@tonic-gatesyscall_trap32(void)	/* for tags only - trap handler - not called from C */
2997c478bd9Sstevel@tonic-gate{}
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate#else /* lint */
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate/*
3047c478bd9Sstevel@tonic-gate * System call trap handler for ILP32 processes.
3057c478bd9Sstevel@tonic-gate *
3067c478bd9Sstevel@tonic-gate * We branch here from sys_trap when a system call occurs.
3077c478bd9Sstevel@tonic-gate *
3087c478bd9Sstevel@tonic-gate * Entry:
3097c478bd9Sstevel@tonic-gate *	%o0 = regs
3107c478bd9Sstevel@tonic-gate *
3117c478bd9Sstevel@tonic-gate * Usage:
3127c478bd9Sstevel@tonic-gate *	%l0 = saved return address
3137c478bd9Sstevel@tonic-gate *	%l1 = saved regs
3147c478bd9Sstevel@tonic-gate *	%l2 = lwp
3157c478bd9Sstevel@tonic-gate */
3167c478bd9Sstevel@tonic-gate	ENTRY_NP(syscall_trap32)
3177c478bd9Sstevel@tonic-gate	ldx	[THREAD_REG + T_CPU], %g1	! get cpu pointer
3187c478bd9Sstevel@tonic-gate	mov	%o7, %l0			! save return addr
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate	!
3217c478bd9Sstevel@tonic-gate	! If the trapping thread has the address mask bit clear, then it's
3227c478bd9Sstevel@tonic-gate	!   a 64-bit process, and has no business calling 32-bit syscalls.
3237c478bd9Sstevel@tonic-gate	!
3247c478bd9Sstevel@tonic-gate	ldx	[%o0 + TSTATE_OFF], %l1		! saved %tstate.am is that
3257c478bd9Sstevel@tonic-gate	andcc	%l1, TSTATE_AM, %l1		!   of the trapping proc
3267c478bd9Sstevel@tonic-gate	be,pn	%xcc, _syscall_ill32		!
3277c478bd9Sstevel@tonic-gate	  mov	%o0, %l1			! save reg pointer
3287c478bd9Sstevel@tonic-gate	srl	%i0, 0, %o0			! copy 1st arg, clear high bits
3297c478bd9Sstevel@tonic-gate	srl	%i1, 0, %o1			! copy 2nd arg, clear high bits
3307c478bd9Sstevel@tonic-gate	ldx	[%g1 + CPU_STATS_SYS_SYSCALL], %g2
3317c478bd9Sstevel@tonic-gate	inc	%g2				! cpu_stats.sys.syscall++
3327c478bd9Sstevel@tonic-gate	stx	%g2, [%g1 + CPU_STATS_SYS_SYSCALL]
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate	!
3357c478bd9Sstevel@tonic-gate	! Set new state for LWP
3367c478bd9Sstevel@tonic-gate	!
3377c478bd9Sstevel@tonic-gate	ldx	[THREAD_REG + T_LWP], %l2
3387c478bd9Sstevel@tonic-gate	mov	LWP_SYS, %g3
3397c478bd9Sstevel@tonic-gate	srl	%i2, 0, %o2			! copy 3rd arg, clear high bits
3407c478bd9Sstevel@tonic-gate	stb	%g3, [%l2 + LWP_STATE]
3417c478bd9Sstevel@tonic-gate	srl	%i3, 0, %o3			! copy 4th arg, clear high bits
3427c478bd9Sstevel@tonic-gate	ldx	[%l2 + LWP_RU_SYSC], %g2	! pesky statistics
3437c478bd9Sstevel@tonic-gate	srl	%i4, 0, %o4			! copy 5th arg, clear high bits
3447c478bd9Sstevel@tonic-gate	addx	%g2, 1, %g2
3457c478bd9Sstevel@tonic-gate	stx	%g2, [%l2 + LWP_RU_SYSC]
3467c478bd9Sstevel@tonic-gate	srl	%i5, 0, %o5			! copy 6th arg, clear high bits
3477c478bd9Sstevel@tonic-gate	! args for direct syscalls now set up
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate#ifdef TRAPTRACE
3507c478bd9Sstevel@tonic-gate	!
3517c478bd9Sstevel@tonic-gate	! make trap trace entry - helps in debugging
3527c478bd9Sstevel@tonic-gate	!
3537c478bd9Sstevel@tonic-gate	rdpr	%pstate, %l3
3547c478bd9Sstevel@tonic-gate	andn	%l3, PSTATE_IE | PSTATE_AM, %g3
3557c478bd9Sstevel@tonic-gate	wrpr	%g0, %g3, %pstate		! disable interrupt
3567c478bd9Sstevel@tonic-gate	TRACE_PTR(%g3, %g2)			! get trace pointer
357*023e71deSHaik Aftandilian	GET_TRACE_TICK(%g1, %g2)
3587c478bd9Sstevel@tonic-gate	stxa	%g1, [%g3 + TRAP_ENT_TICK]%asi
3597c478bd9Sstevel@tonic-gate	ldx	[%l1 + G1_OFF], %g1		! get syscall code
3607c478bd9Sstevel@tonic-gate	TRACE_SAVE_TL_VAL(%g3, %g1)
3617c478bd9Sstevel@tonic-gate	TRACE_SAVE_GL_VAL(%g3, %g0)
3627c478bd9Sstevel@tonic-gate	set	TT_SC_ENTR, %g2
3637c478bd9Sstevel@tonic-gate	stha	%g2, [%g3 + TRAP_ENT_TT]%asi
3647c478bd9Sstevel@tonic-gate	stxa	%g7, [%g3 + TRAP_ENT_TSTATE]%asi ! save thread in tstate space
3657c478bd9Sstevel@tonic-gate	stna	%sp, [%g3 + TRAP_ENT_SP]%asi
3667c478bd9Sstevel@tonic-gate	stna	%o0, [%g3 + TRAP_ENT_F1]%asi
3677c478bd9Sstevel@tonic-gate	stna	%o1, [%g3 + TRAP_ENT_F2]%asi
3687c478bd9Sstevel@tonic-gate	stna	%o2, [%g3 + TRAP_ENT_F3]%asi
3697c478bd9Sstevel@tonic-gate	stna	%o3, [%g3 + TRAP_ENT_F4]%asi
3707c478bd9Sstevel@tonic-gate	stna	%o4, [%g3 + TRAP_ENT_TPC]%asi
3717c478bd9Sstevel@tonic-gate	stna	%o5, [%g3 + TRAP_ENT_TR]%asi
3727c478bd9Sstevel@tonic-gate	TRACE_NEXT(%g3, %g2, %g1)		! set new trace pointer
3737c478bd9Sstevel@tonic-gate	wrpr	%g0, %l3, %pstate		! enable interrupt
3747c478bd9Sstevel@tonic-gate#endif /* TRAPTRACE */
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate	!
3777c478bd9Sstevel@tonic-gate	! Test for pre-system-call handling
3787c478bd9Sstevel@tonic-gate	!
3797c478bd9Sstevel@tonic-gate	ldub	[THREAD_REG + T_PRE_SYS], %g3	! pre-syscall proc?
3807c478bd9Sstevel@tonic-gate#ifdef SYSCALLTRACE
3817c478bd9Sstevel@tonic-gate	sethi	%hi(syscalltrace), %g4
3827c478bd9Sstevel@tonic-gate	ld	[%g4 + %lo(syscalltrace)], %g4
3837c478bd9Sstevel@tonic-gate	orcc	%g3, %g4, %g0			! pre_syscall OR syscalltrace?
3847c478bd9Sstevel@tonic-gate#else
3857c478bd9Sstevel@tonic-gate	tst	%g3				! is pre_syscall flag set?
3867c478bd9Sstevel@tonic-gate#endif /* SYSCALLTRACE */
3877c478bd9Sstevel@tonic-gate	bnz,pn	%icc, _syscall_pre32		! yes - pre_syscall needed
3887c478bd9Sstevel@tonic-gate	  nop
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate	! Fast path invocation of new_mstate
3917c478bd9Sstevel@tonic-gate	mov	LMS_USER, %o0
3927c478bd9Sstevel@tonic-gate	call 	syscall_mstate
3937c478bd9Sstevel@tonic-gate	mov	LMS_SYSTEM, %o1
3947c478bd9Sstevel@tonic-gate
3957c478bd9Sstevel@tonic-gate 	lduw	[%l1 + O0_OFF + 4], %o0		! reload 32-bit args
3967c478bd9Sstevel@tonic-gate	lduw	[%l1 + O1_OFF + 4], %o1
3977c478bd9Sstevel@tonic-gate	lduw	[%l1 + O2_OFF + 4], %o2
3987c478bd9Sstevel@tonic-gate	lduw	[%l1 + O3_OFF + 4], %o3
3997c478bd9Sstevel@tonic-gate	lduw	[%l1 + O4_OFF + 4], %o4
4007c478bd9Sstevel@tonic-gate	lduw	[%l1 + O5_OFF + 4], %o5
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gate	! lwp_arg now set up
4037c478bd9Sstevel@tonic-gate3:
4047c478bd9Sstevel@tonic-gate	!
4057c478bd9Sstevel@tonic-gate	! Call the handler.  The %o's have been set up.
4067c478bd9Sstevel@tonic-gate	!
4077c478bd9Sstevel@tonic-gate	lduw	[%l1 + G1_OFF + 4], %g1		! get 32-bit code
4087c478bd9Sstevel@tonic-gate	set	sysent32, %g3			! load address of vector table
4097c478bd9Sstevel@tonic-gate	cmp	%g1, NSYSCALL			! check range
4107c478bd9Sstevel@tonic-gate	sth	%g1, [THREAD_REG + T_SYSNUM]	! save syscall code
4117c478bd9Sstevel@tonic-gate	bgeu,pn	%ncc, _syscall_ill32
4127c478bd9Sstevel@tonic-gate	  sll	%g1, SYSENT_SHIFT, %g4		! delay - get index
4137c478bd9Sstevel@tonic-gate	add	%g3, %g4, %g5			! g5 = addr of sysentry
4147c478bd9Sstevel@tonic-gate	ldx	[%g5 + SY_CALLC], %g3		! load system call handler
4157c478bd9Sstevel@tonic-gate
4167c478bd9Sstevel@tonic-gate	brnz,a,pt %g1, 4f			! check for indir()
4177c478bd9Sstevel@tonic-gate	mov	%g5, %l4			! save addr of sysentry
4187c478bd9Sstevel@tonic-gate	!
4197c478bd9Sstevel@tonic-gate	! Yuck.  If %g1 is zero, that means we're doing a syscall() via the
4207c478bd9Sstevel@tonic-gate	! indirect system call.  That means we have to check the
4217c478bd9Sstevel@tonic-gate	! flags of the targetted system call, not the indirect system call
4227c478bd9Sstevel@tonic-gate	! itself.  See return value handling code below.
4237c478bd9Sstevel@tonic-gate	!
4247c478bd9Sstevel@tonic-gate	set	sysent32, %l4			! load address of vector table
4257c478bd9Sstevel@tonic-gate	cmp	%o0, NSYSCALL			! check range
4267c478bd9Sstevel@tonic-gate	bgeu,pn	%ncc, 4f			! out of range, let C handle it
4277c478bd9Sstevel@tonic-gate	  sll	%o0, SYSENT_SHIFT, %g4		! delay - get index
4287c478bd9Sstevel@tonic-gate	add	%g4, %l4, %l4			! compute & save addr of sysent
4297c478bd9Sstevel@tonic-gate4:
4307c478bd9Sstevel@tonic-gate	call	%g3				! call system call handler
4317c478bd9Sstevel@tonic-gate	nop
4327c478bd9Sstevel@tonic-gate
4337c478bd9Sstevel@tonic-gate	!
4347c478bd9Sstevel@tonic-gate	! If handler returns long long then we need to split the 64 bit
4357c478bd9Sstevel@tonic-gate	! return value in %o0 into %o0 and %o1 for ILP32 clients.
4367c478bd9Sstevel@tonic-gate	!
4377c478bd9Sstevel@tonic-gate	lduh    [%l4 + SY_FLAGS], %g4           ! load sy_flags
4387c478bd9Sstevel@tonic-gate	andcc	%g4, SE_64RVAL | SE_32RVAL2, %g0 ! check for 64-bit return
4397c478bd9Sstevel@tonic-gate	bz,a,pt	%xcc, 5f
4407c478bd9Sstevel@tonic-gate	  srl	%o0, 0, %o0			! 32-bit only
4417c478bd9Sstevel@tonic-gate	srl	%o0, 0, %o1			! lower 32 bits into %o1
4427c478bd9Sstevel@tonic-gate	srlx	%o0, 32, %o0			! upper 32 bits into %o0
4437c478bd9Sstevel@tonic-gate5:
4447c478bd9Sstevel@tonic-gate
4457c478bd9Sstevel@tonic-gate#ifdef TRAPTRACE
4467c478bd9Sstevel@tonic-gate	!
4477c478bd9Sstevel@tonic-gate	! make trap trace entry for return - helps in debugging
4487c478bd9Sstevel@tonic-gate	!
4497c478bd9Sstevel@tonic-gate	rdpr	%pstate, %g5
4507c478bd9Sstevel@tonic-gate	andn	%g5, PSTATE_IE | PSTATE_AM, %g4
4517c478bd9Sstevel@tonic-gate	wrpr	%g0, %g4, %pstate		! disable interrupt
4527c478bd9Sstevel@tonic-gate	TRACE_PTR(%g4, %g2)			! get trace pointer
453*023e71deSHaik Aftandilian	GET_TRACE_TICK(%g2, %g3)
4547c478bd9Sstevel@tonic-gate	stxa	%g2, [%g4 + TRAP_ENT_TICK]%asi
4557c478bd9Sstevel@tonic-gate	lduh	[THREAD_REG + T_SYSNUM], %g2
4567c478bd9Sstevel@tonic-gate	TRACE_SAVE_TL_VAL(%g4, %g2)
4577c478bd9Sstevel@tonic-gate	TRACE_SAVE_GL_VAL(%g4, %g0)
4587c478bd9Sstevel@tonic-gate	mov	TT_SC_RET, %g2			! system call return code
4597c478bd9Sstevel@tonic-gate	stha	%g2, [%g4 + TRAP_ENT_TT]%asi
4607c478bd9Sstevel@tonic-gate	ldx	[%l1 + nPC_OFF], %g2		! get saved npc (new pc)
4617c478bd9Sstevel@tonic-gate	stna	%g2, [%g4 + TRAP_ENT_TPC]%asi
4627c478bd9Sstevel@tonic-gate	ldx	[%l1 + TSTATE_OFF], %g2		! get saved tstate
4637c478bd9Sstevel@tonic-gate	stxa	%g2, [%g4 + TRAP_ENT_TSTATE]%asi
4647c478bd9Sstevel@tonic-gate	stna	%sp, [%g4 + TRAP_ENT_SP]%asi
4657c478bd9Sstevel@tonic-gate	stna	THREAD_REG, [%g4 + TRAP_ENT_TR]%asi
4667c478bd9Sstevel@tonic-gate	stna	%o0, [%g4 + TRAP_ENT_F1]%asi
4677c478bd9Sstevel@tonic-gate	stna	%o1, [%g4 + TRAP_ENT_F2]%asi
4687c478bd9Sstevel@tonic-gate	stna	%g0, [%g4 + TRAP_ENT_F3]%asi
4697c478bd9Sstevel@tonic-gate	stna	%g0, [%g4 + TRAP_ENT_F4]%asi
4707c478bd9Sstevel@tonic-gate	TRACE_NEXT(%g4, %g2, %g3)		! set new trace pointer
4717c478bd9Sstevel@tonic-gate	wrpr	%g0, %g5, %pstate		! enable interrupt
4727c478bd9Sstevel@tonic-gate#endif /* TRAPTRACE */
4737c478bd9Sstevel@tonic-gate	!
4747c478bd9Sstevel@tonic-gate	! Check for post-syscall processing.
4757c478bd9Sstevel@tonic-gate	! This tests all members of the union containing t_astflag, t_post_sys,
4767c478bd9Sstevel@tonic-gate	! and t_sig_check with one test.
4777c478bd9Sstevel@tonic-gate	!
4787c478bd9Sstevel@tonic-gate	ld	[THREAD_REG + T_POST_SYS_AST], %g1
4797c478bd9Sstevel@tonic-gate#ifdef SYSCALLTRACE
4807c478bd9Sstevel@tonic-gate	sethi	%hi(syscalltrace), %g4
4817c478bd9Sstevel@tonic-gate	ld	[%g4 + %lo(syscalltrace)], %g4
4827c478bd9Sstevel@tonic-gate	orcc	%g4, %g1, %g0			! OR in syscalltrace
4837c478bd9Sstevel@tonic-gate#else
4847c478bd9Sstevel@tonic-gate	tst	%g1				! need post-processing?
4857c478bd9Sstevel@tonic-gate#endif /* SYSCALLTRACE */
4867c478bd9Sstevel@tonic-gate	bnz,pn	%icc, _syscall_post32		! yes - post_syscall or AST set
4877c478bd9Sstevel@tonic-gate	mov	LWP_USER, %g1
4887c478bd9Sstevel@tonic-gate	stb	%g1, [%l2 + LWP_STATE]		! set lwp_state
4897c478bd9Sstevel@tonic-gate	stx	%o0, [%l1 + O0_OFF]		! set rp->r_o0
4907c478bd9Sstevel@tonic-gate	stx	%o1, [%l1 + O1_OFF]		! set rp->r_o1
4917c478bd9Sstevel@tonic-gate	clrh	[THREAD_REG + T_SYSNUM]		! clear syscall code
4927c478bd9Sstevel@tonic-gate	ldx	[%l1 + TSTATE_OFF], %g1		! get saved tstate
4937c478bd9Sstevel@tonic-gate	ldx	[%l1 + nPC_OFF], %g2		! get saved npc (new pc)
4947c478bd9Sstevel@tonic-gate	mov	CCR_IC, %g3
4957c478bd9Sstevel@tonic-gate	sllx	%g3, TSTATE_CCR_SHIFT, %g3
4967c478bd9Sstevel@tonic-gate	add	%g2, 4, %g4			! calc new npc
4977c478bd9Sstevel@tonic-gate	andn	%g1, %g3, %g1			! clear carry bit for no error
4987c478bd9Sstevel@tonic-gate	stx	%g2, [%l1 + PC_OFF]
4997c478bd9Sstevel@tonic-gate	stx	%g4, [%l1 + nPC_OFF]
5007c478bd9Sstevel@tonic-gate	stx	%g1, [%l1 + TSTATE_OFF]
5017c478bd9Sstevel@tonic-gate
5027c478bd9Sstevel@tonic-gate	! fast path outbound microstate accounting call
5037c478bd9Sstevel@tonic-gate	mov	LMS_SYSTEM, %o0
5047c478bd9Sstevel@tonic-gate	call 	syscall_mstate
5057c478bd9Sstevel@tonic-gate	mov	LMS_USER, %o1
5067c478bd9Sstevel@tonic-gate
5077c478bd9Sstevel@tonic-gate	jmp	%l0 + 8
5087c478bd9Sstevel@tonic-gate	 nop
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate
5117c478bd9Sstevel@tonic-gate_syscall_pre32:
5127c478bd9Sstevel@tonic-gate	ldx	[%l1 + G1_OFF], %g1
5137c478bd9Sstevel@tonic-gate	call	pre_syscall			! abort = pre_syscall(arg0)
5147c478bd9Sstevel@tonic-gate	sth	%g1, [THREAD_REG + T_SYSNUM]
5157c478bd9Sstevel@tonic-gate
5167c478bd9Sstevel@tonic-gate	brnz,pn	%o0, _syscall_post32		! did it abort?
5177c478bd9Sstevel@tonic-gate	nop
5187c478bd9Sstevel@tonic-gate 	lduw	[%l1 + O0_OFF + 4], %o0		! reload 32-bit args
5197c478bd9Sstevel@tonic-gate	lduw	[%l1 + O1_OFF + 4], %o1
5207c478bd9Sstevel@tonic-gate	lduw	[%l1 + O2_OFF + 4], %o2
5217c478bd9Sstevel@tonic-gate	lduw	[%l1 + O3_OFF + 4], %o3
5227c478bd9Sstevel@tonic-gate	lduw	[%l1 + O4_OFF + 4], %o4
5237c478bd9Sstevel@tonic-gate	ba,pt	%xcc, 3b
5247c478bd9Sstevel@tonic-gate	lduw	[%l1 + O5_OFF + 4], %o5
5257c478bd9Sstevel@tonic-gate
5267c478bd9Sstevel@tonic-gate	!
5277c478bd9Sstevel@tonic-gate	! Floating-point trap was pending at start of system call.
5287c478bd9Sstevel@tonic-gate	! Here with:
5297c478bd9Sstevel@tonic-gate	!	%l3 = mpcb_flags
5307c478bd9Sstevel@tonic-gate	!
5317c478bd9Sstevel@tonic-gate_syscall_fp32:
5327c478bd9Sstevel@tonic-gate	andn	%l3, FP_TRAPPED, %l3
5337c478bd9Sstevel@tonic-gate	st	%l3, [%sp + STACK_BIAS + MPCB_FLAGS] 	! clear FP_TRAPPED
5347c478bd9Sstevel@tonic-gate	jmp	%l0 + 8				! return to user_rtt
5357c478bd9Sstevel@tonic-gate	clrh	[THREAD_REG + T_SYSNUM]		! clear syscall code
5367c478bd9Sstevel@tonic-gate
5377c478bd9Sstevel@tonic-gate	!
5387c478bd9Sstevel@tonic-gate	! illegal system call - syscall number out of range
5397c478bd9Sstevel@tonic-gate	!
5407c478bd9Sstevel@tonic-gate_syscall_ill32:
5417c478bd9Sstevel@tonic-gate	call	nosys
5427c478bd9Sstevel@tonic-gate	nop
5437c478bd9Sstevel@tonic-gate	!
5447c478bd9Sstevel@tonic-gate	! Post-syscall with special processing needed.
5457c478bd9Sstevel@tonic-gate	!
5467c478bd9Sstevel@tonic-gate_syscall_post32:
5477c478bd9Sstevel@tonic-gate	call	post_syscall			! post_syscall(rvals)
5487c478bd9Sstevel@tonic-gate	nop
5497c478bd9Sstevel@tonic-gate	jmp	%l0 + 8				! return to user_rtt
5507c478bd9Sstevel@tonic-gate	nop
5517c478bd9Sstevel@tonic-gate	SET_SIZE(syscall_trap32)
5527c478bd9Sstevel@tonic-gate
5537c478bd9Sstevel@tonic-gate#endif /* lint */
5547c478bd9Sstevel@tonic-gate
5557c478bd9Sstevel@tonic-gate
5567c478bd9Sstevel@tonic-gate/*
5577c478bd9Sstevel@tonic-gate * lwp_rtt - start execution in newly created LWP.
5587c478bd9Sstevel@tonic-gate *	Here with t_post_sys set by lwp_create, and lwp_eosys == JUSTRETURN,
5597c478bd9Sstevel@tonic-gate *	so that post_syscall() will run and the registers will
5607c478bd9Sstevel@tonic-gate *	simply be restored.
5617c478bd9Sstevel@tonic-gate *	This must go out through sys_rtt instead of syscall_rtt.
5627c478bd9Sstevel@tonic-gate */
5637c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
5647c478bd9Sstevel@tonic-gate
5657c478bd9Sstevel@tonic-gatevoid
5667c478bd9Sstevel@tonic-gatelwp_rtt_initial(void)
5677c478bd9Sstevel@tonic-gate{}
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gatevoid
5707c478bd9Sstevel@tonic-gatelwp_rtt(void)
5717c478bd9Sstevel@tonic-gate{}
5727c478bd9Sstevel@tonic-gate
5737c478bd9Sstevel@tonic-gate#else	/* lint */
5747c478bd9Sstevel@tonic-gate	ENTRY_NP(lwp_rtt_initial)
5757c478bd9Sstevel@tonic-gate	ldn	[THREAD_REG + T_STACK], %l7
5767c478bd9Sstevel@tonic-gate	call	__dtrace_probe___proc_start
5777c478bd9Sstevel@tonic-gate	sub	%l7, STACK_BIAS, %sp
578c4978b50Sraf	ba,a,pt	%xcc, 0f
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate	ENTRY_NP(lwp_rtt)
5817c478bd9Sstevel@tonic-gate	ldn	[THREAD_REG + T_STACK], %l7
5827c478bd9Sstevel@tonic-gate	sub	%l7, STACK_BIAS, %sp
5837c478bd9Sstevel@tonic-gate0:
5847c478bd9Sstevel@tonic-gate	call	__dtrace_probe___proc_lwp__start
5857c478bd9Sstevel@tonic-gate	nop
5867c478bd9Sstevel@tonic-gate	call	dtrace_systrace_rtt
5877c478bd9Sstevel@tonic-gate	add	%sp, REGOFF + STACK_BIAS, %l7
5887c478bd9Sstevel@tonic-gate	ldx	[%l7 + O0_OFF], %o0
5897c478bd9Sstevel@tonic-gate	call	post_syscall
5907c478bd9Sstevel@tonic-gate	ldx	[%l7 + O1_OFF], %o1
5917c478bd9Sstevel@tonic-gate	ba,a,pt	%xcc, user_rtt
5927c478bd9Sstevel@tonic-gate	SET_SIZE(lwp_rtt)
593c4978b50Sraf	SET_SIZE(lwp_rtt_initial)
5947c478bd9Sstevel@tonic-gate
5957c478bd9Sstevel@tonic-gate#endif	/* lint */
596