SYS.h revision 1.9
1/*	$NetBSD: SYS.h,v 1.9 2014/03/06 19:02:58 skrll Exp $	*/
2
3/*	$OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $	*/
4
5/*
6 * Copyright (c) 1998-2002 Michael Shalayeff
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/syscall.h>
31#include <machine/asm.h>
32#include <machine/vmparam.h>
33#undef _LOCORE
34#define _LOCORE
35#include <machine/frame.h>
36
37#define	SYSENTRY(x)	LEAF_ENTRY(x)
38#define	SYSEXIT(x)	EXIT(x)
39
40#define	SYSCALL(x)				!\
41	stw	%rp, HPPA_FRAME_ERP(%sr0,%sp)	!\
42	ldil	L%SYSCALLGATE, %r1		!\
43	ble	4(%sr2, %r1)			!\
44	ldi	__CONCAT(SYS_,x), %t1		!\
45	.import __cerror, code			!\
46	comb,<>	%r0, %t1, __cerror		!\
47	ldw	HPPA_FRAME_ERP(%sr0,%sp), %rp
48
49#define	PSEUDO(x,y)				!\
50SYSENTRY(x)					!\
51	SYSCALL(y)				!\
52	bv	%r0(%rp)			!\
53	nop					!\
54SYSEXIT(x)
55
56#define	PSEUDO_NOERROR(x,y)			!\
57SYSENTRY(x)					!\
58	stw	%rp, HPPA_FRAME_ERP(%sr0,%sp)	!\
59	ldil	L%SYSCALLGATE, %r1		!\
60	ble	4(%sr2, %r1)			!\
61	ldi	__CONCAT(SYS_,y), %t1		!\
62	ldw	HPPA_FRAME_ERP(%sr0,%sp), %rp	!\
63	bv	%r0(%rp)			!\
64	nop					!\
65SYSEXIT(x)
66
67#define RSYSCALL(x)		PSEUDO(x,x)
68#define	RSYSCALL_NOERROR(x)	PSEUDO_NOERROR(x,x)
69
70#ifdef WEAK_ALIAS
71#define WSYSCALL(weak,strong)		!\
72	WEAK_ALIAS(weak,strong)		!\
73	PSEUDO(strong,weak)
74#else
75#define WSYSCALL(weak,strong)		!\
76	PSEUDO(weak,weak)
77#endif
78