SYS.h revision 1.10
1/*	$NetBSD: SYS.h,v 1.10 2020/05/05 06:06:16 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#include <machine/frame.h>
34
35#define	SYSENTRY(x)	LEAF_ENTRY(x)
36#define	SYSEXIT(x)	EXIT(x)
37
38#define	SYSCALL(x)				!\
39	stw	%rp, HPPA_FRAME_ERP(%sr0,%sp)	!\
40	ldil	L%SYSCALLGATE, %r1		!\
41	ble	4(%sr2, %r1)			!\
42	ldi	__CONCAT(SYS_,x), %t1		!\
43	.import __cerror, code			!\
44	comb,<>	%r0, %t1, __cerror		!\
45	ldw	HPPA_FRAME_ERP(%sr0,%sp), %rp
46
47#define	PSEUDO(x,y)				!\
48SYSENTRY(x)					!\
49	SYSCALL(y)				!\
50	bv	%r0(%rp)			!\
51	nop					!\
52SYSEXIT(x)
53
54#define	PSEUDO_NOERROR(x,y)			!\
55SYSENTRY(x)					!\
56	stw	%rp, HPPA_FRAME_ERP(%sr0,%sp)	!\
57	ldil	L%SYSCALLGATE, %r1		!\
58	ble	4(%sr2, %r1)			!\
59	ldi	__CONCAT(SYS_,y), %t1		!\
60	ldw	HPPA_FRAME_ERP(%sr0,%sp), %rp	!\
61	bv	%r0(%rp)			!\
62	nop					!\
63SYSEXIT(x)
64
65#define RSYSCALL(x)		PSEUDO(x,x)
66#define	RSYSCALL_NOERROR(x)	PSEUDO_NOERROR(x,x)
67
68#ifdef WEAK_ALIAS
69#define WSYSCALL(weak,strong)		!\
70	WEAK_ALIAS(weak,strong)		!\
71	PSEUDO(strong,weak)
72#else
73#define WSYSCALL(weak,strong)		!\
74	PSEUDO(weak,weak)
75#endif
76