]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/um/include/sysdep-x86_64/stub.h
Merge branch 'master'
[linux-2.6-omap-h63xx.git] / arch / um / include / sysdep-x86_64 / stub.h
1 /*
2  * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
8
9 #include <asm/ptrace.h>
10 #include <asm/unistd.h>
11 #include <sysdep/ptrace_user.h>
12
13 extern void stub_segv_handler(int sig);
14 extern void stub_clone_handler(void);
15
16 #define STUB_SYSCALL_RET PT_INDEX(RAX)
17 #define STUB_MMAP_NR __NR_mmap
18 #define MMAP_OFFSET(o) (o)
19
20 #define __syscall_clobber "r11","rcx","memory"
21 #define __syscall "syscall"
22
23 static inline long stub_syscall2(long syscall, long arg1, long arg2)
24 {
25         long ret;
26
27         __asm__ volatile (__syscall
28                 : "=a" (ret)
29                 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
30
31         return ret;
32 }
33
34 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
35 {
36         long ret;
37
38         __asm__ volatile (__syscall
39                 : "=a" (ret)
40                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
41                 : __syscall_clobber );
42
43         return ret;
44 }
45
46 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
47                                  long arg4)
48 {
49         long ret;
50
51         __asm__ volatile ("movq %5,%%r10 ; " __syscall
52                 : "=a" (ret)
53                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
54                   "g" (arg4)
55                 : __syscall_clobber, "r10" );
56
57         return ret;
58 }
59
60 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
61                                  long arg4, long arg5)
62 {
63         long ret;
64
65         __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
66                 : "=a" (ret)
67                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
68                   "g" (arg4), "g" (arg5)
69                 : __syscall_clobber, "r10", "r8" );
70
71         return ret;
72 }
73
74 static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
75                                  long arg4, long arg5, long arg6)
76 {
77         long ret;
78
79         __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
80                 "movq %7, %%r9; " __syscall : "=a" (ret)
81                 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
82                   "g" (arg4), "g" (arg5), "g" (arg6)
83                 : __syscall_clobber, "r10", "r8", "r9" );
84
85         return ret;
86 }
87
88 static inline void trap_myself(void)
89 {
90         __asm("int3");
91 }
92
93 #endif