diff options
Diffstat (limited to 'arch/um/include/sysdep-i386/stub.h')
-rw-r--r-- | arch/um/include/sysdep-i386/stub.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h new file mode 100644 index 000000000000..d3699fe1c613 --- /dev/null +++ b/arch/um/include/sysdep-i386/stub.h | |||
@@ -0,0 +1,65 @@ | |||
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 | |||
12 | extern void stub_segv_handler(int sig); | ||
13 | extern void stub_clone_handler(void); | ||
14 | |||
15 | #define STUB_SYSCALL_RET EAX | ||
16 | #define STUB_MMAP_NR __NR_mmap2 | ||
17 | #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) | ||
18 | |||
19 | static inline long stub_syscall2(long syscall, long arg1, long arg2) | ||
20 | { | ||
21 | long ret; | ||
22 | |||
23 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | ||
24 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | ||
25 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | ||
26 | __asm__("int $0x80;" : : : "%eax"); | ||
27 | __asm__ __volatile__("movl %%eax, %0; " : "=g" (ret) :); | ||
28 | return(ret); | ||
29 | } | ||
30 | |||
31 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) | ||
32 | { | ||
33 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | ||
34 | return(stub_syscall2(syscall, arg1, arg2)); | ||
35 | } | ||
36 | |||
37 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, | ||
38 | long arg4) | ||
39 | { | ||
40 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | ||
41 | return(stub_syscall3(syscall, arg1, arg2, arg3)); | ||
42 | } | ||
43 | |||
44 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, | ||
45 | long arg4, long arg5, long arg6) | ||
46 | { | ||
47 | long ret; | ||
48 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | ||
49 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | ||
50 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | ||
51 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | ||
52 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | ||
53 | __asm__("movl %0, %%edi; " : : "g" (arg5) : "%edi"); | ||
54 | __asm__ __volatile__("pushl %%ebp ; movl %1, %%ebp; " | ||
55 | "int $0x80; popl %%ebp ; " | ||
56 | "movl %%eax, %0; " : "=g" (ret) : "g" (arg6) : "%eax"); | ||
57 | return(ret); | ||
58 | } | ||
59 | |||
60 | static inline void trap_myself(void) | ||
61 | { | ||
62 | __asm("int3"); | ||
63 | } | ||
64 | |||
65 | #endif | ||