2 * Copyright (c) 2003 Peter Wemm.
3 * Copyright (c) 1990 The Regents of the University of California.
6 * This code is derived from software contributed to Berkeley by
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * from: @(#)reg.h 5.5 (Berkeley) 1/18/91
37 #ifndef _MACHINE_REG_H_
38 #define _MACHINE_REG_H_
40 #include <machine/_types.h>
44 * Indices for registers in `struct trapframe' and `struct regs'.
46 * This interface is deprecated. In the kernel, it is only used in FPU
47 * emulators to convert from register numbers encoded in instructions to
48 * register values. Everything else just accesses the relevant struct
49 * members. In userland, debuggers tend to abuse this interface since
50 * they don't understand that `struct regs' is a struct. I hope they have
51 * stopped accessing the registers in the trap frame via PT_{READ,WRITE}_U
52 * and we can stop supporting the user area soon.
73 * Indices for registers in `struct regs' only.
75 * Some registers live in the pcb and are only in an "array" with the
76 * other registers in application interfaces that copy all the registers
77 * to or from a `struct regs'.
82 /* Rename the structs below depending on the machine architecture. */
85 #define __fpreg32 fpreg
86 #define __dbreg32 dbreg
90 #define __fpreg32 fpreg32
91 #define __fpreg64 fpreg
92 #define __dbreg32 dbreg32
93 #define __dbreg64 dbreg
98 * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS.
152 * Register set accessible via /proc/$pid/fpregs.
154 * XXX should get struct from fpu.h. Here we give a slightly
155 * simplified struct. This may be too much detail. Perhaps
156 * an array of unsigned longs is best.
159 __uint32_t fpr_env[7];
160 __uint8_t fpr_acc[8][10];
161 __uint32_t fpr_ex_sw;
162 __uint8_t fpr_pad[64];
166 __uint64_t fpr_env[4];
167 __uint8_t fpr_acc[8][16];
168 __uint8_t fpr_xacc[16][16];
169 __uint64_t fpr_spare[12];
173 * Register set accessible via PT_GETXMMREGS (i386).
177 * XXX should get struct from npx.h. Here we give a slightly
178 * simplified struct. This may be too much detail. Perhaps
179 * an array of unsigned longs is best.
181 __uint32_t xmm_env[8];
182 __uint8_t xmm_acc[8][16];
183 __uint8_t xmm_reg[8][16];
184 __uint8_t xmm_pad[224];
188 * Register set accessible via /proc/$pid/dbregs.
191 __uint32_t dr[8]; /* debug registers */
192 /* Index 0-3: debug address registers */
193 /* Index 4-5: reserved */
194 /* Index 6: debug status */
195 /* Index 7: debug control */
199 __uint64_t dr[16]; /* debug registers */
200 /* Index 0-3: debug address registers */
201 /* Index 4-5: reserved */
202 /* Index 6: debug status */
203 /* Index 7: debug control */
204 /* Index 8-15: reserved */
207 #define DBREG_DR7_LOCAL_ENABLE 0x01
208 #define DBREG_DR7_GLOBAL_ENABLE 0x02
209 #define DBREG_DR7_LEN_1 0x00 /* 1 byte length */
210 #define DBREG_DR7_LEN_2 0x01
211 #define DBREG_DR7_LEN_4 0x03
212 #define DBREG_DR7_LEN_8 0x02
213 #define DBREG_DR7_EXEC 0x00 /* break on execute */
214 #define DBREG_DR7_WRONLY 0x01 /* break on write */
215 #define DBREG_DR7_RDWR 0x03 /* break on read or write */
216 #define DBREG_DR7_MASK(i) \
217 ((__u_register_t)(0xf) << ((i) * 4 + 16) | 0x3 << (i) * 2)
218 #define DBREG_DR7_SET(i, len, access, enable) \
219 ((__u_register_t)((len) << 2 | (access)) << ((i) * 4 + 16) | \
221 #define DBREG_DR7_GD 0x2000
222 #define DBREG_DR7_ENABLED(d, i) (((d) & 0x3 << (i) * 2) != 0)
223 #define DBREG_DR7_ACCESS(d, i) ((d) >> ((i) * 4 + 16) & 0x3)
224 #define DBREG_DR7_LEN(d, i) ((d) >> ((i) * 4 + 18) & 0x3)
226 #define DBREG_DRX(d,x) ((d)->dr[(x)]) /* reference dr0 - dr7 by
238 * XXX these interfaces are MI, so they should be declared in a MI place.
240 int fill_regs(struct thread *, struct reg *);
241 int fill_frame_regs(struct trapframe *, struct reg *);
242 int set_regs(struct thread *, struct reg *);
243 int fill_fpregs(struct thread *, struct fpreg *);
244 int set_fpregs(struct thread *, struct fpreg *);
245 int fill_dbregs(struct thread *, struct dbreg *);
246 int set_dbregs(struct thread *, struct dbreg *);
247 #ifdef COMPAT_FREEBSD32
248 int fill_regs32(struct thread *, struct reg32 *);
249 int set_regs32(struct thread *, struct reg32 *);
250 int fill_fpregs32(struct thread *, struct fpreg32 *);
251 int set_fpregs32(struct thread *, struct fpreg32 *);
252 int fill_dbregs32(struct thread *, struct dbreg32 *);
253 int set_dbregs32(struct thread *, struct dbreg32 *);
257 #endif /* !_MACHINE_REG_H_ */