blob: a49ceb199ee57e2c5150f93373dc994fe7d00f30 [file] [log] [blame]
Jeff Diked67b5692005-07-07 17:56:49 -07001/*
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
12extern void stub_segv_handler(int sig);
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070013extern void stub_clone_handler(void);
Jeff Diked67b5692005-07-07 17:56:49 -070014
15#define STUB_SYSCALL_RET EAX
16#define STUB_MMAP_NR __NR_mmap2
17#define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
18
Paolo 'Blaisorblade' Giarrusso4f027242005-11-07 00:58:46 -080019static inline long stub_syscall1(long syscall, long arg1)
20{
21 long ret;
22
23 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
24
25 return ret;
26}
27
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070028static inline long stub_syscall2(long syscall, long arg1, long arg2)
29{
30 long ret;
31
Paolo 'Blaisorblade' Giarrusso4f027242005-11-07 00:58:46 -080032 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
33 "c" (arg2));
34
35 return ret;
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070036}
37
38static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
39{
Paolo 'Blaisorblade' Giarrusso4f027242005-11-07 00:58:46 -080040 long ret;
41
42 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
43 "c" (arg2), "d" (arg3));
44
45 return ret;
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070046}
47
48static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
49 long arg4)
50{
Paolo 'Blaisorblade' Giarrusso4f027242005-11-07 00:58:46 -080051 long ret;
52
53 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
54 "c" (arg2), "d" (arg3), "S" (arg4));
55
56 return ret;
57}
58
59static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
60 long arg4, long arg5)
61{
62 long ret;
63
64 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
65 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
66
67 return ret;
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070068}
69
70static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
71 long arg4, long arg5, long arg6)
72{
73 long ret;
Paolo 'Blaisorblade' Giarrusso4f027242005-11-07 00:58:46 -080074
75 __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; "
76 "int $0x80 ; pop %%ebp"
77 : "=a" (ret)
78 : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3),
79 "S" (arg4), "D" (arg5), "0" (arg6));
80
81 return ret;
Bodo Stroesser9786a8f2005-07-07 17:56:50 -070082}
83
84static inline void trap_myself(void)
85{
86 __asm("int3");
87}
88
Jeff Diked67b5692005-07-07 17:56:49 -070089#endif