blob: 94b7a6806587e7b73e616eaee84d6c1a82d0274f [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
Elliott Hughes4e72fcc2014-01-29 17:53:59 -080039enum {
40 REG_R0 = 0,
41 REG_R1,
42 REG_R2,
43 REG_R3,
44 REG_R4,
45 REG_R5,
46 REG_R6,
47 REG_R7,
48 REG_R8,
49 REG_R9,
50 REG_R10,
51 REG_R11,
52 REG_R12,
53 REG_R13,
54 REG_R14,
55 REG_R15,
56};
57
58#define NGREG 18 /* Like glibc. */
59
60typedef int greg_t;
61typedef greg_t gregset_t[NGREG];
62
63/* TODO: fpregset_t. */
64
65#include <asm/sigcontext.h>
66typedef struct sigcontext mcontext_t;
67
68typedef struct ucontext {
69 unsigned long uc_flags;
70 struct ucontext* uc_link;
71 stack_t uc_stack;
72 mcontext_t uc_mcontext;
73 sigset_t uc_sigmask;
74 /* TODO: uc_regspace */
75} ucontext_t;
Elliott Hughes677a07c2014-01-29 16:46:00 -080076
Ross McIlroy7b958072014-01-31 04:45:53 +000077#elif defined(__aarch64__)
Elliott Hughes677a07c2014-01-29 16:46:00 -080078
Ross McIlroy7b958072014-01-31 04:45:53 +000079/* TODO: gregset_t and fpregset_t. */
80
81#include <asm/sigcontext.h>
82typedef struct sigcontext mcontext_t;
83
84typedef struct ucontext {
85 unsigned long uc_flags;
86 struct ucontext *uc_link;
87 stack_t uc_stack;
88 sigset_t uc_sigmask;
89 mcontext_t uc_mcontext;
90} ucontext_t;
Elliott Hughes677a07c2014-01-29 16:46:00 -080091
92#elif defined(__i386__)
93
94enum {
95 REG_GS = 0,
96 REG_FS,
97 REG_ES,
98 REG_DS,
99 REG_EDI,
100 REG_ESI,
101 REG_EBP,
102 REG_ESP,
103 REG_EBX,
104 REG_EDX,
105 REG_ECX,
106 REG_EAX,
107 REG_TRAPNO,
108 REG_ERR,
109 REG_EIP,
110 REG_CS,
111 REG_EFL,
112 REG_UESP,
113 REG_SS,
114 NGREG
115};
116
117typedef int greg_t;
118typedef greg_t gregset_t[NGREG];
119
120struct _libc_fpreg {
121 unsigned short significand[4];
122 unsigned short exponent;
123};
124
125struct _libc_fpstate {
126 unsigned long cw;
127 unsigned long sw;
128 unsigned long tag;
129 unsigned long ipoff;
130 unsigned long cssel;
131 unsigned long dataoff;
132 unsigned long datasel;
133 struct _libc_fpreg _st[8];
134 unsigned long status;
135};
136
137typedef struct _libc_fpstate* fpregset_t;
138
139typedef struct {
140 gregset_t gregs;
141 fpregset_t fpregs;
142 unsigned long oldmask;
143 unsigned long cr2;
144} mcontext_t;
145
146typedef struct ucontext {
147 unsigned long uc_flags;
148 struct ucontext* uc_link;
149 stack_t uc_stack;
150 mcontext_t uc_mcontext;
151 sigset_t uc_sigmask;
152 /* TODO: __fpregs_mem? */
153} ucontext_t;
154
155#elif defined(__mips__)
156
Elliott Hughes02c661b2014-01-29 18:37:15 -0800157/* glibc doesn't have names for MIPS registers. */
158
159#define NGREG 32
160#define NFPREG 32
161
162typedef unsigned long long greg_t;
163typedef greg_t gregset_t[NGREG];
164
165typedef struct fpregset {
166 union {
167 double fp_dregs[NFPREG];
168 struct {
169 float _fp_fregs;
170 unsigned _fp_pad;
171 } fp_fregs[NFPREG];
172 } fp_r;
173} fpregset_t;
174
175typedef struct {
176 unsigned regmask;
177 unsigned status;
178 greg_t pc;
179 gregset_t gregs;
180 fpregset_t fpregs;
181 unsigned fp_owned;
182 unsigned fpc_csr;
183 unsigned fpc_eir;
184 unsigned used_math;
185 unsigned dsp;
186 greg_t mdhi;
187 greg_t mdlo;
188 unsigned long hi1;
189 unsigned long lo1;
190 unsigned long hi2;
191 unsigned long lo2;
192 unsigned long hi3;
193 unsigned long lo3;
194} mcontext_t;
195
196typedef struct ucontext {
197 unsigned long uc_flags;
198 struct ucontext* uc_link;
199 stack_t uc_stack;
200 mcontext_t uc_mcontext;
201 sigset_t uc_sigmask;
202} ucontext_t;
Elliott Hughes677a07c2014-01-29 16:46:00 -0800203
204#elif defined(__mips64__)
205
206#error TODO
207
208#elif defined(__x86_64__)
Pavel Chupine61d1062014-01-27 17:56:43 +0400209
210enum {
211 REG_R8 = 0,
212 REG_R9,
213 REG_R10,
214 REG_R11,
215 REG_R12,
216 REG_R13,
217 REG_R14,
218 REG_R15,
219 REG_RDI,
220 REG_RSI,
221 REG_RBP,
222 REG_RBX,
223 REG_RDX,
224 REG_RAX,
225 REG_RCX,
226 REG_RSP,
227 REG_RIP,
228 REG_EFL,
229 REG_CSGSFS,
230 REG_ERR,
231 REG_TRAPNO,
232 REG_OLDMASK,
233 REG_CR2,
234 NGREG
235};
236
237typedef long greg_t;
238typedef greg_t gregset_t[NGREG];
239
240typedef struct user_i387_struct* fpregset_t;
241
242typedef struct {
243 gregset_t gregs;
244 fpregset_t fpregs;
245 /* TODO: reserved space? */
246} mcontext_t;
247
248typedef struct ucontext {
249 unsigned long uc_flags;
250 struct ucontext* uc_link;
251 stack_t uc_stack;
252 mcontext_t uc_mcontext;
253 sigset_t uc_sigmask;
254 /* TODO: __fpregs_mem? */
255} ucontext_t;
256
Elliott Hughes677a07c2014-01-29 16:46:00 -0800257#endif
Pavel Chupine61d1062014-01-27 17:56:43 +0400258
259__END_DECLS
260
261#endif /* _SYS_UCONTEXT_H_ */