blob: d6c6b43172886f6a20736b64bc698a27a8f95fb7 [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
Elliott Hughes4e72fcc2014-01-29 17:53:59 -080063#include <asm/sigcontext.h>
64typedef struct sigcontext mcontext_t;
65
66typedef struct ucontext {
67 unsigned long uc_flags;
68 struct ucontext* uc_link;
69 stack_t uc_stack;
70 mcontext_t uc_mcontext;
71 sigset_t uc_sigmask;
Calin Juravle0e85fb62014-05-19 19:14:03 +010072 char __padding[128 - sizeof(sigset_t)];
73 unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
Elliott Hughes4e72fcc2014-01-29 17:53:59 -080074} ucontext_t;
Elliott Hughes677a07c2014-01-29 16:46:00 -080075
Ross McIlroy7b958072014-01-31 04:45:53 +000076#elif defined(__aarch64__)
Elliott Hughes677a07c2014-01-29 16:46:00 -080077
Ross McIlroy7b958072014-01-31 04:45:53 +000078#include <asm/sigcontext.h>
79typedef struct sigcontext mcontext_t;
80
81typedef struct ucontext {
82 unsigned long uc_flags;
83 struct ucontext *uc_link;
84 stack_t uc_stack;
85 sigset_t uc_sigmask;
Elliott Hughes50249bc2014-04-07 14:36:59 -070086 char __padding[128 - sizeof(sigset_t)];
Ross McIlroy7b958072014-01-31 04:45:53 +000087 mcontext_t uc_mcontext;
88} ucontext_t;
Elliott Hughes677a07c2014-01-29 16:46:00 -080089
90#elif defined(__i386__)
91
92enum {
93 REG_GS = 0,
94 REG_FS,
95 REG_ES,
96 REG_DS,
97 REG_EDI,
98 REG_ESI,
99 REG_EBP,
100 REG_ESP,
101 REG_EBX,
102 REG_EDX,
103 REG_ECX,
104 REG_EAX,
105 REG_TRAPNO,
106 REG_ERR,
107 REG_EIP,
108 REG_CS,
109 REG_EFL,
110 REG_UESP,
111 REG_SS,
112 NGREG
113};
114
115typedef int greg_t;
116typedef greg_t gregset_t[NGREG];
117
118struct _libc_fpreg {
119 unsigned short significand[4];
120 unsigned short exponent;
121};
122
123struct _libc_fpstate {
124 unsigned long cw;
125 unsigned long sw;
126 unsigned long tag;
127 unsigned long ipoff;
128 unsigned long cssel;
129 unsigned long dataoff;
130 unsigned long datasel;
131 struct _libc_fpreg _st[8];
132 unsigned long status;
133};
134
135typedef struct _libc_fpstate* fpregset_t;
136
137typedef struct {
138 gregset_t gregs;
139 fpregset_t fpregs;
140 unsigned long oldmask;
141 unsigned long cr2;
142} mcontext_t;
143
144typedef struct ucontext {
145 unsigned long uc_flags;
146 struct ucontext* uc_link;
147 stack_t uc_stack;
148 mcontext_t uc_mcontext;
149 sigset_t uc_sigmask;
Calin Juravlea6ab9682014-05-13 20:29:01 +0100150 char __padding[128 - sizeof(sigset_t)];
151 struct _libc_fpstate __fpregs_mem;
Elliott Hughes677a07c2014-01-29 16:46:00 -0800152} ucontext_t;
153
154#elif defined(__mips__)
155
Elliott Hughes02c661b2014-01-29 18:37:15 -0800156/* glibc doesn't have names for MIPS registers. */
157
158#define NGREG 32
159#define NFPREG 32
160
161typedef unsigned long long greg_t;
162typedef greg_t gregset_t[NGREG];
163
164typedef struct fpregset {
165 union {
166 double fp_dregs[NFPREG];
167 struct {
168 float _fp_fregs;
169 unsigned _fp_pad;
170 } fp_fregs[NFPREG];
171 } fp_r;
172} fpregset_t;
173
174typedef struct {
175 unsigned regmask;
176 unsigned status;
177 greg_t pc;
178 gregset_t gregs;
179 fpregset_t fpregs;
180 unsigned fp_owned;
181 unsigned fpc_csr;
182 unsigned fpc_eir;
183 unsigned used_math;
184 unsigned dsp;
185 greg_t mdhi;
186 greg_t mdlo;
187 unsigned long hi1;
188 unsigned long lo1;
189 unsigned long hi2;
190 unsigned long lo2;
191 unsigned long hi3;
192 unsigned long lo3;
193} mcontext_t;
194
195typedef struct ucontext {
196 unsigned long uc_flags;
197 struct ucontext* uc_link;
198 stack_t uc_stack;
199 mcontext_t uc_mcontext;
200 sigset_t uc_sigmask;
Calin Juravleae0f8f12014-05-20 16:53:15 +0100201 char __padding[128 - sizeof(sigset_t)];
Elliott Hughes02c661b2014-01-29 18:37:15 -0800202} 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
Calin Juravlea6ab9682014-05-13 20:29:01 +0100240struct _libc_fpxreg {
241 unsigned short significand[4];
242 unsigned short exponent;
243 unsigned short padding[3];
244};
245
246struct _libc_xmmreg {
247 uint32_t element[4];
248};
249
250struct _libc_fpstate {
251 uint16_t cwd;
252 uint16_t swd;
253 uint16_t ftw;
254 uint16_t fop;
255 uint64_t rip;
256 uint64_t rdp;
257 uint32_t mxcsr;
258 uint32_t mxcr_mask;
259 struct _libc_fpxreg _st[8];
260 struct _libc_xmmreg _xmm[16];
261 uint32_t padding[24];
262};
263
264typedef struct _libc_fpstate* fpregset_t;
Pavel Chupine61d1062014-01-27 17:56:43 +0400265
266typedef struct {
267 gregset_t gregs;
268 fpregset_t fpregs;
Elliott Hughesc5992a02014-04-09 13:27:48 -0700269 unsigned long __reserved1[8];
Pavel Chupine61d1062014-01-27 17:56:43 +0400270} mcontext_t;
271
272typedef struct ucontext {
273 unsigned long uc_flags;
274 struct ucontext* uc_link;
275 stack_t uc_stack;
276 mcontext_t uc_mcontext;
277 sigset_t uc_sigmask;
Calin Juravlea6ab9682014-05-13 20:29:01 +0100278 char __padding[128 - sizeof(sigset_t)];
279 struct _libc_fpstate __fpregs_mem;
Pavel Chupine61d1062014-01-27 17:56:43 +0400280} ucontext_t;
281
Elliott Hughes677a07c2014-01-29 16:46:00 -0800282#endif
Pavel Chupine61d1062014-01-27 17:56:43 +0400283
284__END_DECLS
285
286#endif /* _SYS_UCONTEXT_H_ */