Linux 2.6.39-rc2
[pohmelfs.git] / arch / um / sys-i386 / shared / sysdep / stub.h
blob977dedd9221bf44cd97a0611febb727486f823a3
1 /*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
9 #include <sys/mman.h>
10 #include <asm/ptrace.h>
11 #include <asm/unistd.h>
12 #include "as-layout.h"
13 #include "stub-data.h"
14 #include "kern_constants.h"
16 extern void stub_segv_handler(int sig);
17 extern void stub_clone_handler(void);
19 #define STUB_SYSCALL_RET EAX
20 #define STUB_MMAP_NR __NR_mmap2
21 #define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT)
23 static inline long stub_syscall0(long syscall)
25 long ret;
27 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
29 return ret;
32 static inline long stub_syscall1(long syscall, long arg1)
34 long ret;
36 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
38 return ret;
41 static inline long stub_syscall2(long syscall, long arg1, long arg2)
43 long ret;
45 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
46 "c" (arg2));
48 return ret;
51 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
53 long ret;
55 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
56 "c" (arg2), "d" (arg3));
58 return ret;
61 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
62 long arg4)
64 long ret;
66 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
67 "c" (arg2), "d" (arg3), "S" (arg4));
69 return ret;
72 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
73 long arg4, long arg5)
75 long ret;
77 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
78 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
80 return ret;
83 static inline void trap_myself(void)
85 __asm("int3");
88 static inline void remap_stack(int fd, unsigned long offset)
90 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
91 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
92 : : "g" (STUB_MMAP_NR), "b" (STUB_DATA),
93 "c" (UM_KERN_PAGE_SIZE),
94 "d" (PROT_READ | PROT_WRITE),
95 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
96 "a" (offset),
97 "i" (&((struct stub_data *) STUB_DATA)->err)
98 : "memory");
101 #endif