2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2003 Peter Wemm.
5 * Copyright (c) 1990 The Regents of the University of California.
8 * This code is derived from software contributed to Berkeley by
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * from: @(#)reg.h 5.5 (Berkeley) 1/18/91
39 #ifndef _MACHINE_REG_H_
40 #define _MACHINE_REG_H_
42 #include <machine/_types.h>
46 * Indices for registers in `struct trapframe' and `struct regs'.
48 * This interface is deprecated. In the kernel, it is only used in FPU
49 * emulators to convert from register numbers encoded in instructions to
50 * register values. Everything else just accesses the relevant struct
51 * members. In userland, debuggers tend to abuse this interface since
52 * they don't understand that `struct regs' is a struct. I hope they have
53 * stopped accessing the registers in the trap frame via PT_{READ,WRITE}_U
54 * and we can stop supporting the user area soon.
75 * Indices for registers in `struct regs' only.
77 * Some registers live in the pcb and are only in an "array" with the
78 * other registers in application interfaces that copy all the registers
79 * to or from a `struct regs'.
84 /* Rename the structs below depending on the machine architecture. */
87 #define __fpreg32 fpreg
88 #define __dbreg32 dbreg
92 #define __fpreg32 fpreg32
93 #define __fpreg64 fpreg
94 #define __dbreg32 dbreg32
95 #define __dbreg64 dbreg
100 * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS.
154 * Register set accessible via /proc/$pid/fpregs.
156 * XXX should get struct from fpu.h. Here we give a slightly
157 * simplified struct. This may be too much detail. Perhaps
158 * an array of unsigned longs is best.
161 __uint32_t fpr_env[7];
162 __uint8_t fpr_acc[8][10];
163 __uint32_t fpr_ex_sw;
164 __uint8_t fpr_pad[64];
168 __uint64_t fpr_env[4];
169 __uint8_t fpr_acc[8][16];
170 __uint8_t fpr_xacc[16][16];
171 __uint64_t fpr_spare[12];
175 * Register set accessible via PT_GETXMMREGS (i386).
179 * XXX should get struct from npx.h. Here we give a slightly
180 * simplified struct. This may be too much detail. Perhaps
181 * an array of unsigned longs is best.
183 __uint32_t xmm_env[8];
184 __uint8_t xmm_acc[8][16];
185 __uint8_t xmm_reg[8][16];
186 __uint8_t xmm_pad[224];
190 * Register set accessible via /proc/$pid/dbregs.
193 __uint32_t dr[8]; /* debug registers */
194 /* Index 0-3: debug address registers */
195 /* Index 4-5: reserved */
196 /* Index 6: debug status */
197 /* Index 7: debug control */
201 __uint64_t dr[16]; /* debug registers */
202 /* Index 0-3: debug address registers */
203 /* Index 4-5: reserved */
204 /* Index 6: debug status */
205 /* Index 7: debug control */
206 /* Index 8-15: reserved */
209 #define DBREG_DR6_RESERVED1 0xffff0ff0
210 #define DBREG_DR6_BMASK 0x000f
211 #define DBREG_DR6_B(i) (1 << (i))
212 #define DBREG_DR6_BD 0x2000
213 #define DBREG_DR6_BS 0x4000
214 #define DBREG_DR6_BT 0x8000
216 #define DBREG_DR7_RESERVED1 0x0400
217 #define DBREG_DR7_LOCAL_ENABLE 0x01
218 #define DBREG_DR7_GLOBAL_ENABLE 0x02
219 #define DBREG_DR7_LEN_1 0x00 /* 1 byte length */
220 #define DBREG_DR7_LEN_2 0x01
221 #define DBREG_DR7_LEN_4 0x03
222 #define DBREG_DR7_LEN_8 0x02
223 #define DBREG_DR7_EXEC 0x00 /* break on execute */
224 #define DBREG_DR7_WRONLY 0x01 /* break on write */
225 #define DBREG_DR7_RDWR 0x03 /* break on read or write */
226 #define DBREG_DR7_MASK(i) \
227 ((__u_register_t)(0xf) << ((i) * 4 + 16) | 0x3 << (i) * 2)
228 #define DBREG_DR7_SET(i, len, access, enable) \
229 ((__u_register_t)((len) << 2 | (access)) << ((i) * 4 + 16) | \
231 #define DBREG_DR7_GD 0x2000
232 #define DBREG_DR7_ENABLED(d, i) (((d) & 0x3 << (i) * 2) != 0)
233 #define DBREG_DR7_ACCESS(d, i) ((d) >> ((i) * 4 + 16) & 0x3)
234 #define DBREG_DR7_LEN(d, i) ((d) >> ((i) * 4 + 18) & 0x3)
236 #define DBREG_DRX(d,x) ((d)->dr[(x)]) /* reference dr0 - dr7 by
250 * XXX these interfaces are MI, so they should be declared in a MI place.
252 int fill_regs(struct thread *, struct reg *);
253 int fill_frame_regs(struct trapframe *, struct reg *);
254 int set_regs(struct thread *, struct reg *);
255 int fill_fpregs(struct thread *, struct fpreg *);
256 int set_fpregs(struct thread *, struct fpreg *);
257 int fill_dbregs(struct thread *, struct dbreg *);
258 int set_dbregs(struct thread *, struct dbreg *);
259 #ifdef COMPAT_FREEBSD32
260 int fill_regs32(struct thread *, struct reg32 *);
261 int set_regs32(struct thread *, struct reg32 *);
262 int fill_fpregs32(struct thread *, struct fpreg32 *);
263 int set_fpregs32(struct thread *, struct fpreg32 *);
264 int fill_dbregs32(struct thread *, struct dbreg32 *);
265 int set_dbregs32(struct thread *, struct dbreg32 *);
269 #endif /* !_MACHINE_REG_H_ */