initial commit
[glibc.git] / sysdeps / unix / bsd / bsd4.4 / kfreebsd / x86_64 / bits / mcontext.h
1 /* Machine-dependent processor state structure for FreeBSD.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. x86_64 version.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #if !defined _SYS_UCONTEXT_H
21 # error "Never use <bits/mcontext.h> directly; include <sys/ucontext.h> instead."
22 #endif
23
24 /*-
25 * Copyright (c) 2003 Peter Wemm
26 * Copyright (c) 1999 Marcel Moolenaar
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer
34 * in this position and unchanged.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. The name of the author may not be used to endorse or promote products
39 * derived from this software without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 *
52 * based on $FreeBSD: src/sys/amd64/include/ucontext.h,v 1.18 2003/11/08 04:39:22 peter Exp $
53 */
54
55 #ifdef __i386__
56
57 /* Whole processor state. */
58 typedef struct
59 {
60 /*
61 * The first 20 fields must match the definition of
62 * sigcontext. So that we can support sigcontext
63 * and ucontext_t at the same time.
64 */
65
66 int mc_onstack; /* Nonzero if running on sigstack. */
67
68 /* Segment registers. */
69 int mc_gs;
70 int mc_fs;
71 int mc_es;
72 int mc_ds;
73
74 /* "General" registers. These members are in the order that the i386
75 `pusha' and `popa' instructions use (`popa' ignores %esp). */
76 int mc_edi;
77 int mc_esi;
78 int mc_ebp;
79 int mc_isp; /* Not used; sc_esp is used instead. */
80 int mc_ebx;
81 int mc_edx;
82 int mc_ecx;
83 int mc_eax;
84
85 int mc_trapno;
86 int mc_err;
87
88 int mc_eip; /* Instruction pointer. */
89 int mc_cs; /* Code segment register. */
90
91 int mc_efl; /* Processor flags. */
92
93 int mc_esp; /* This stack pointer is used. */
94 int mc_ss; /* Stack segment register. */
95
96 int mc_len; /* sizeof(mcontext_t) */
97 #define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */
98 #define _MC_FPFMT_387 0x10001
99 #define _MC_FPFMT_XMM 0x10002
100 int mc_fpformat;
101 #define _MC_FPOWNED_NONE 0x20000 /* FP state not used */
102 #define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */
103 #define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */
104 int mc_ownedfp;
105 int mc_spare1[1]; /* align next field to 16 bytes */
106 /*
107 * See <machine/npx.h> for the internals of mc_fpstate[].
108 */
109 int mc_fpstate[128] __attribute__((aligned(16)));
110 int mc_spare2[8];
111 } mcontext_t;
112
113 #else
114
115 /* Whole processor state. */
116 typedef struct
117 {
118 /*
119 * The first 20 fields must match the definition of
120 * sigcontext. So that we can support sigcontext
121 * and ucontext_t at the same time.
122 */
123 long mc_onstack; /* XXX - sigcontext compat. */
124 long mc_rdi; /* machine state (struct trapframe) */
125 long mc_rsi;
126 long mc_rdx;
127 long mc_rcx;
128 long mc_r8;
129 long mc_r9;
130 long mc_rax;
131 long mc_rbx;
132 long mc_rbp;
133 long mc_r10;
134 long mc_r11;
135 long mc_r12;
136 long mc_r13;
137 long mc_r14;
138 long mc_r15;
139 long mc_trapno;
140 long mc_addr;
141 long mc_flags;
142 long mc_err;
143 long mc_rip;
144 long mc_cs;
145 long mc_rflags;
146 long mc_rsp;
147 long mc_ss;
148
149 long mc_len; /* sizeof(mcontext_t) */
150 #define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */
151 #define _MC_FPFMT_XMM 0x10002
152 long mc_fpformat;
153 #define _MC_FPOWNED_NONE 0x20000 /* FP state not used */
154 #define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */
155 #define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */
156 long mc_ownedfp;
157 /*
158 * See <machine/fpu.h> for the internals of mc_fpstate[].
159 */
160 long mc_fpstate[64] __attribute__((aligned(16)));
161 long mc_spare[8];
162 } mcontext_t;
163
164 #endif
165
166 /* Traditional BSD names for some members. */
167 #define mc_eflags mc_efl