blob: fffd6b8cca23ea4b527315182746da68fee8b066 [file] [log] [blame]
Pavel Chupine61d1062014-01-27 17:56:43 +04001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _SYS_UCONTEXT_H_
30#define _SYS_UCONTEXT_H_
31
32#include <signal.h>
33#include <sys/user.h>
34
35__BEGIN_DECLS
36
Elliott Hughes677a07c2014-01-29 16:46:00 -080037#if defined(__arm__)
38
39#error TODO
40
41#elif defined(__arm64__)
42
43#error TODO
44
45#elif defined(__i386__)
46
47enum {
48 REG_GS = 0,
49 REG_FS,
50 REG_ES,
51 REG_DS,
52 REG_EDI,
53 REG_ESI,
54 REG_EBP,
55 REG_ESP,
56 REG_EBX,
57 REG_EDX,
58 REG_ECX,
59 REG_EAX,
60 REG_TRAPNO,
61 REG_ERR,
62 REG_EIP,
63 REG_CS,
64 REG_EFL,
65 REG_UESP,
66 REG_SS,
67 NGREG
68};
69
70typedef int greg_t;
71typedef greg_t gregset_t[NGREG];
72
73struct _libc_fpreg {
74 unsigned short significand[4];
75 unsigned short exponent;
76};
77
78struct _libc_fpstate {
79 unsigned long cw;
80 unsigned long sw;
81 unsigned long tag;
82 unsigned long ipoff;
83 unsigned long cssel;
84 unsigned long dataoff;
85 unsigned long datasel;
86 struct _libc_fpreg _st[8];
87 unsigned long status;
88};
89
90typedef struct _libc_fpstate* fpregset_t;
91
92typedef struct {
93 gregset_t gregs;
94 fpregset_t fpregs;
95 unsigned long oldmask;
96 unsigned long cr2;
97} mcontext_t;
98
99typedef struct ucontext {
100 unsigned long uc_flags;
101 struct ucontext* uc_link;
102 stack_t uc_stack;
103 mcontext_t uc_mcontext;
104 sigset_t uc_sigmask;
105 /* TODO: __fpregs_mem? */
106} ucontext_t;
107
108#elif defined(__mips__)
109
110#error TODO
111
112#elif defined(__mips64__)
113
114#error TODO
115
116#elif defined(__x86_64__)
Pavel Chupine61d1062014-01-27 17:56:43 +0400117
118enum {
119 REG_R8 = 0,
120 REG_R9,
121 REG_R10,
122 REG_R11,
123 REG_R12,
124 REG_R13,
125 REG_R14,
126 REG_R15,
127 REG_RDI,
128 REG_RSI,
129 REG_RBP,
130 REG_RBX,
131 REG_RDX,
132 REG_RAX,
133 REG_RCX,
134 REG_RSP,
135 REG_RIP,
136 REG_EFL,
137 REG_CSGSFS,
138 REG_ERR,
139 REG_TRAPNO,
140 REG_OLDMASK,
141 REG_CR2,
142 NGREG
143};
144
145typedef long greg_t;
146typedef greg_t gregset_t[NGREG];
147
148typedef struct user_i387_struct* fpregset_t;
149
150typedef struct {
151 gregset_t gregs;
152 fpregset_t fpregs;
153 /* TODO: reserved space? */
154} mcontext_t;
155
156typedef struct ucontext {
157 unsigned long uc_flags;
158 struct ucontext* uc_link;
159 stack_t uc_stack;
160 mcontext_t uc_mcontext;
161 sigset_t uc_sigmask;
162 /* TODO: __fpregs_mem? */
163} ucontext_t;
164
Elliott Hughes677a07c2014-01-29 16:46:00 -0800165#endif
Pavel Chupine61d1062014-01-27 17:56:43 +0400166
167__END_DECLS
168
169#endif /* _SYS_UCONTEXT_H_ */