/*	Copyright (c) 1984 AT&T	*/
/*	All Rights Reserved	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any	*/
/*	actual or intended publication of such source code.	*/

#ident "$Header: sys.i386 1.4 88/04/29 $@(#)sys.i386	1.0"

#include <syscall.h>

/*
 *	Include file for assembler system call libraries.
 */
#define	R0	%eax
#define	R1	%ecx
#define	R2	%edx

#define	SPARG0	4(%esp)
#define	SPARG1	8(%esp)
#define	SPARG2	12(%esp)
#define	SPARG3	16(%esp)
#define	SPARG4	20(%esp)
#define	SPARG5	24(%esp)
#define	SPARG6	28(%esp)
#define	SPARG7	32(%esp)

/*
 * BASE_SVC_INT must match 1st interrupt number used in kernel (see
 * machine/trap.h).
 */

/*#include <machine/trap.h>	/* XXX */
#define	BASE_SVC_INT	/*T_SVC0*/ 40


/*
 * In the following, parameter 'a' to a macro means "number of arguments
 * to syscall", 's' means "name of syscall", and 'p' means "name of
 * pseudo syscall".
 */

#ifdef	MCOUNT
#define	ENTRY(s)	.text; .align 4; .globl s; s:;	\
			.data; .align 4; .__LINE__: .long 0; \
			.text; movl $.__LINE__, R2;	\
			 call _mcount
#else
#define	ENTRY(s) 	.text;	.globl s; .align 4; s:
#endif

#define	SYSCALL(a,s)	ENTRY(s); SVC/**/a(s); jc _cerror
#define	PSEUDO(s,p)	ENTRY(s); SVC0(p)
#define	PSEUDO1(s,p)	ENTRY(s); SVC1(p)

#define	SVC0(s)		SVC(0,s)
#define	SVC1(s)		movl SPARG0,R1; SVC(1,s)
#define	SVC2(s)		movl SPARG0,R1; movl SPARG1,R2; SVC(2,s)
#define	SVC3(s)		leal SPARG0,R1; SVC(3,s)
#define	SVC4(s)		leal SPARG0,R1; SVC(4,s)
#define	SVC5(s)		leal SPARG0,R1; SVC(5,s)
#define	SVC6(s)		leal SPARG0,R1; SVC(6,s)

#define	SVC(n,s)    movl $[SYS_/**/s|[SYS_TYP<<16]], R0; int $BASE_SVC_INT+n
