xref: /openbsd-src/lib/libc/arch/arm/SYS.h (revision 83762a71f74848f4d09174ce350838b4204957c5)
1*83762a71Sderaadt /*	$OpenBSD: SYS.h,v 1.20 2023/12/10 16:45:51 deraadt Exp $	*/
2d987040fSdrahn /*	$NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $	*/
3d987040fSdrahn 
4d987040fSdrahn /*-
5d987040fSdrahn  * Copyright (c) 1990 The Regents of the University of California.
6d987040fSdrahn  * All rights reserved.
7d987040fSdrahn  *
8d987040fSdrahn  * This code is derived from software contributed to Berkeley by
9d987040fSdrahn  * William Jolitz.
10d987040fSdrahn  *
11d987040fSdrahn  * Redistribution and use in source and binary forms, with or without
12d987040fSdrahn  * modification, are permitted provided that the following conditions
13d987040fSdrahn  * are met:
14d987040fSdrahn  * 1. Redistributions of source code must retain the above copyright
15d987040fSdrahn  *    notice, this list of conditions and the following disclaimer.
16d987040fSdrahn  * 2. Redistributions in binary form must reproduce the above copyright
17d987040fSdrahn  *    notice, this list of conditions and the following disclaimer in the
18d987040fSdrahn  *    documentation and/or other materials provided with the distribution.
19d987040fSdrahn  * 3. Neither the name of the University nor the names of its contributors
20d987040fSdrahn  *    may be used to endorse or promote products derived from this software
21d987040fSdrahn  *    without specific prior written permission.
22d987040fSdrahn  *
23d987040fSdrahn  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24d987040fSdrahn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25d987040fSdrahn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26d987040fSdrahn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27d987040fSdrahn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28d987040fSdrahn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29d987040fSdrahn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30d987040fSdrahn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31d987040fSdrahn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32d987040fSdrahn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33d987040fSdrahn  * SUCH DAMAGE.
34d987040fSdrahn  *
35d987040fSdrahn  *	from: @(#)SYS.h	5.5 (Berkeley) 5/7/91
36d987040fSdrahn  */
37d987040fSdrahn 
3838848718Sguenther #include "DEFS.h"
39d987040fSdrahn #include <sys/syscall.h>
40d987040fSdrahn 
419b9d2a55Sguenther 
42d987040fSdrahn #define SYSENTRY(x)					\
4381621933Sguenther 	.weak x;					\
4481621933Sguenther 	x = _thread_sys_ ## x;				\
45d987040fSdrahn 	ENTRY(_thread_sys_ ## x)
46514a545fSguenther #define SYSENTRY_HIDDEN(x)				\
47514a545fSguenther 	ENTRY(_thread_sys_ ## x)
483f373d41Sguenther #define __END_HIDDEN(x)					\
493f373d41Sguenther 	END(_thread_sys_ ## x);				\
503f373d41Sguenther 	_HIDDEN_FALIAS(x, _thread_sys_ ## x);		\
513f373d41Sguenther 	END(_HIDDEN(x))
523f373d41Sguenther #define __END(x)					\
533f373d41Sguenther 	__END_HIDDEN(x); END(x)
54d987040fSdrahn 
55a54774d4Sdrahn #define SYSTRAP(x) \
56853a72c4Sdrahn 	ldr	r12, =SYS_ ## x;			\
57*83762a71Sderaadt 97:	swi	0;					\
58*83762a71Sderaadt 	PINSYSCALL(SYS_ ## x, 97b);			\
59f74a2b77Sderaadt 	dsb	nsh;					\
60f74a2b77Sderaadt 	isb
61a54774d4Sdrahn 
6281621933Sguenther #define	CERROR		__cerror
63a54774d4Sdrahn 
64a54774d4Sdrahn #define _SYSCALL_NOERROR(x,y)						\
65a54774d4Sdrahn 	SYSENTRY(x);							\
66a54774d4Sdrahn 	SYSTRAP(y)
67514a545fSguenther #define _SYSCALL_HIDDEN_NOERROR(x,y)					\
68514a545fSguenther 	SYSENTRY_HIDDEN(x);						\
69514a545fSguenther 	SYSTRAP(y)
70d987040fSdrahn 
71d987040fSdrahn #define _SYSCALL(x, y)							\
72d987040fSdrahn 	_SYSCALL_NOERROR(x,y);						\
7338848718Sguenther 	bcs CERROR
74514a545fSguenther #define _SYSCALL_HIDDEN(x, y)						\
75514a545fSguenther 	_SYSCALL_HIDDEN_NOERROR(x,y);					\
7638848718Sguenther 	bcs CERROR
77d987040fSdrahn 
78d987040fSdrahn #define SYSCALL_NOERROR(x)						\
79d987040fSdrahn 	_SYSCALL_NOERROR(x,x)
80d987040fSdrahn 
81d987040fSdrahn #define SYSCALL(x)							\
82d987040fSdrahn 	_SYSCALL(x,x)
83d987040fSdrahn 
84d987040fSdrahn 
85d987040fSdrahn #define PSEUDO_NOERROR(x,y)						\
86d987040fSdrahn 	_SYSCALL_NOERROR(x,y);						\
873f373d41Sguenther 	mov r15, r14;							\
883f373d41Sguenther 	__END(x)
89d987040fSdrahn 
90d987040fSdrahn #define PSEUDO(x,y)							\
91d987040fSdrahn 	_SYSCALL(x,y);							\
923f373d41Sguenther 	mov r15, r14;							\
933f373d41Sguenther 	__END(x)
94514a545fSguenther #define PSEUDO_HIDDEN(x,y)						\
95514a545fSguenther 	_SYSCALL_HIDDEN(x,y);						\
963f373d41Sguenther 	mov r15, r14;							\
973f373d41Sguenther 	__END_HIDDEN(x)
98d987040fSdrahn 
99d987040fSdrahn 
100d987040fSdrahn #define RSYSCALL_NOERROR(x)						\
101d987040fSdrahn 	PSEUDO_NOERROR(x,x)
102d987040fSdrahn 
103d987040fSdrahn #define RSYSCALL(x)							\
104d987040fSdrahn 	PSEUDO(x,x)
105514a545fSguenther #define RSYSCALL_HIDDEN(x)						\
106514a545fSguenther 	PSEUDO_HIDDEN(x,x)
1073f373d41Sguenther #define SYSCALL_END(x)							\
1083f373d41Sguenther 	__END(x)
1095aed4d28Sguenther #define SYSCALL_END_HIDDEN(x)						\
1105aed4d28Sguenther 	__END_HIDDEN(x)
111d987040fSdrahn 
112d987040fSdrahn 	.globl	CERROR
113