backlight: Add driver for Tabletkiosk Sahara TouchIT-213 Tablet PC
[linux-2.6-block.git] / arch / um / include / sysdep-x86_64 / stub.h
CommitLineData
d67b569f
JD
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
5b7b15af 9#include <sys/mman.h>
d67b569f
JD
10#include <asm/unistd.h>
11#include <sysdep/ptrace_user.h>
54ae36f2 12#include "as-layout.h"
5b7b15af
JD
13#include "stub-data.h"
14#include "kern_constants.h"
15#include "uml-config.h"
d67b569f
JD
16
17extern void stub_segv_handler(int sig);
9786a8f3 18extern void stub_clone_handler(void);
d67b569f
JD
19
20#define STUB_SYSCALL_RET PT_INDEX(RAX)
21#define STUB_MMAP_NR __NR_mmap
22#define MMAP_OFFSET(o) (o)
23
4f027241
PBG
24#define __syscall_clobber "r11","rcx","memory"
25#define __syscall "syscall"
26
17d46971
JD
27static inline long stub_syscall0(long syscall)
28{
29 long ret;
30
31 __asm__ volatile (__syscall
32 : "=a" (ret)
33 : "0" (syscall) : __syscall_clobber );
34
35 return ret;
36}
37
9786a8f3
BS
38static inline long stub_syscall2(long syscall, long arg1, long arg2)
39{
40 long ret;
41
4f027241
PBG
42 __asm__ volatile (__syscall
43 : "=a" (ret)
44 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
45
46 return ret;
9786a8f3
BS
47}
48
49static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
50{
4f027241
PBG
51 long ret;
52
53 __asm__ volatile (__syscall
54 : "=a" (ret)
55 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
56 : __syscall_clobber );
57
58 return ret;
9786a8f3
BS
59}
60
61static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
62 long arg4)
63{
4f027241
PBG
64 long ret;
65
66 __asm__ volatile ("movq %5,%%r10 ; " __syscall
67 : "=a" (ret)
68 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
69 "g" (arg4)
70 : __syscall_clobber, "r10" );
71
72 return ret;
73}
74
75static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
76 long arg4, long arg5)
77{
78 long ret;
79
80 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
81 : "=a" (ret)
82 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
83 "g" (arg4), "g" (arg5)
84 : __syscall_clobber, "r10", "r8" );
85
86 return ret;
9786a8f3
BS
87}
88
5b7b15af 89static inline void trap_myself(void)
9786a8f3 90{
5b7b15af 91 __asm("int3");
9786a8f3
BS
92}
93
5b7b15af 94static inline void remap_stack(long fd, unsigned long offset)
9786a8f3 95{
5b7b15af
JD
96 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
97 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
54ae36f2
JD
98 "movq %%rax, (%%rbx)":
99 : "a" (STUB_MMAP_NR), "D" (STUB_DATA),
100 "S" (UM_KERN_PAGE_SIZE),
101 "d" (PROT_READ | PROT_WRITE),
102 "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
5b7b15af 103 "g" (offset),
54ae36f2 104 "i" (&((struct stub_data *) STUB_DATA)->err)
5b7b15af 105 : __syscall_clobber, "r10", "r8", "r9" );
9786a8f3
BS
106}
107
d67b569f 108#endif