2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
9 #include <asm/ptrace.h>
10 #include <generated/asm-offsets.h>
12 #define STUB_MMAP_NR __NR_mmap2
13 #define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT)
15 static inline long stub_syscall0(long syscall)
19 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
24 static inline long stub_syscall1(long syscall, long arg1)
28 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
33 static inline long stub_syscall2(long syscall, long arg1, long arg2)
37 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
43 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
47 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
48 "c" (arg2), "d" (arg3));
53 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
58 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
59 "c" (arg2), "d" (arg3), "S" (arg4));
64 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
69 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
70 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
75 static inline void trap_myself(void)
80 static inline void remap_stack_and_trap(void)
86 "movl %%ebx,%%edi ; addl %2,%%edi ; movl (%%edi),%%edi ;"
87 "movl %%ebx,%%ebp ; addl %3,%%ebp ; movl (%%ebp),%%ebp ;"
89 "addl %4,%%ebx ; movl %%eax, (%%ebx) ;"
92 "g" (~(UM_KERN_PAGE_SIZE - 1)),
94 "g" (UML_STUB_FIELD_FD),
95 "g" (UML_STUB_FIELD_OFFSET),
96 "g" (UML_STUB_FIELD_CHILD_ERR),
97 "c" (UM_KERN_PAGE_SIZE),
98 "d" (PROT_READ | PROT_WRITE),
99 "S" (MAP_FIXED | MAP_SHARED)