aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include/sysdep-x86_64
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-x86_64
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-x86_64')
-rw-r--r--arch/um/include/sysdep-x86_64/checksum.h151
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h264
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace_user.h69
-rw-r--r--arch/um/include/sysdep-x86_64/sigcontext.h49
-rw-r--r--arch/um/include/sysdep-x86_64/signal.h27
-rw-r--r--arch/um/include/sysdep-x86_64/syscalls.h91
6 files changed, 651 insertions, 0 deletions
diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/include/sysdep-x86_64/checksum.h
new file mode 100644
index 000000000000..572c6c19be33
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/checksum.h
@@ -0,0 +1,151 @@
1/*
2 * Licensed under the GPL
3 */
4
5#ifndef __UM_SYSDEP_CHECKSUM_H
6#define __UM_SYSDEP_CHECKSUM_H
7
8#include "linux/string.h"
9#include "linux/in6.h"
10#include "asm/uaccess.h"
11
12extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len,
13 int sum, int *err_ptr);
14extern unsigned csum_partial(const unsigned char *buff, unsigned len,
15 unsigned sum);
16
17/*
18 * Note: when you get a NULL pointer exception here this means someone
19 * passed in an incorrect kernel address to one of these functions.
20 *
21 * If you use these functions directly please don't forget the
22 * access_ok().
23 */
24
25static __inline__
26unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst,
27 int len, int sum)
28{
29 memcpy(dst, src, len);
30 return(csum_partial(dst, len, sum));
31}
32
33static __inline__
34unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
35 int len, int sum, int *err_ptr)
36{
37 return csum_partial_copy_from(src, dst, len, sum, err_ptr);
38}
39
40/**
41 * csum_fold - Fold and invert a 32bit checksum.
42 * sum: 32bit unfolded sum
43 *
44 * Fold a 32bit running checksum to 16bit and invert it. This is usually
45 * the last step before putting a checksum into a packet.
46 * Make sure not to mix with 64bit checksums.
47 */
48static inline unsigned int csum_fold(unsigned int sum)
49{
50 __asm__(
51 " addl %1,%0\n"
52 " adcl $0xffff,%0"
53 : "=r" (sum)
54 : "r" (sum << 16), "0" (sum & 0xffff0000)
55 );
56 return (~sum) >> 16;
57}
58
59/**
60 * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum.
61 * @saddr: source address
62 * @daddr: destination address
63 * @len: length of packet
64 * @proto: ip protocol of packet
65 * @sum: initial sum to be added in (32bit unfolded)
66 *
67 * Returns the pseudo header checksum the input data. Result is
68 * 32bit unfolded.
69 */
70static inline unsigned long
71csum_tcpudp_nofold(unsigned saddr, unsigned daddr, unsigned short len,
72 unsigned short proto, unsigned int sum)
73{
74 asm(" addl %1, %0\n"
75 " adcl %2, %0\n"
76 " adcl %3, %0\n"
77 " adcl $0, %0\n"
78 : "=r" (sum)
79 : "g" (daddr), "g" (saddr), "g" ((ntohs(len)<<16)+proto*256), "0" (sum));
80 return sum;
81}
82
83/*
84 * computes the checksum of the TCP/UDP pseudo-header
85 * returns a 16-bit checksum, already complemented
86 */
87static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
88 unsigned long daddr,
89 unsigned short len,
90 unsigned short proto,
91 unsigned int sum)
92{
93 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
94}
95
96/**
97 * ip_fast_csum - Compute the IPv4 header checksum efficiently.
98 * iph: ipv4 header
99 * ihl: length of header / 4
100 */
101static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
102{
103 unsigned int sum;
104
105 asm( " movl (%1), %0\n"
106 " subl $4, %2\n"
107 " jbe 2f\n"
108 " addl 4(%1), %0\n"
109 " adcl 8(%1), %0\n"
110 " adcl 12(%1), %0\n"
111 "1: adcl 16(%1), %0\n"
112 " lea 4(%1), %1\n"
113 " decl %2\n"
114 " jne 1b\n"
115 " adcl $0, %0\n"
116 " movl %0, %2\n"
117 " shrl $16, %0\n"
118 " addw %w2, %w0\n"
119 " adcl $0, %0\n"
120 " notl %0\n"
121 "2:"
122 /* Since the input registers which are loaded with iph and ipl
123 are modified, we must also specify them as outputs, or gcc
124 will assume they contain their original values. */
125 : "=r" (sum), "=r" (iph), "=r" (ihl)
126 : "1" (iph), "2" (ihl)
127 : "memory");
128 return(sum);
129}
130
131static inline unsigned add32_with_carry(unsigned a, unsigned b)
132{
133 asm("addl %2,%0\n\t"
134 "adcl $0,%0"
135 : "=r" (a)
136 : "0" (a), "r" (b));
137 return a;
138}
139
140#endif
141
142/*
143 * Overrides for Emacs so that we follow Linus's tabbing style.
144 * Emacs will notice this stuff at the end of the file and automatically
145 * adjust the settings for this buffer only. This must remain at the end
146 * of the file.
147 * ---------------------------------------------------------------------------
148 * Local variables:
149 * c-file-style: "linux"
150 * End:
151 */
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
new file mode 100644
index 000000000000..915c82daffbd
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -0,0 +1,264 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_PTRACE_H
8#define __SYSDEP_X86_64_PTRACE_H
9
10#include "uml-config.h"
11#include "user_constants.h"
12
13#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
15
16#ifdef UML_CONFIG_MODE_TT
17#include "sysdep/sc.h"
18#endif
19
20#ifdef UML_CONFIG_MODE_SKAS
21#include "skas_ptregs.h"
22
23#define REGS_IP(r) ((r)[HOST_IP])
24#define REGS_SP(r) ((r)[HOST_SP])
25
26#define REGS_RBX(r) ((r)[HOST_RBX])
27#define REGS_RCX(r) ((r)[HOST_RCX])
28#define REGS_RDX(r) ((r)[HOST_RDX])
29#define REGS_RSI(r) ((r)[HOST_RSI])
30#define REGS_RDI(r) ((r)[HOST_RDI])
31#define REGS_RBP(r) ((r)[HOST_RBP])
32#define REGS_RAX(r) ((r)[HOST_RAX])
33#define REGS_R8(r) ((r)[HOST_R8])
34#define REGS_R9(r) ((r)[HOST_R9])
35#define REGS_R10(r) ((r)[HOST_R10])
36#define REGS_R11(r) ((r)[HOST_R11])
37#define REGS_R12(r) ((r)[HOST_R12])
38#define REGS_R13(r) ((r)[HOST_R13])
39#define REGS_R14(r) ((r)[HOST_R14])
40#define REGS_R15(r) ((r)[HOST_R15])
41#define REGS_CS(r) ((r)[HOST_CS])
42#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
43#define REGS_SS(r) ((r)[HOST_SS])
44
45#define HOST_FS_BASE 21
46#define HOST_GS_BASE 22
47#define HOST_DS 23
48#define HOST_ES 24
49#define HOST_FS 25
50#define HOST_GS 26
51
52#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
53#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
54#define REGS_DS(r) ((r)[HOST_DS])
55#define REGS_ES(r) ((r)[HOST_ES])
56#define REGS_FS(r) ((r)[HOST_FS])
57#define REGS_GS(r) ((r)[HOST_GS])
58
59#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX])
60
61#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
62
63#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
64
65#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
66
67#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
68
69#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
70
71#define REGS_TRAP(r) ((r)->trap_type)
72
73#define REGS_ERR(r) ((r)->fault_type)
74
75#endif
76
77#include "choose-mode.h"
78
79/* XXX */
80union uml_pt_regs {
81#ifdef UML_CONFIG_MODE_TT
82 struct tt_regs {
83 long syscall;
84 unsigned long orig_rax;
85 void *sc;
86 } tt;
87#endif
88#ifdef UML_CONFIG_MODE_SKAS
89 struct skas_regs {
90 /* XXX */
91 unsigned long regs[27];
92 unsigned long fp[65];
93 unsigned long fault_addr;
94 unsigned long fault_type;
95 unsigned long trap_type;
96 long syscall;
97 int is_user;
98 } skas;
99#endif
100};
101
102#define EMPTY_UML_PT_REGS { }
103
104/* XXX */
105extern int mode_tt;
106
107#define UPT_RBX(r) __CHOOSE_MODE(SC_RBX(UPT_SC(r)), REGS_RBX((r)->skas.regs))
108#define UPT_RCX(r) __CHOOSE_MODE(SC_RCX(UPT_SC(r)), REGS_RCX((r)->skas.regs))
109#define UPT_RDX(r) __CHOOSE_MODE(SC_RDX(UPT_SC(r)), REGS_RDX((r)->skas.regs))
110#define UPT_RSI(r) __CHOOSE_MODE(SC_RSI(UPT_SC(r)), REGS_RSI((r)->skas.regs))
111#define UPT_RDI(r) __CHOOSE_MODE(SC_RDI(UPT_SC(r)), REGS_RDI((r)->skas.regs))
112#define UPT_RBP(r) __CHOOSE_MODE(SC_RBP(UPT_SC(r)), REGS_RBP((r)->skas.regs))
113#define UPT_RAX(r) __CHOOSE_MODE(SC_RAX(UPT_SC(r)), REGS_RAX((r)->skas.regs))
114#define UPT_R8(r) __CHOOSE_MODE(SC_R8(UPT_SC(r)), REGS_R8((r)->skas.regs))
115#define UPT_R9(r) __CHOOSE_MODE(SC_R9(UPT_SC(r)), REGS_R9((r)->skas.regs))
116#define UPT_R10(r) __CHOOSE_MODE(SC_R10(UPT_SC(r)), REGS_R10((r)->skas.regs))
117#define UPT_R11(r) __CHOOSE_MODE(SC_R11(UPT_SC(r)), REGS_R11((r)->skas.regs))
118#define UPT_R12(r) __CHOOSE_MODE(SC_R12(UPT_SC(r)), REGS_R12((r)->skas.regs))
119#define UPT_R13(r) __CHOOSE_MODE(SC_R13(UPT_SC(r)), REGS_R13((r)->skas.regs))
120#define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs))
121#define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs))
122#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
123#define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
124#define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
125#define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
126#define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
127#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
128#define UPT_ORIG_RAX(r) \
129 __CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs))
130
131#define UPT_IP(r) __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
132#define UPT_SP(r) __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
133
134#define UPT_EFLAGS(r) \
135 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
136#define UPT_SC(r) ((r)->tt.sc)
137#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
138
139extern int user_context(unsigned long sp);
140
141#define UPT_IS_USER(r) \
142 CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
143
144#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
145#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
146#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
147#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
148#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
149#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
150
151struct syscall_args {
152 unsigned long args[6];
153};
154
155#define SYSCALL_ARGS(r) ((struct syscall_args) \
156 { .args = { UPT_SYSCALL_ARG1(r), \
157 UPT_SYSCALL_ARG2(r), \
158 UPT_SYSCALL_ARG3(r), \
159 UPT_SYSCALL_ARG4(r), \
160 UPT_SYSCALL_ARG5(r), \
161 UPT_SYSCALL_ARG6(r) } } )
162
163#define UPT_REG(regs, reg) \
164 ({ unsigned long val; \
165 switch(reg){ \
166 case R8: val = UPT_R8(regs); break; \
167 case R9: val = UPT_R9(regs); break; \
168 case R10: val = UPT_R10(regs); break; \
169 case R11: val = UPT_R11(regs); break; \
170 case R12: val = UPT_R12(regs); break; \
171 case R13: val = UPT_R13(regs); break; \
172 case R14: val = UPT_R14(regs); break; \
173 case R15: val = UPT_R15(regs); break; \
174 case RIP: val = UPT_IP(regs); break; \
175 case RSP: val = UPT_SP(regs); break; \
176 case RAX: val = UPT_RAX(regs); break; \
177 case RBX: val = UPT_RBX(regs); break; \
178 case RCX: val = UPT_RCX(regs); break; \
179 case RDX: val = UPT_RDX(regs); break; \
180 case RSI: val = UPT_RSI(regs); break; \
181 case RDI: val = UPT_RDI(regs); break; \
182 case RBP: val = UPT_RBP(regs); break; \
183 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
184 case CS: val = UPT_CS(regs); break; \
185 case DS: val = UPT_DS(regs); break; \
186 case ES: val = UPT_ES(regs); break; \
187 case FS: val = UPT_FS(regs); break; \
188 case GS: val = UPT_GS(regs); break; \
189 case EFLAGS: val = UPT_EFLAGS(regs); break; \
190 default : \
191 panic("Bad register in UPT_REG : %d\n", reg); \
192 val = -1; \
193 } \
194 val; \
195 })
196
197
198#define UPT_SET(regs, reg, val) \
199 ({ unsigned long val; \
200 switch(reg){ \
201 case R8: UPT_R8(regs) = val; break; \
202 case R9: UPT_R9(regs) = val; break; \
203 case R10: UPT_R10(regs) = val; break; \
204 case R11: UPT_R11(regs) = val; break; \
205 case R12: UPT_R12(regs) = val; break; \
206 case R13: UPT_R13(regs) = val; break; \
207 case R14: UPT_R14(regs) = val; break; \
208 case R15: UPT_R15(regs) = val; break; \
209 case RIP: UPT_IP(regs) = val; break; \
210 case RSP: UPT_SP(regs) = val; break; \
211 case RAX: UPT_RAX(regs) = val; break; \
212 case RBX: UPT_RBX(regs) = val; break; \
213 case RCX: UPT_RCX(regs) = val; break; \
214 case RDX: UPT_RDX(regs) = val; break; \
215 case RSI: UPT_RSI(regs) = val; break; \
216 case RDI: UPT_RDI(regs) = val; break; \
217 case RBP: UPT_RBP(regs) = val; break; \
218 case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \
219 case CS: UPT_CS(regs) = val; break; \
220 case DS: UPT_DS(regs) = val; break; \
221 case ES: UPT_ES(regs) = val; break; \
222 case FS: UPT_FS(regs) = val; break; \
223 case GS: UPT_GS(regs) = val; break; \
224 case EFLAGS: UPT_EFLAGS(regs) = val; break; \
225 default : \
226 panic("Bad register in UPT_SET : %d\n", reg); \
227 break; \
228 } \
229 val; \
230 })
231
232#define UPT_SET_SYSCALL_RETURN(r, res) \
233 CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
234 REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
235
236#define UPT_RESTART_SYSCALL(r) \
237 CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
238 REGS_RESTART_SYSCALL((r)->skas.regs))
239
240#define UPT_SEGV_IS_FIXABLE(r) \
241 CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
242 REGS_SEGV_IS_FIXABLE(&r->skas))
243
244#define UPT_FAULT_ADDR(r) \
245 __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
246
247#define UPT_FAULT_WRITE(r) \
248 CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
249
250#define UPT_TRAP(r) __CHOOSE_MODE(SC_TRAP_TYPE(UPT_SC(r)), REGS_TRAP(&r->skas))
251#define UPT_ERR(r) __CHOOSE_MODE(SC_FAULT_TYPE(UPT_SC(r)), REGS_ERR(&r->skas))
252
253#endif
254
255/*
256 * Overrides for Emacs so that we follow Linus's tabbing style.
257 * Emacs will notice this stuff at the end of the file and automatically
258 * adjust the settings for this buffer only. This must remain at the end
259 * of the file.
260 * ---------------------------------------------------------------------------
261 * Local variables:
262 * c-file-style: "linux"
263 * End:
264 */
diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/include/sysdep-x86_64/ptrace_user.h
new file mode 100644
index 000000000000..31729973fb14
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/ptrace_user.h
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_PTRACE_USER_H__
8#define __SYSDEP_X86_64_PTRACE_USER_H__
9
10#define __FRAME_OFFSETS
11#include <sys/ptrace.h>
12#include <linux/ptrace.h>
13#include <asm/ptrace.h>
14#undef __FRAME_OFFSETS
15
16#define PT_INDEX(off) ((off) / sizeof(unsigned long))
17
18#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)])
19#define PT_SYSCALL_NR_OFFSET (ORIG_RAX)
20
21#define PT_SYSCALL_ARG1(regs) (((unsigned long *) (regs))[PT_INDEX(RDI)])
22#define PT_SYSCALL_ARG1_OFFSET (RDI)
23
24#define PT_SYSCALL_ARG2(regs) (((unsigned long *) (regs))[PT_INDEX(RSI)])
25#define PT_SYSCALL_ARG2_OFFSET (RSI)
26
27#define PT_SYSCALL_ARG3(regs) (((unsigned long *) (regs))[PT_INDEX(RDX)])
28#define PT_SYSCALL_ARG3_OFFSET (RDX)
29
30#define PT_SYSCALL_ARG4(regs) (((unsigned long *) (regs))[PT_INDEX(RCX)])
31#define PT_SYSCALL_ARG4_OFFSET (RCX)
32
33#define PT_SYSCALL_ARG5(regs) (((unsigned long *) (regs))[PT_INDEX(R8)])
34#define PT_SYSCALL_ARG5_OFFSET (R8)
35
36#define PT_SYSCALL_ARG6(regs) (((unsigned long *) (regs))[PT_INDEX(R9)])
37#define PT_SYSCALL_ARG6_OFFSET (R9)
38
39#define PT_SYSCALL_RET_OFFSET (RAX)
40
41#define PT_IP_OFFSET (RIP)
42#define PT_IP(regs) ((regs)[PT_INDEX(RIP)])
43
44#define PT_SP_OFFSET (RSP)
45#define PT_SP(regs) ((regs)[PT_INDEX(RSP)])
46
47#define PT_ORIG_RAX_OFFSET (ORIG_RAX)
48#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
49
50/* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
51 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
52 * 2.4 name and value for 2.4 host compatibility.
53 */
54#ifndef PTRACE_OLDSETOPTIONS
55#define PTRACE_OLDSETOPTIONS 21
56#endif
57
58#endif
59
60/*
61 * Overrides for Emacs so that we follow Linus's tabbing style.
62 * Emacs will notice this stuff at the end of the file and automatically
63 * adjust the settings for this buffer only. This must remain at the end
64 * of the file.
65 * ---------------------------------------------------------------------------
66 * Local variables:
67 * c-file-style: "linux"
68 * End:
69 */
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h
new file mode 100644
index 000000000000..1e38a54ff4cf
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/sigcontext.h
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_SIGCONTEXT_H
8#define __SYSDEP_X86_64_SIGCONTEXT_H
9
10#include <sysdep/sc.h>
11
12#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
13
14#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
15#define SC_SET_SYSCALL_RETURN(sc, result) SC_RAX(sc) = (result)
16
17#define SC_FAULT_ADDR(sc) SC_CR2(sc)
18#define SC_FAULT_TYPE(sc) SC_ERR(sc)
19
20#define FAULT_WRITE(err) ((err) & 2)
21
22#define SC_FAULT_WRITE(sc) FAULT_WRITE(SC_FAULT_TYPE(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
30#define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
31
32#define SEGV_IS_FIXABLE(trap) ((trap) == 14)
33#define SC_SEGV_IS_FIXABLE(sc) SEGV_IS_FIXABLE(SC_TRAP_TYPE(sc))
34
35extern unsigned long *sc_sigmask(void *sc_ptr);
36
37#endif
38
39/*
40 * Overrides for Emacs so that we follow Linus's tabbing style.
41 * Emacs will notice this stuff at the end of the file and automatically
42 * adjust the settings for this buffer only. This must remain at the end
43 * of the file.
44 * ---------------------------------------------------------------------------
45 * Local variables:
46 * c-file-style: "linux"
47 * End:
48 */
49
diff --git a/arch/um/include/sysdep-x86_64/signal.h b/arch/um/include/sysdep-x86_64/signal.h
new file mode 100644
index 000000000000..e5e52756fab4
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/signal.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) 2004 PathScale, Inc
3 * Licensed under the GPL
4 */
5
6#ifndef __X86_64_SIGNAL_H_
7#define __X86_64_SIGNAL_H_
8
9#define ARCH_GET_SIGCONTEXT(sc, sig_addr) \
10 do { \
11 struct ucontext *__uc; \
12 asm("movq %%rdx, %0" : "=r" (__uc)); \
13 sc = (struct sigcontext *) &__uc->uc_mcontext; \
14 } while(0)
15
16#endif
17
18/*
19 * Overrides for Emacs so that we follow Linus's tabbing style.
20 * Emacs will notice this stuff at the end of the file and automatically
21 * adjust the settings for this buffer only. This must remain at the end
22 * of the file.
23 * ---------------------------------------------------------------------------
24 * Local variables:
25 * c-file-style: "linux"
26 * End:
27 */
diff --git a/arch/um/include/sysdep-x86_64/syscalls.h b/arch/um/include/sysdep-x86_64/syscalls.h
new file mode 100644
index 000000000000..b187a4157ff3
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/syscalls.h
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_SYSCALLS_H__
8#define __SYSDEP_X86_64_SYSCALLS_H__
9
10#include <linux/msg.h>
11#include <linux/shm.h>
12
13typedef long syscall_handler_t(void);
14
15extern syscall_handler_t *ia32_sys_call_table[];
16
17#define EXECUTE_SYSCALL(syscall, regs) \
18 (((long (*)(long, long, long, long, long, long)) \
19 (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(&regs->regs), \
20 UPT_SYSCALL_ARG2(&regs->regs), \
21 UPT_SYSCALL_ARG3(&regs->regs), \
22 UPT_SYSCALL_ARG4(&regs->regs), \
23 UPT_SYSCALL_ARG5(&regs->regs), \
24 UPT_SYSCALL_ARG6(&regs->regs)))
25
26extern long old_mmap(unsigned long addr, unsigned long len,
27 unsigned long prot, unsigned long flags,
28 unsigned long fd, unsigned long pgoff);
29extern syscall_handler_t wrap_sys_shmat;
30extern syscall_handler_t sys_modify_ldt;
31extern syscall_handler_t sys_arch_prctl;
32
33#define ARCH_SYSCALLS \
34 [ __NR_mmap ] = (syscall_handler_t *) old_mmap, \
35 [ __NR_select ] = (syscall_handler_t *) sys_select, \
36 [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
37 [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
38 [ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \
39 [ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \
40 [ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \
41 [ __NR_semop ] = (syscall_handler_t *) sys_semop, \
42 [ __NR_semget ] = (syscall_handler_t *) sys_semget, \
43 [ __NR_semctl ] = (syscall_handler_t *) sys_semctl, \
44 [ __NR_shmdt ] = (syscall_handler_t *) sys_shmdt, \
45 [ __NR_msgget ] = (syscall_handler_t *) sys_msgget, \
46 [ __NR_msgsnd ] = (syscall_handler_t *) sys_msgsnd, \
47 [ __NR_msgrcv ] = (syscall_handler_t *) sys_msgrcv, \
48 [ __NR_msgctl ] = (syscall_handler_t *) sys_msgctl, \
49 [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
50 [ __NR_tuxcall ] = (syscall_handler_t *) sys_ni_syscall, \
51 [ __NR_security ] = (syscall_handler_t *) sys_ni_syscall, \
52 [ __NR_epoll_ctl_old ] = (syscall_handler_t *) sys_ni_syscall, \
53 [ __NR_epoll_wait_old ] = (syscall_handler_t *) sys_ni_syscall, \
54 [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
55 [ __NR_arch_prctl ] = (syscall_handler_t *) sys_arch_prctl, \
56 [ __NR_socket ] = (syscall_handler_t *) sys_socket, \
57 [ __NR_connect ] = (syscall_handler_t *) sys_connect, \
58 [ __NR_accept ] = (syscall_handler_t *) sys_accept, \
59 [ __NR_recvfrom ] = (syscall_handler_t *) sys_recvfrom, \
60 [ __NR_recvmsg ] = (syscall_handler_t *) sys_recvmsg, \
61 [ __NR_sendmsg ] = (syscall_handler_t *) sys_sendmsg, \
62 [ __NR_bind ] = (syscall_handler_t *) sys_bind, \
63 [ __NR_listen ] = (syscall_handler_t *) sys_listen, \
64 [ __NR_getsockname ] = (syscall_handler_t *) sys_getsockname, \
65 [ __NR_getpeername ] = (syscall_handler_t *) sys_getpeername, \
66 [ __NR_socketpair ] = (syscall_handler_t *) sys_socketpair, \
67 [ __NR_sendto ] = (syscall_handler_t *) sys_sendto, \
68 [ __NR_shutdown ] = (syscall_handler_t *) sys_shutdown, \
69 [ __NR_setsockopt ] = (syscall_handler_t *) sys_setsockopt, \
70 [ __NR_getsockopt ] = (syscall_handler_t *) sys_getsockopt, \
71 [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
72 [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
73 [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
74 [ __NR_semtimedop ] = (syscall_handler_t *) sys_semtimedop, \
75 [ 251 ] = (syscall_handler_t *) sys_ni_syscall,
76
77#define LAST_ARCH_SYSCALL 251
78#define NR_syscalls 1024
79
80#endif
81
82/*
83 * Overrides for Emacs so that we follow Linus's tabbing style.
84 * Emacs will notice this stuff at the end of the file and automatically
85 * adjust the settings for this buffer only. This must remain at the end
86 * of the file.
87 * ---------------------------------------------------------------------------
88 * Local variables:
89 * c-file-style: "linux"
90 * End:
91 */