mcontext.h revision 1.1 1 /* $NetBSD: mcontext.h,v 1.1 2003/04/26 18:39:44 fvdl Exp $ */
2
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _AMD64_MCONTEXT_H_
40 #define _AMD64_MCONTEXT_H_
41
42 /*
43 * Layout of mcontext_t according to the System V Application Binary Interface,
44 * Intel386(tm) Architecture Processor Supplement, Fourth Edition.
45 */
46
47 /*
48 * General register state
49 */
50 #define _NGREG 26
51 typedef long __greg_t;
52 typedef __greg_t __gregset_t[_NGREG];
53
54 /*
55 * This is laid out to match trapframe and intrframe (see <machine/frame.h>).
56 * Hence, memcpy between gregs and a trapframe is possible.
57 */
58 #define _REG_RDI 0
59 #define _REG_RSI 1
60 #define _REG_RDX 2
61 #define _REG_RCX 3
62 #define _REG_R8 4
63 #define _REG_R9 5
64 #define _REG_R10 6
65 #define _REG_R11 7
66 #define _REG_R12 8
67 #define _REG_R13 9
68 #define _REG_R14 10
69 #define _REG_R15 11
70 #define _REG_RBP 12
71 #define _REG_RBX 13
72 #define _REG_RAX 14
73 #define _REG_GS 15
74 #define _REG_FS 16
75 #define _REG_ES 17
76 #define _REG_DS 18
77 #define _REG_TRAPNO 19
78 #define _REG_ERR 20
79 #define _REG_RIP 21
80 #define _REG_CS 22
81 #define _REG_RFL 23
82 #define _REG_URSP 24
83 #define _REG_SS 25
84
85 /*
86 * Floating point register state
87 */
88 typedef char __fpregset_t[512];
89
90 /*
91 * The padding below is to make __fpregs have a 16-byte aligned offset
92 * within ucontext_t.
93 */
94
95 typedef struct {
96 __gregset_t __gregs;
97 long __pad;
98 __fpregset_t __fpregs;
99 } mcontext_t;
100
101 #define _UC_UCONTEXT_ALIGN (~0xf)
102
103 #ifdef _KERNEL
104 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_URSP])
105 #endif
106
107 #endif /* !_AMD64_MCONTEXT_H_ */
108