aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include/sysdep-i386
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/include/sysdep-i386
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/um/include/sysdep-i386')
-rw-r--r--arch/um/include/sysdep-i386/checksum.h219
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h241
-rw-r--r--arch/um/include/sysdep-i386/ptrace_user.h62
-rw-r--r--arch/um/include/sysdep-i386/sigcontext.h49
-rw-r--r--arch/um/include/sysdep-i386/signal.h25
-rw-r--r--arch/um/include/sysdep-i386/syscalls.h123
6 files changed, 719 insertions, 0 deletions
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h
new file mode 100644
index 000000000000..3a2a45811aa3
--- /dev/null
+++ b/arch/um/include/sysdep-i386/checksum.h
@@ -0,0 +1,219 @@
1/*
2 * Licensed under the GPL
3 */
4
5#ifndef __UM_SYSDEP_CHECKSUM_H
6#define __UM_SYSDEP_CHECKSUM_H
7
8#include "linux/in6.h"
9#include "linux/string.h"
10
11/*
12 * computes the checksum of a memory block at buff, length len,
13 * and adds in "sum" (32-bit)
14 *
15 * returns a 32-bit number suitable for feeding into itself
16 * or csum_tcpudp_magic
17 *
18 * this function must be called with even lengths, except
19 * for the last fragment, which may be odd
20 *
21 * it's best to have buff aligned on a 32-bit boundary
22 */
23unsigned int csum_partial(const unsigned char * buff, int len,
24 unsigned int sum);
25
26/*
27 * the same as csum_partial, but copies from src while it
28 * checksums, and handles user-space pointer exceptions correctly, when needed.
29 *
30 * here even more important to align src and dst on a 32-bit (or even
31 * better 64-bit) boundary
32 */
33
34unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst,
35 int len, int sum, int *err_ptr);
36unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst,
37 int len, int sum, int *err_ptr);
38
39/*
40 * Note: when you get a NULL pointer exception here this means someone
41 * passed in an incorrect kernel address to one of these functions.
42 *
43 * If you use these functions directly please don't forget the
44 * access_ok().
45 */
46
47static __inline__
48unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst,
49 int len, int sum)
50{
51 memcpy(dst, src, len);
52 return(csum_partial(dst, len, sum));
53}
54
55static __inline__
56unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
57 int len, int sum, int *err_ptr)
58{
59 return csum_partial_copy_from(src, dst, len, sum, err_ptr);
60}
61
62/*
63 * These are the old (and unsafe) way of doing checksums, a warning message
64 * will be printed if they are used and an exception occurs.
65 *
66 * these functions should go away after some time.
67 */
68
69#define csum_partial_copy_fromuser csum_partial_copy_from_user
70unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);
71
72/*
73 * This is a version of ip_compute_csum() optimized for IP headers,
74 * which always checksum on 4 octet boundaries.
75 *
76 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
77 * Arnt Gulbrandsen.
78 */
79static inline unsigned short ip_fast_csum(unsigned char * iph,
80 unsigned int ihl)
81{
82 unsigned int sum;
83
84 __asm__ __volatile__(
85 "movl (%1), %0 ;\n"
86 "subl $4, %2 ;\n"
87 "jbe 2f ;\n"
88 "addl 4(%1), %0 ;\n"
89 "adcl 8(%1), %0 ;\n"
90 "adcl 12(%1), %0 ;\n"
91"1: adcl 16(%1), %0 ;\n"
92 "lea 4(%1), %1 ;\n"
93 "decl %2 ;\n"
94 "jne 1b ;\n"
95 "adcl $0, %0 ;\n"
96 "movl %0, %2 ;\n"
97 "shrl $16, %0 ;\n"
98 "addw %w2, %w0 ;\n"
99 "adcl $0, %0 ;\n"
100 "notl %0 ;\n"
101"2: ;\n"
102 /* Since the input registers which are loaded with iph and ipl
103 are modified, we must also specify them as outputs, or gcc
104 will assume they contain their original values. */
105 : "=r" (sum), "=r" (iph), "=r" (ihl)
106 : "1" (iph), "2" (ihl)
107 : "memory");
108 return(sum);
109}
110
111/*
112 * Fold a partial checksum
113 */
114
115static inline unsigned int csum_fold(unsigned int sum)
116{
117 __asm__(
118 "addl %1, %0 ;\n"
119 "adcl $0xffff, %0 ;\n"
120 : "=r" (sum)
121 : "r" (sum << 16), "0" (sum & 0xffff0000)
122 );
123 return (~sum) >> 16;
124}
125
126static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
127 unsigned long daddr,
128 unsigned short len,
129 unsigned short proto,
130 unsigned int sum)
131{
132 __asm__(
133 "addl %1, %0 ;\n"
134 "adcl %2, %0 ;\n"
135 "adcl %3, %0 ;\n"
136 "adcl $0, %0 ;\n"
137 : "=r" (sum)
138 : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum));
139 return sum;
140}
141
142/*
143 * computes the checksum of the TCP/UDP pseudo-header
144 * returns a 16-bit checksum, already complemented
145 */
146static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
147 unsigned long daddr,
148 unsigned short len,
149 unsigned short proto,
150 unsigned int sum)
151{
152 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
153}
154
155/*
156 * this routine is used for miscellaneous IP-like checksums, mainly
157 * in icmp.c
158 */
159
160static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
161{
162 return csum_fold (csum_partial(buff, len, 0));
163}
164
165#define _HAVE_ARCH_IPV6_CSUM
166static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
167 struct in6_addr *daddr,
168 __u32 len,
169 unsigned short proto,
170 unsigned int sum)
171{
172 __asm__(
173 "addl 0(%1), %0 ;\n"
174 "adcl 4(%1), %0 ;\n"
175 "adcl 8(%1), %0 ;\n"
176 "adcl 12(%1), %0 ;\n"
177 "adcl 0(%2), %0 ;\n"
178 "adcl 4(%2), %0 ;\n"
179 "adcl 8(%2), %0 ;\n"
180 "adcl 12(%2), %0 ;\n"
181 "adcl %3, %0 ;\n"
182 "adcl %4, %0 ;\n"
183 "adcl $0, %0 ;\n"
184 : "=&r" (sum)
185 : "r" (saddr), "r" (daddr),
186 "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
187
188 return csum_fold(sum);
189}
190
191/*
192 * Copy and checksum to user
193 */
194#define HAVE_CSUM_COPY_USER
195static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
196 unsigned char *dst,
197 int len, int sum, int *err_ptr)
198{
199 if (access_ok(VERIFY_WRITE, dst, len))
200 return(csum_partial_copy_to(src, dst, len, sum, err_ptr));
201
202 if (len)
203 *err_ptr = -EFAULT;
204
205 return -1; /* invalid checksum */
206}
207
208#endif
209
210/*
211 * Overrides for Emacs so that we follow Linus's tabbing style.
212 * Emacs will notice this stuff at the end of the file and automatically
213 * adjust the settings for this buffer only. This must remain at the end
214 * of the file.
215 * ---------------------------------------------------------------------------
216 * Local variables:
217 * c-file-style: "linux"
218 * End:
219 */
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
new file mode 100644
index 000000000000..661d495e2044
--- /dev/null
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -0,0 +1,241 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_PTRACE_H
7#define __SYSDEP_I386_PTRACE_H
8
9#include "uml-config.h"
10#include "user_constants.h"
11
12#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
13#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14
15extern void update_debugregs(int seq);
16
17/* syscall emulation path in ptrace */
18
19#ifndef PTRACE_SYSEMU
20#define PTRACE_SYSEMU 31
21#endif
22
23void set_using_sysemu(int value);
24int get_using_sysemu(void);
25extern int sysemu_supported;
26
27#ifdef UML_CONFIG_MODE_TT
28#include "sysdep/sc.h"
29#endif
30
31#ifdef UML_CONFIG_MODE_SKAS
32
33#include "skas_ptregs.h"
34
35#define REGS_IP(r) ((r)[HOST_IP])
36#define REGS_SP(r) ((r)[HOST_SP])
37#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
38#define REGS_EAX(r) ((r)[HOST_EAX])
39#define REGS_EBX(r) ((r)[HOST_EBX])
40#define REGS_ECX(r) ((r)[HOST_ECX])
41#define REGS_EDX(r) ((r)[HOST_EDX])
42#define REGS_ESI(r) ((r)[HOST_ESI])
43#define REGS_EDI(r) ((r)[HOST_EDI])
44#define REGS_EBP(r) ((r)[HOST_EBP])
45#define REGS_CS(r) ((r)[HOST_CS])
46#define REGS_SS(r) ((r)[HOST_SS])
47#define REGS_DS(r) ((r)[HOST_DS])
48#define REGS_ES(r) ((r)[HOST_ES])
49#define REGS_FS(r) ((r)[HOST_FS])
50#define REGS_GS(r) ((r)[HOST_GS])
51
52#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
53
54#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
55
56#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
57
58#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
59
60#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
61
62#endif
63#ifndef PTRACE_SYSEMU_SINGLESTEP
64#define PTRACE_SYSEMU_SINGLESTEP 32
65#endif
66
67#include "choose-mode.h"
68
69union uml_pt_regs {
70#ifdef UML_CONFIG_MODE_TT
71 struct tt_regs {
72 long syscall;
73 void *sc;
74 } tt;
75#endif
76#ifdef UML_CONFIG_MODE_SKAS
77 struct skas_regs {
78 unsigned long regs[HOST_FRAME_SIZE];
79 unsigned long fp[HOST_FP_SIZE];
80 unsigned long xfp[HOST_XFP_SIZE];
81 unsigned long fault_addr;
82 unsigned long fault_type;
83 unsigned long trap_type;
84 long syscall;
85 int is_user;
86 } skas;
87#endif
88};
89
90#define EMPTY_UML_PT_REGS { }
91
92extern int mode_tt;
93
94#define UPT_SC(r) ((r)->tt.sc)
95#define UPT_IP(r) \
96 __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
97#define UPT_SP(r) \
98 __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
99#define UPT_EFLAGS(r) \
100 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
101#define UPT_EAX(r) \
102 __CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs))
103#define UPT_EBX(r) \
104 __CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs))
105#define UPT_ECX(r) \
106 __CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs))
107#define UPT_EDX(r) \
108 __CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs))
109#define UPT_ESI(r) \
110 __CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs))
111#define UPT_EDI(r) \
112 __CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs))
113#define UPT_EBP(r) \
114 __CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs))
115#define UPT_ORIG_EAX(r) \
116 __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
117#define UPT_CS(r) \
118 __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
119#define UPT_SS(r) \
120 __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
121#define UPT_DS(r) \
122 __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
123#define UPT_ES(r) \
124 __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
125#define UPT_FS(r) \
126 __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
127#define UPT_GS(r) \
128 __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
129
130#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
131#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
132#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
133#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
134#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
135#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
136
137extern int user_context(unsigned long sp);
138
139#define UPT_IS_USER(r) \
140 CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
141
142struct syscall_args {
143 unsigned long args[6];
144};
145
146#define SYSCALL_ARGS(r) ((struct syscall_args) \
147 { .args = { UPT_SYSCALL_ARG1(r), \
148 UPT_SYSCALL_ARG2(r), \
149 UPT_SYSCALL_ARG3(r), \
150 UPT_SYSCALL_ARG4(r), \
151 UPT_SYSCALL_ARG5(r), \
152 UPT_SYSCALL_ARG6(r) } } )
153
154#define UPT_REG(regs, reg) \
155 ({ unsigned long val; \
156 switch(reg){ \
157 case EIP: val = UPT_IP(regs); break; \
158 case UESP: val = UPT_SP(regs); break; \
159 case EAX: val = UPT_EAX(regs); break; \
160 case EBX: val = UPT_EBX(regs); break; \
161 case ECX: val = UPT_ECX(regs); break; \
162 case EDX: val = UPT_EDX(regs); break; \
163 case ESI: val = UPT_ESI(regs); break; \
164 case EDI: val = UPT_EDI(regs); break; \
165 case EBP: val = UPT_EBP(regs); break; \
166 case ORIG_EAX: val = UPT_ORIG_EAX(regs); break; \
167 case CS: val = UPT_CS(regs); break; \
168 case SS: val = UPT_SS(regs); break; \
169 case DS: val = UPT_DS(regs); break; \
170 case ES: val = UPT_ES(regs); break; \
171 case FS: val = UPT_FS(regs); break; \
172 case GS: val = UPT_GS(regs); break; \
173 case EFL: val = UPT_EFLAGS(regs); break; \
174 default : \
175 panic("Bad register in UPT_REG : %d\n", reg); \
176 val = -1; \
177 } \
178 val; \
179 })
180
181
182#define UPT_SET(regs, reg, val) \
183 do { \
184 switch(reg){ \
185 case EIP: UPT_IP(regs) = val; break; \
186 case UESP: UPT_SP(regs) = val; break; \
187 case EAX: UPT_EAX(regs) = val; break; \
188 case EBX: UPT_EBX(regs) = val; break; \
189 case ECX: UPT_ECX(regs) = val; break; \
190 case EDX: UPT_EDX(regs) = val; break; \
191 case ESI: UPT_ESI(regs) = val; break; \
192 case EDI: UPT_EDI(regs) = val; break; \
193 case EBP: UPT_EBP(regs) = val; break; \
194 case ORIG_EAX: UPT_ORIG_EAX(regs) = val; break; \
195 case CS: UPT_CS(regs) = val; break; \
196 case SS: UPT_SS(regs) = val; break; \
197 case DS: UPT_DS(regs) = val; break; \
198 case ES: UPT_ES(regs) = val; break; \
199 case FS: UPT_FS(regs) = val; break; \
200 case GS: UPT_GS(regs) = val; break; \
201 case EFL: UPT_EFLAGS(regs) = val; break; \
202 default : \
203 panic("Bad register in UPT_SET : %d\n", reg); \
204 break; \
205 } \
206 } while (0)
207
208#define UPT_SET_SYSCALL_RETURN(r, res) \
209 CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
210 REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
211
212#define UPT_RESTART_SYSCALL(r) \
213 CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
214 REGS_RESTART_SYSCALL((r)->skas.regs))
215
216#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
217#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
218#define UPT_SYSCALL_RET(r) UPT_EAX(r)
219
220#define UPT_SEGV_IS_FIXABLE(r) \
221 CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
222 REGS_SEGV_IS_FIXABLE(&r->skas))
223
224#define UPT_FAULT_ADDR(r) \
225 __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
226
227#define UPT_FAULT_WRITE(r) \
228 CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
229
230#endif
231
232/*
233 * Overrides for Emacs so that we follow Linus's tabbing style.
234 * Emacs will notice this stuff at the end of the file and automatically
235 * adjust the settings for this buffer only. This must remain at the end
236 * of the file.
237 * ---------------------------------------------------------------------------
238 * Local variables:
239 * c-file-style: "linux"
240 * End:
241 */
diff --git a/arch/um/include/sysdep-i386/ptrace_user.h b/arch/um/include/sysdep-i386/ptrace_user.h
new file mode 100644
index 000000000000..eca8066e7a43
--- /dev/null
+++ b/arch/um/include/sysdep-i386/ptrace_user.h
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_PTRACE_USER_H__
7#define __SYSDEP_I386_PTRACE_USER_H__
8
9#include <sys/ptrace.h>
10#include <linux/ptrace.h>
11#include <asm/ptrace.h>
12
13#define PT_OFFSET(r) ((r) * sizeof(long))
14
15#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX])
16#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX)
17
18#define PT_SYSCALL_ARG1_OFFSET PT_OFFSET(EBX)
19#define PT_SYSCALL_ARG2_OFFSET PT_OFFSET(ECX)
20#define PT_SYSCALL_ARG3_OFFSET PT_OFFSET(EDX)
21#define PT_SYSCALL_ARG4_OFFSET PT_OFFSET(ESI)
22#define PT_SYSCALL_ARG5_OFFSET PT_OFFSET(EDI)
23
24#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX)
25
26#define PT_IP_OFFSET PT_OFFSET(EIP)
27#define PT_IP(regs) ((regs)[EIP])
28#define PT_SP(regs) ((regs)[UESP])
29
30#ifndef FRAME_SIZE
31#define FRAME_SIZE (17)
32#endif
33#define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long))
34
35#define FP_FRAME_SIZE (27)
36#define FPX_FRAME_SIZE (128)
37
38#ifdef PTRACE_GETREGS
39#define UM_HAVE_GETREGS
40#endif
41
42#ifdef PTRACE_SETREGS
43#define UM_HAVE_SETREGS
44#endif
45
46#ifdef PTRACE_GETFPREGS
47#define UM_HAVE_GETFPREGS
48#endif
49
50#ifdef PTRACE_SETFPREGS
51#define UM_HAVE_SETFPREGS
52#endif
53
54#ifdef PTRACE_GETFPXREGS
55#define UM_HAVE_GETFPXREGS
56#endif
57
58#ifdef PTRACE_SETFPXREGS
59#define UM_HAVE_SETFPXREGS
60#endif
61
62#endif
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h
new file mode 100644
index 000000000000..dfee589de360
--- /dev/null
+++ b/arch/um/include/sysdep-i386/sigcontext.h
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYS_SIGCONTEXT_I386_H
7#define __SYS_SIGCONTEXT_I386_H
8
9#include <sysdep/sc.h>
10
11#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
12
13#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
14#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
15
16#define SC_FAULT_ADDR(sc) SC_CR2(sc)
17#define SC_FAULT_TYPE(sc) SC_ERR(sc)
18
19#define FAULT_WRITE(err) (err & 2)
20#define TO_SC_ERR(is_write) ((is_write) ? 2 : 0)
21
22#define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc)))
23
24#define SC_TRAP_TYPE(sc) SC_TRAPNO(sc)
25
26/* ptrace expects that, at the start of a system call, %eax contains
27 * -ENOSYS, so this makes it so.
28 */
29#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
30
31/* This is Page Fault */
32#define SEGV_IS_FIXABLE(trap) (trap == 14)
33
34#define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
35
36extern unsigned long *sc_sigmask(void *sc_ptr);
37extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
38
39#endif
40/*
41 * Overrides for Emacs so that we follow Linus's tabbing style.
42 * Emacs will notice this stuff at the end of the file and automatically
43 * adjust the settings for this buffer only. This must remain at the end
44 * of the file.
45 * ---------------------------------------------------------------------------
46 * Local variables:
47 * c-file-style: "linux"
48 * End:
49 */
diff --git a/arch/um/include/sysdep-i386/signal.h b/arch/um/include/sysdep-i386/signal.h
new file mode 100644
index 000000000000..b1e1f7a77499
--- /dev/null
+++ b/arch/um/include/sysdep-i386/signal.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2004 PathScale, Inc
3 * Licensed under the GPL
4 */
5
6#ifndef __I386_SIGNAL_H_
7#define __I386_SIGNAL_H_
8
9#include <signal.h>
10
11#define ARCH_GET_SIGCONTEXT(sc, sig) \
12 do sc = (struct sigcontext *) (&sig + 1); while(0)
13
14#endif
15
16/*
17 * Overrides for Emacs so that we follow Linus's tabbing style.
18 * Emacs will notice this stuff at the end of the file and automatically
19 * adjust the settings for this buffer only. This must remain at the end
20 * of the file.
21 * ---------------------------------------------------------------------------
22 * Local variables:
23 * c-file-style: "linux"
24 * End:
25 */
diff --git a/arch/um/include/sysdep-i386/syscalls.h b/arch/um/include/sysdep-i386/syscalls.h
new file mode 100644
index 000000000000..5db81ec9087d
--- /dev/null
+++ b/arch/um/include/sysdep-i386/syscalls.h
@@ -0,0 +1,123 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "asm/unistd.h"
7#include "sysdep/ptrace.h"
8
9typedef long syscall_handler_t(struct pt_regs);
10
11/* Not declared on x86, incompatible declarations on x86_64, so these have
12 * to go here rather than in sys_call_table.c
13 */
14extern syscall_handler_t sys_ptrace;
15extern syscall_handler_t sys_rt_sigaction;
16
17extern syscall_handler_t old_mmap_i386;
18
19#define EXECUTE_SYSCALL(syscall, regs) \
20 ((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
21
22extern long sys_mmap2(unsigned long addr, unsigned long len,
23 unsigned long prot, unsigned long flags,
24 unsigned long fd, unsigned long pgoff);
25
26/* On i386 they choose a meaningless naming.*/
27#define __NR_kexec_load __NR_sys_kexec_load
28
29#define ARCH_SYSCALLS \
30 [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid, \
31 [ __NR_break ] = (syscall_handler_t *) sys_ni_syscall, \
32 [ __NR_oldstat ] = (syscall_handler_t *) sys_stat, \
33 [ __NR_umount ] = (syscall_handler_t *) sys_oldumount, \
34 [ __NR_stime ] = um_stime, \
35 [ __NR_oldfstat ] = (syscall_handler_t *) sys_fstat, \
36 [ __NR_stty ] = (syscall_handler_t *) sys_ni_syscall, \
37 [ __NR_gtty ] = (syscall_handler_t *) sys_ni_syscall, \
38 [ __NR_nice ] = (syscall_handler_t *) sys_nice, \
39 [ __NR_ftime ] = (syscall_handler_t *) sys_ni_syscall, \
40 [ __NR_prof ] = (syscall_handler_t *) sys_ni_syscall, \
41 [ __NR_signal ] = (syscall_handler_t *) sys_signal, \
42 [ __NR_lock ] = (syscall_handler_t *) sys_ni_syscall, \
43 [ __NR_mpx ] = (syscall_handler_t *) sys_ni_syscall, \
44 [ __NR_ulimit ] = (syscall_handler_t *) sys_ni_syscall, \
45 [ __NR_oldolduname ] = (syscall_handler_t *) sys_olduname, \
46 [ __NR_sigaction ] = (syscall_handler_t *) sys_sigaction, \
47 [ __NR_sgetmask ] = (syscall_handler_t *) sys_sgetmask, \
48 [ __NR_ssetmask ] = (syscall_handler_t *) sys_ssetmask, \
49 [ __NR_sigsuspend ] = (syscall_handler_t *) sys_sigsuspend, \
50 [ __NR_sigpending ] = (syscall_handler_t *) sys_sigpending, \
51 [ __NR_oldlstat ] = (syscall_handler_t *) sys_lstat, \
52 [ __NR_readdir ] = old_readdir, \
53 [ __NR_profil ] = (syscall_handler_t *) sys_ni_syscall, \
54 [ __NR_socketcall ] = (syscall_handler_t *) sys_socketcall, \
55 [ __NR_olduname ] = (syscall_handler_t *) sys_uname, \
56 [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
57 [ __NR_idle ] = (syscall_handler_t *) sys_ni_syscall, \
58 [ __NR_ipc ] = (syscall_handler_t *) sys_ipc, \
59 [ __NR_sigreturn ] = (syscall_handler_t *) sys_sigreturn, \
60 [ __NR_sigprocmask ] = (syscall_handler_t *) sys_sigprocmask, \
61 [ __NR_bdflush ] = (syscall_handler_t *) sys_bdflush, \
62 [ __NR__llseek ] = (syscall_handler_t *) sys_llseek, \
63 [ __NR__newselect ] = (syscall_handler_t *) sys_select, \
64 [ __NR_vm86 ] = (syscall_handler_t *) sys_ni_syscall, \
65 [ __NR_mmap ] = (syscall_handler_t *) old_mmap_i386, \
66 [ __NR_ugetrlimit ] = (syscall_handler_t *) sys_getrlimit, \
67 [ __NR_mmap2 ] = (syscall_handler_t *) sys_mmap2, \
68 [ __NR_truncate64 ] = (syscall_handler_t *) sys_truncate64, \
69 [ __NR_ftruncate64 ] = (syscall_handler_t *) sys_ftruncate64, \
70 [ __NR_stat64 ] = (syscall_handler_t *) sys_stat64, \
71 [ __NR_lstat64 ] = (syscall_handler_t *) sys_lstat64, \
72 [ __NR_fstat64 ] = (syscall_handler_t *) sys_fstat64, \
73 [ __NR_fcntl64 ] = (syscall_handler_t *) sys_fcntl64, \
74 [ __NR_sendfile64 ] = (syscall_handler_t *) sys_sendfile64, \
75 [ __NR_statfs64 ] = (syscall_handler_t *) sys_statfs64, \
76 [ __NR_fstatfs64 ] = (syscall_handler_t *) sys_fstatfs64, \
77 [ __NR_fadvise64_64 ] = (syscall_handler_t *) sys_fadvise64_64, \
78 [ __NR_select ] = (syscall_handler_t *) old_select, \
79 [ __NR_vm86old ] = (syscall_handler_t *) sys_ni_syscall, \
80 [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
81 [ __NR_lchown32 ] = (syscall_handler_t *) sys_lchown, \
82 [ __NR_getuid32 ] = (syscall_handler_t *) sys_getuid, \
83 [ __NR_getgid32 ] = (syscall_handler_t *) sys_getgid, \
84 [ __NR_geteuid32 ] = (syscall_handler_t *) sys_geteuid, \
85 [ __NR_getegid32 ] = (syscall_handler_t *) sys_getegid, \
86 [ __NR_setreuid32 ] = (syscall_handler_t *) sys_setreuid, \
87 [ __NR_setregid32 ] = (syscall_handler_t *) sys_setregid, \
88 [ __NR_getgroups32 ] = (syscall_handler_t *) sys_getgroups, \
89 [ __NR_setgroups32 ] = (syscall_handler_t *) sys_setgroups, \
90 [ __NR_fchown32 ] = (syscall_handler_t *) sys_fchown, \
91 [ __NR_setresuid32 ] = (syscall_handler_t *) sys_setresuid, \
92 [ __NR_getresuid32 ] = (syscall_handler_t *) sys_getresuid, \
93 [ __NR_setresgid32 ] = (syscall_handler_t *) sys_setresgid, \
94 [ __NR_getresgid32 ] = (syscall_handler_t *) sys_getresgid, \
95 [ __NR_chown32 ] = (syscall_handler_t *) sys_chown, \
96 [ __NR_setuid32 ] = (syscall_handler_t *) sys_setuid, \
97 [ __NR_setgid32 ] = (syscall_handler_t *) sys_setgid, \
98 [ __NR_setfsuid32 ] = (syscall_handler_t *) sys_setfsuid, \
99 [ __NR_setfsgid32 ] = (syscall_handler_t *) sys_setfsgid, \
100 [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
101 [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
102 [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
103 [ 222 ] = (syscall_handler_t *) sys_ni_syscall, \
104 [ 223 ] = (syscall_handler_t *) sys_ni_syscall, \
105 [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
106 [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
107 [ 251 ] = (syscall_handler_t *) sys_ni_syscall, \
108 [ 285 ] = (syscall_handler_t *) sys_ni_syscall,
109
110/* 222 doesn't yet have a name in include/asm-i386/unistd.h */
111
112#define LAST_ARCH_SYSCALL 285
113
114/*
115 * Overrides for Emacs so that we follow Linus's tabbing style.
116 * Emacs will notice this stuff at the end of the file and automatically
117 * adjust the settings for this buffer only. This must remain at the end
118 * of the file.
119 * ---------------------------------------------------------------------------
120 * Local variables:
121 * c-file-style: "linux"
122 * End:
123 */