blob: ca49be8ddd0c7160821a4d4db06f18346f52b195 [file] [log] [blame]
Al Viro8d0b9dc2005-05-05 16:15:23 -07001#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
Jeff Dike63ae2a92006-03-27 01:14:30 -08004#include <sys/poll.h>
Jeff Dike16dd07b2007-05-06 14:51:48 -07005#include <sys/mman.h>
Jeff Dike189872f2007-10-16 01:27:14 -07006#include <sys/user.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -07007#define __FRAME_OFFSETS
8#include <asm/ptrace.h>
Jeff Dikeba9950c2005-05-20 13:59:07 -07009#include <asm/types.h>
Al Viro8d0b9dc2005-05-05 16:15:23 -070010
11#define DEFINE(sym, val) \
Al Viro6582b7f2011-08-18 20:03:19 +010012 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
Al Viro8d0b9dc2005-05-05 16:15:23 -070013
Al Viroecba97d2005-09-28 22:27:23 +010014#define DEFINE_LONGS(sym, val) \
Al Viro6582b7f2011-08-18 20:03:19 +010015 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
Al Viroecba97d2005-09-28 22:27:23 +010016
Al Viro8d0b9dc2005-05-05 16:15:23 -070017void foo(void)
18{
Al Viro6582b7f2011-08-18 20:03:19 +010019#ifdef __i386__
20 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
21 DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
22
23 DEFINE(HOST_IP, EIP);
24 DEFINE(HOST_SP, UESP);
25 DEFINE(HOST_EFLAGS, EFL);
Al Viro3579a382011-08-18 20:10:09 +010026 DEFINE(HOST_AX, EAX);
27 DEFINE(HOST_BX, EBX);
28 DEFINE(HOST_CX, ECX);
29 DEFINE(HOST_DX, EDX);
30 DEFINE(HOST_SI, ESI);
31 DEFINE(HOST_DI, EDI);
32 DEFINE(HOST_BP, EBP);
Al Viro6582b7f2011-08-18 20:03:19 +010033 DEFINE(HOST_CS, CS);
34 DEFINE(HOST_SS, SS);
35 DEFINE(HOST_DS, DS);
36 DEFINE(HOST_FS, FS);
37 DEFINE(HOST_ES, ES);
38 DEFINE(HOST_GS, GS);
Al Viro966e8032011-08-18 20:12:19 +010039 DEFINE(HOST_ORIG_AX, ORIG_EAX);
Al Viro6582b7f2011-08-18 20:03:19 +010040#else
Jeff Dikee2216fe2006-02-07 12:58:43 -080041 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
Al Viro3579a382011-08-18 20:10:09 +010042 DEFINE_LONGS(HOST_BX, RBX);
43 DEFINE_LONGS(HOST_CX, RCX);
44 DEFINE_LONGS(HOST_DI, RDI);
45 DEFINE_LONGS(HOST_SI, RSI);
46 DEFINE_LONGS(HOST_DX, RDX);
47 DEFINE_LONGS(HOST_BP, RBP);
48 DEFINE_LONGS(HOST_AX, RAX);
Al Viroecba97d2005-09-28 22:27:23 +010049 DEFINE_LONGS(HOST_R8, R8);
50 DEFINE_LONGS(HOST_R9, R9);
51 DEFINE_LONGS(HOST_R10, R10);
52 DEFINE_LONGS(HOST_R11, R11);
53 DEFINE_LONGS(HOST_R12, R12);
54 DEFINE_LONGS(HOST_R13, R13);
55 DEFINE_LONGS(HOST_R14, R14);
56 DEFINE_LONGS(HOST_R15, R15);
Al Viro966e8032011-08-18 20:12:19 +010057 DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
Al Viroecba97d2005-09-28 22:27:23 +010058 DEFINE_LONGS(HOST_CS, CS);
59 DEFINE_LONGS(HOST_SS, SS);
60 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
Al Viro8d0b9dc2005-05-05 16:15:23 -070061#if 0
Al Viroecba97d2005-09-28 22:27:23 +010062 DEFINE_LONGS(HOST_FS, FS);
63 DEFINE_LONGS(HOST_GS, GS);
64 DEFINE_LONGS(HOST_DS, DS);
65 DEFINE_LONGS(HOST_ES, ES);
Al Viro8d0b9dc2005-05-05 16:15:23 -070066#endif
67
Al Viroecba97d2005-09-28 22:27:23 +010068 DEFINE_LONGS(HOST_IP, RIP);
69 DEFINE_LONGS(HOST_SP, RSP);
Al Viro6582b7f2011-08-18 20:03:19 +010070#endif
Jeff Dike63ae2a92006-03-27 01:14:30 -080071
Al Viro6582b7f2011-08-18 20:03:19 +010072 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
Jeff Dike63ae2a92006-03-27 01:14:30 -080073 DEFINE(UM_POLLIN, POLLIN);
74 DEFINE(UM_POLLPRI, POLLPRI);
75 DEFINE(UM_POLLOUT, POLLOUT);
Jeff Dike16dd07b2007-05-06 14:51:48 -070076
77 DEFINE(UM_PROT_READ, PROT_READ);
78 DEFINE(UM_PROT_WRITE, PROT_WRITE);
79 DEFINE(UM_PROT_EXEC, PROT_EXEC);
Al Viro8d0b9dc2005-05-05 16:15:23 -070080}