1209878Snwhitehorn/*-
2209878Snwhitehorn * Copyright (c) 2002 Benno Rice.  All rights reserved.
3209878Snwhitehorn * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
4209878Snwhitehorn *
5209878Snwhitehorn * Redistribution and use in source and binary forms, with or without
6209878Snwhitehorn * modification, are permitted provided that the following conditions
7209878Snwhitehorn * are met:
8209878Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9209878Snwhitehorn *    notice, this list of conditions and the following disclaimer.
10209878Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
11209878Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
12209878Snwhitehorn *    documentation and/or other materials provided with the distribution.
13209878Snwhitehorn * 3. Neither the name of the author nor the names of any contributors
14209878Snwhitehorn *    may be used to endorse or promote products derived from this software
15209878Snwhitehorn *    without specific prior written permission.
16209878Snwhitehorn *
17209878Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18209878Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19209878Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20209878Snwhitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21209878Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22209878Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23209878Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24209878Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25209878Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26209878Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27209878Snwhitehorn * SUCH DAMAGE.
28209878Snwhitehorn *
29209878Snwhitehorn *	$NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $
30209878Snwhitehorn * $FreeBSD$
31209878Snwhitehorn */
32209878Snwhitehorn
33209878Snwhitehorn#include <sys/syscall.h>
34209878Snwhitehorn#include <machine/asm.h>
35209878Snwhitehorn
36231044Sandreast#define	_SYSCALL(name)						\
37209878Snwhitehorn	.text;							\
38209878Snwhitehorn	.align 2;						\
39258502Sandreast	li	0,(SYS_##name);					\
40209878Snwhitehorn	sc
41209878Snwhitehorn
42231044Sandreast#define	SYSCALL(name)						\
43209878Snwhitehorn	.text;							\
44209878Snwhitehorn	.align 2;						\
45209878Snwhitehorn2:	mflr	%r0;						\
46209878Snwhitehorn	std	%r0,16(%r1);					\
47209878Snwhitehorn	stdu	%r1,-48(%r1);					\
48218824Snwhitehorn	bl	CNAME(HIDENAME(cerror));			\
49209878Snwhitehorn	nop;							\
50209878Snwhitehorn	addi	%r1,%r1,48;					\
51209878Snwhitehorn	ld	%r0,16(%r1);					\
52209878Snwhitehorn	mtlr	%r0;						\
53209878Snwhitehorn	blr;							\
54258502SandreastENTRY(__sys_##name);						\
55258502Sandreast	WEAK_REFERENCE(__sys_##name, name);			\
56258502Sandreast	WEAK_REFERENCE(__sys_##name, _##name);			\
57258502Sandreast	_SYSCALL(name);						\
58209878Snwhitehorn	bso	2b
59209878Snwhitehorn
60231044Sandreast#define	PSEUDO(name)						\
61209878Snwhitehorn	.text;							\
62209878Snwhitehorn	.align 2;						\
63258502SandreastENTRY(__sys_##name);						\
64258502Sandreast	WEAK_REFERENCE(__sys_##name, _##name);			\
65231044Sandreast	_SYSCALL(name);						\
66209878Snwhitehorn	bnslr;							\
67209878Snwhitehorn	mflr	%r0;						\
68209878Snwhitehorn	std	%r0,16(%r1);					\
69209878Snwhitehorn	stdu	%r1,-48(%r1);					\
70218824Snwhitehorn	bl	CNAME(HIDENAME(cerror));			\
71209878Snwhitehorn	nop;							\
72209878Snwhitehorn	addi	%r1,%r1,48;					\
73209878Snwhitehorn	ld	%r0,16(%r1);					\
74209878Snwhitehorn	mtlr	%r0;						\
75209878Snwhitehorn	blr;
76209878Snwhitehorn
77231044Sandreast#define	RSYSCALL(name)						\
78209878Snwhitehorn	.text;							\
79209878Snwhitehorn	.align 2;						\
80258502SandreastENTRY(__sys_##name);						\
81258502Sandreast	WEAK_REFERENCE(__sys_##name, name);			\
82258502Sandreast	WEAK_REFERENCE(__sys_##name, _##name);			\
83231044Sandreast	_SYSCALL(name);						\
84209878Snwhitehorn	bnslr;							\
85209878Snwhitehorn								\
86209878Snwhitehorn	mflr	%r0;						\
87209878Snwhitehorn	std	%r0,16(%r1);					\
88209878Snwhitehorn	stdu	%r1,-48(%r1);					\
89218824Snwhitehorn	bl	CNAME(HIDENAME(cerror));			\
90209878Snwhitehorn	nop;							\
91209878Snwhitehorn	addi	%r1,%r1,48;					\
92209878Snwhitehorn	ld	%r0,16(%r1);					\
93209878Snwhitehorn	mtlr	%r0;						\
94209878Snwhitehorn	blr;
95