xref: /netbsd-src/lib/libc/arch/or1k/SYS.h (revision abb9139a12332a650defb77c70c46ae7afbc0f2c)
1*abb9139aSmatt /*	$NetBSD: SYS.h,v 1.2 2014/09/05 18:09:37 matt Exp $	*/
2*abb9139aSmatt 
3*abb9139aSmatt /*-
4*abb9139aSmatt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
5*abb9139aSmatt  * All rights reserved.
6*abb9139aSmatt  *
7*abb9139aSmatt  * This code is derived from software contributed to The NetBSD Foundation
8*abb9139aSmatt  * by Matt Thomas of 3am Software Foundry.
9*abb9139aSmatt  *
10*abb9139aSmatt  * Redistribution and use in source and binary forms, with or without
11*abb9139aSmatt  * modification, are permitted provided that the following conditions
12*abb9139aSmatt  * are met:
13*abb9139aSmatt  * 1. Redistributions of source code must retain the above copyright
14*abb9139aSmatt  *    notice, this list of conditions and the following disclaimer.
15*abb9139aSmatt  * 2. Redistributions in binary form must reproduce the above copyright
16*abb9139aSmatt  *    notice, this list of conditions and the following disclaimer in the
17*abb9139aSmatt  *    documentation and/or other materials provided with the distribution.
18*abb9139aSmatt  *
19*abb9139aSmatt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*abb9139aSmatt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*abb9139aSmatt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*abb9139aSmatt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*abb9139aSmatt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*abb9139aSmatt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*abb9139aSmatt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*abb9139aSmatt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*abb9139aSmatt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*abb9139aSmatt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*abb9139aSmatt  * POSSIBILITY OF SUCH DAMAGE.
30*abb9139aSmatt  */
3127620987Smatt 
3227620987Smatt #include <machine/asm.h>
3327620987Smatt #include <sys/syscall.h>
34*abb9139aSmatt #include "sysassym.h"
3527620987Smatt 
3627620987Smatt #define	_DOSYSCALL(x)		l.addi	r13,r0,(SYS_ ## x)	;\
3727620987Smatt 				l.sys	0			;\
3827620987Smatt 				l.nop
3927620987Smatt 
40*abb9139aSmatt #define	_SYSCALL_NOERROR(x,y)	ENTRY(x)			;\
41*abb9139aSmatt 				.if NSYSARGS_##y > 6		;\
42*abb9139aSmatt 				l.lwz	r11, 0(r1)		;\
43*abb9139aSmatt 				.endif				;\
44*abb9139aSmatt 				.if NSYSARGS_##y > 7		;\
45*abb9139aSmatt 				l.lwz	r12, 4(r1)		;\
46*abb9139aSmatt 				.endif				;\
4727620987Smatt 				_DOSYSCALL(y)
4827620987Smatt 
49*abb9139aSmatt #define _SYSCALL(x,y)		_SYSCALL_NOERROR(x,y)		;\
50*abb9139aSmatt 				l.bf	_C_LABEL(__cerror)	;\
5127620987Smatt 				l.nop
5227620987Smatt 
5327620987Smatt #define SYSCALL_NOERROR(x)	_SYSCALL_NOERROR(x,x)
5427620987Smatt 
5527620987Smatt #define SYSCALL(x)		_SYSCALL(x,x)
5627620987Smatt 
5727620987Smatt #define PSEUDO_NOERROR(x,y)	_SYSCALL_NOERROR(x,y)		;\
5827620987Smatt 				l.jr	lr			;\
5927620987Smatt 				l.nop				;\
6027620987Smatt 				END(x)
6127620987Smatt 
6227620987Smatt #define PSEUDO(x,y)		_SYSCALL_NOERROR(x,y)		;\
6327620987Smatt 				l.bf	_C_LABEL(__cerror)	;\
6427620987Smatt 				l.nop				;\
6527620987Smatt 				l.jr	lr			;\
6627620987Smatt 				l.nop				;\
6727620987Smatt 				END(x)
6827620987Smatt 
6927620987Smatt #define RSYSCALL_NOERROR(x)	PSEUDO_NOERROR(x,x)
7027620987Smatt 
7127620987Smatt #define RSYSCALL(x)		PSEUDO(x,x)
7227620987Smatt 
7327620987Smatt #define	WSYSCALL(weak,strong)	WEAK_ALIAS(weak,strong)		;\
7427620987Smatt 				PSEUDO(strong,weak)
75