SYS.h revision 1.4
11.4Smatt/*	$NetBSD: SYS.h,v 1.4 2003/10/06 05:30:21 matt Exp $	*/
21.1Sfredette
31.1Sfredette/*	$OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $	*/
41.1Sfredette
51.1Sfredette/*
61.1Sfredette * Copyright (c) 1998-1999 Michael Shalayeff
71.1Sfredette * All rights reserved.
81.1Sfredette *
91.1Sfredette * Redistribution and use in source and binary forms, with or without
101.1Sfredette * modification, are permitted provided that the following conditions
111.1Sfredette * are met:
121.1Sfredette * 1. Redistributions of source code must retain the above copyright
131.1Sfredette *    notice, this list of conditions and the following disclaimer.
141.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright
151.1Sfredette *    notice, this list of conditions and the following disclaimer in the
161.1Sfredette *    documentation and/or other materials provided with the distribution.
171.1Sfredette * 3. All advertising materials mentioning features or use of this software
181.1Sfredette *    must display the following acknowledgement:
191.1Sfredette *	This product includes software developed by Michael Shalayeff.
201.1Sfredette * 4. The name of the author may not be used to endorse or promote products
211.1Sfredette *    derived from this software without specific prior written permission.
221.1Sfredette *
231.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
241.1Sfredette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
251.1Sfredette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
261.1Sfredette * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
271.1Sfredette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
281.1Sfredette * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND
291.1Sfredette * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
301.1Sfredette * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
311.1Sfredette * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
321.1Sfredette * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
331.1Sfredette */
341.1Sfredette
351.1Sfredette#include <sys/syscall.h>
361.1Sfredette#include <machine/asm.h>
371.1Sfredette#include <machine/vmparam.h>
381.1Sfredette#undef _LOCORE
391.1Sfredette#define _LOCORE
401.1Sfredette#include <machine/frame.h>
411.1Sfredette
421.1Sfredette#define	__ENTRY(p,x)	ENTRY(__CONCAT(p,x),0)
431.1Sfredette#define	__EXIT(p,x)	EXIT(__CONCAT(p,x))
441.1Sfredette
451.1Sfredette#define	__SYSCALL_NOERROR(p,x)			!\
461.4Smatt	stw	%rp, HPPA_FRAME_ERP(%sr0,%sp)	!\
471.4Smatt	ldil	L%SYSCALLGATE, %r1		!\
481.4Smatt	ble	4(%sr7, %r1)			!\
491.4Smatt	ldi	__CONCAT(SYS_,x), %t1		!\
501.4Smatt	ldw	HPPA_FRAME_ERP(%sr0,%sp), %rp
511.1Sfredette
521.2Sfredette#ifdef PIC
531.2Sfredette#define	__SYSCALL_ERRNO				!\
541.2Sfredette	addil	LT%errno, %r19			!\
551.2Sfredette	ldw	RT%errno(%r1), %r1		!\
561.4Smatt	stw	%t1, 0(%r1)
571.2Sfredette#else
581.2Sfredette#define	__SYSCALL_ERRNO				!\
591.2Sfredette	ldil	L%errno, %r1			!\
601.4Smatt	stw	%t1, R%errno(%r1)
611.2Sfredette#endif
621.2Sfredette
631.1Sfredette#define	__SYSCALL(p,x)				!\
641.1Sfredette	.import	errno, data			!\
651.1Sfredette	__SYSCALL_NOERROR(p,x)			!\
661.4Smatt	comb,=,n %r0, %t1, __CONCAT(x,$noerr)	!\
671.2Sfredette	__SYSCALL_ERRNO				!\
681.4Smatt	ldi	-1, %ret0			!\
691.4Smatt	bv	%r0(%rp)				!\
701.4Smatt	ldi	-1, %ret1			!\
711.1Sfredette	.label	__CONCAT(x,$noerr)
721.1Sfredette
731.1Sfredette#define	__RSYSCALL(p,x)			!\
741.1Sfredette__ENTRY(p,x)				!\
751.1Sfredette	__SYSCALL(p,x)			!\
761.4Smatt	bv	%r0(%rp)			!\
771.1Sfredette	nop				!\
781.1Sfredette__EXIT(p,x)
791.1Sfredette
801.1Sfredette#define	__RSYSCALL_NOERROR(p,x)		!\
811.1Sfredette__ENTRY(p,x)				!\
821.1Sfredette	__SYSCALL_NOERROR(p,x)		!\
831.4Smatt	bv	%r0(%rp)		!\
841.1Sfredette	nop				!\
851.1Sfredette__EXIT(p,x)
861.1Sfredette
871.1Sfredette#define	__PSEUDO(p,x,y)			!\
881.1Sfredette__ENTRY(p,x)				!\
891.1Sfredette	__SYSCALL(p,y)			!\
901.4Smatt	bv	%r0(%rp)		!\
911.1Sfredette	nop				!\
921.1Sfredette__EXIT(p,x)
931.1Sfredette
941.1Sfredette#define	__PSEUDO_NOERROR(p,x,y)		!\
951.1Sfredette__ENTRY(p,x)				!\
961.1Sfredette	__SYSCALL_NOERROR(p,y)		!\
971.4Smatt	bv	%r0(%rp)		!\
981.1Sfredette	nop				!\
991.1Sfredette__EXIT(p,x)
1001.1Sfredette
1011.1Sfredette#ifdef WEAK_ALIAS
1021.1Sfredette#define WSYSCALL(weak,strong)		!\
1031.1Sfredette	WEAK_ALIAS(weak,strong)		!\
1041.1Sfredette	PSEUDO(strong,weak)
1051.1Sfredette#else
1061.1Sfredette#define WSYSCALL(weak,strong)		!\
1071.1Sfredette	PSEUDO(weak,weak)
1081.1Sfredette#endif
1091.1Sfredette
1101.3Sthorpej#define SYSCALL(x)		__SYSCALL(,x)
1111.3Sthorpej#define RSYSCALL(x)		__RSYSCALL(,x)
1121.3Sthorpej#define RSYSCALL_NOERROR(x)	__RSYSCALL_NOERROR(,x)
1131.3Sthorpej#define PSEUDO(x,y)		__PSEUDO(,x,y)
1141.3Sthorpej#define PSEUDO_NOERROR(x,y)	__PSEUDO_NOERROR(,x,y)
1151.3Sthorpej/*#define SYSENTRY(x)		__ENTRY(,x)*/
116