1281197Sandrew/*-
2281197Sandrew * Copyright (c) 2014 Andrew Turner
3281197Sandrew * Copyright (c) 2015 The FreeBSD Foundation
4281197Sandrew * All rights reserved.
5281197Sandrew *
6281197Sandrew * This software was developed by Andrew Turner under
7281197Sandrew * sponsorship from the FreeBSD Foundation.
8281197Sandrew *
9281197Sandrew * Redistribution and use in source and binary forms, with or without
10281197Sandrew * modification, are permitted provided that the following conditions
11281197Sandrew * are met:
12281197Sandrew * 1. Redistributions of source code must retain the above copyright
13281197Sandrew *    notice, this list of conditions and the following disclaimer.
14281197Sandrew * 2. Redistributions in binary form must reproduce the above copyright
15281197Sandrew *    notice, this list of conditions and the following disclaimer in the
16281197Sandrew *    documentation and/or other materials provided with the distribution.
17281197Sandrew *
18281197Sandrew * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19281197Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20281197Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21281197Sandrew * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22281197Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23281197Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24281197Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25281197Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26281197Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27281197Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28281197Sandrew * SUCH DAMAGE.
29281197Sandrew *
30281197Sandrew * $FreeBSD$
31281197Sandrew */
32281197Sandrew
33281197Sandrew#include <sys/syscall.h>
34281197Sandrew#include <machine/asm.h>
35281197Sandrew
36281197Sandrew#define	_SYSCALL(name)						\
37281197Sandrew	mov	x8, SYS_ ## name;				\
38281197Sandrew	svc	0
39281197Sandrew
40281197Sandrew#define	SYSCALL(name)						\
41281197SandrewENTRY(__sys_##name);						\
42281197Sandrew	WEAK_REFERENCE(__sys_##name, name);			\
43281197Sandrew	WEAK_REFERENCE(__sys_##name, _##name);			\
44281197Sandrew	_SYSCALL(name);						\
45281197Sandrew	ret;							\
46281197SandrewEND(__sys_##name)
47281197Sandrew
48281197Sandrew#define	PSEUDO(name)						\
49281197SandrewENTRY(__sys_##name);						\
50281197Sandrew	WEAK_REFERENCE(__sys_##name, _##name);			\
51281197Sandrew	_SYSCALL(name);						\
52281197Sandrew	b.cs	cerror;						\
53281197Sandrew	ret;							\
54281197SandrewEND(__sys_##name)
55281197Sandrew
56281197Sandrew#define	RSYSCALL(name)						\
57281197SandrewENTRY(__sys_##name);						\
58281197Sandrew	WEAK_REFERENCE(__sys_##name, name);			\
59281197Sandrew	WEAK_REFERENCE(__sys_##name, _##name);			\
60281197Sandrew	_SYSCALL(name);						\
61281197Sandrew	b.cs	cerror;						\
62281197Sandrew	ret;							\
63281197SandrewEND(__sys_##name)
64