Xenomai
3.1.2
syscall.h
1
/*
2
* Copyright (C) 2015 Philippe Gerum <rpm@xenomai.org>.
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17
*/
18
#ifndef _LIB_COBALT_ARM64_SYSCALL_H
19
#define _LIB_COBALT_ARM64_SYSCALL_H
20
21
#include <xeno_config.h>
22
#include <errno.h>
23
#include <cobalt/uapi/syscall.h>
24
25
#define __emit_asmdecl0 \
26
register unsigned int __scno __asm__ ("w8"
); \
27
register unsigned long __res __asm__ ("x0")
28
#define __emit_asmdecl1 \
29
__emit_asmdecl0; register unsigned long __x0 __asm__ ("x0"
)
30
#define __emit_asmdecl2 \
31
__emit_asmdecl1; register unsigned long __x1 __asm__ ("x1"
)
32
#define __emit_asmdecl3 \
33
__emit_asmdecl2; register unsigned long __x2 __asm__ ("x2"
)
34
#define __emit_asmdecl4 \
35
__emit_asmdecl3; register unsigned long __x3 __asm__ ("x3"
)
36
#define __emit_asmdecl5 \
37
__emit_asmdecl4; register unsigned long __x4 __asm__ ("x4"
)
38
39
#define __load_asminput0(__op) \
40
__scno = (unsigned int)__xn_syscode(__op)
41
#define __load_asminput1(__op, __a1) \
42
__load_asminput0(__op); \
43
__x0 = (unsigned long)(__a1)
44
#define __load_asminput2(__op, __a1, __a2) \
45
__load_asminput1(__op, __a1); \
46
__x1 = (unsigned long)(__a2)
47
#define __load_asminput3(__op, __a1, __a2, __a3) \
48
__load_asminput2(__op, __a1, __a2); \
49
__x2 = (unsigned long)(__a3)
50
#define __load_asminput4(__op, __a1, __a2, __a3, __a4) \
51
__load_asminput3(__op, __a1, __a2, __a3); \
52
__x3 = (unsigned long)(__a4)
53
#define __load_asminput5(__op, __a1, __a2, __a3, __a4, __a5) \
54
__load_asminput4(__op, __a1, __a2, __a3, __a4); \
55
__x4 = (unsigned long)(__a5)
56
57
#define __emit_syscall0(__args...) \
58
__asm__ __volatile__ ( \
59
"svc 0;\n\t"
\
60
: "=r" (__res) \
61
: "r" (__scno), ##__args \
62
: "cc", "memory"); \
63
__res
64
#define __emit_syscall1(__a1, __args...) \
65
__emit_syscall0("r"
(__x0), ##__args)
66
#define __emit_syscall2(__a1, __a2, __args...) \
67
__emit_syscall1(__a1, "r"
(__x1), ##__args)
68
#define __emit_syscall3(__a1, __a2, __a3, __args...) \
69
__emit_syscall2(__a1, __a2, "r"
(__x2), ##__args)
70
#define __emit_syscall4(__a1, __a2, __a3, __a4, __args...) \
71
__emit_syscall3(__a1, __a2, __a3, "r"
(__x3), ##__args)
72
#define __emit_syscall5(__a1, __a2, __a3, __a4, __a5, __args...) \
73
__emit_syscall4(__a1, __a2, __a3, __a4, "r"
(__x4), ##__args)
74
75
#define XENOMAI_DO_SYSCALL(__argnr, __op, __args...) \
76
({ \
77
__emit_asmdecl##__argnr; \
78
__load_asminput##__argnr(__op, ##__args); \
79
__emit_syscall##__argnr(__args); \
80
})
81
82
#define XENOMAI_SYSCALL0(__op) \
83
XENOMAI_DO_SYSCALL(0, __op)
84
#define XENOMAI_SYSCALL1(__op, __a1) \
85
XENOMAI_DO_SYSCALL(1, __op, __a1)
86
#define XENOMAI_SYSCALL2(__op, __a1, __a2) \
87
XENOMAI_DO_SYSCALL(2, __op, __a1, __a2)
88
#define XENOMAI_SYSCALL3(__op, __a1, __a2, __a3) \
89
XENOMAI_DO_SYSCALL(3, __op, __a1, __a2, __a3)
90
#define XENOMAI_SYSCALL4(__op, __a1, __a2, __a3, __a4) \
91
XENOMAI_DO_SYSCALL(4, __op, __a1, __a2, __a3, __a4)
92
#define XENOMAI_SYSCALL5(__op, __a1, __a2, __a3, __a4, __a5) \
93
XENOMAI_DO_SYSCALL(5, __op, __a1, __a2, __a3, __a4, __a5)
94
#define XENOMAI_SYSBIND(__breq) \
95
XENOMAI_DO_SYSCALL(1, sc_cobalt_bind, __breq)
96
97
#endif
/* !_LIB_COBALT_ARM64_SYSCALL_H */
lib
cobalt
arch
arm64
include
asm
xenomai
syscall.h
Generated by
1.9.1