1/* $OpenBSD: reg.h,v 1.7 2019/07/14 05:08:26 guenther Exp $ */
2/* $NetBSD: reg.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
3
4/*-
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
22 *
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
33 * SUCH DAMAGE.
34 *
35 * @(#)reg.h 5.5 (Berkeley) 1/18/91
36 */
37
38#ifndef _MACHINE_REG_H_
39#define _MACHINE_REG_H_
40
41#include <machine/fpu.h>
42
43/*
44 * XXX
45 * The #defines aren't used in the kernel, but some user-level code still
46 * expects them.
47 */
48
49/* When referenced during a trap/exception, registers are at these offsets */
50
51#define tRDI 0
52#define tRSI 1
53#define tRDX 2
54#define tRCX 3
55#define tR8 4
56#define tR9 5
57#define tR10 6
58#define tR11 7
59#define tR12 8
60#define tR13 9
61#define tR14 10
62#define tR15 11
63#define tRBP 12
64#define tRBX 13
65#define tRAX 14
66#define tRSP 15
67#define tRIP 16
68#define tRFLAGS 17
69#define tCS 18
70#define tSS 19
71#define tDS 20
72#define tES 21
73#define tFS 22
74#define tGS 23
75
76/*
77 * Registers accessible to ptrace(2) syscall for debugger use.
78 */
79struct reg {
80 int64_t r_rdi;
81 int64_t r_rsi;
82 int64_t r_rdx;
83 int64_t r_rcx;
84 int64_t r_r8;
85 int64_t r_r9;
86 int64_t r_r10;
87 int64_t r_r11;
88 int64_t r_r12;
89 int64_t r_r13;
90 int64_t r_r14;
91 int64_t r_r15;
92 int64_t r_rbp;
93 int64_t r_rbx;
94 int64_t r_rax;
95 int64_t r_rsp;
96 int64_t r_rip;
97 int64_t r_rflags;
98 int64_t r_cs;
99 int64_t r_ss;
100 int64_t r_ds;
101 int64_t r_es;
102 int64_t r_fs;
103 int64_t r_gs;
104};
105
106struct fpreg {
107 struct fxsave64 fxstate;
108};
109
110#define fp_fcw fxstate.fx_fcw
111#define fp_fsw fxstate.fx_fsw
112#define fp_ftw fxstate.fx_ftw
113#define fp_fop fxstate.fx_fop
114#define fp_rip fxstate.fx_rip
115#define fp_rdp fxstate.fx_rdp
116#define fp_mxcsr fxstate.fx_mxcsr
117#define fp_mxcsr_mask fxstate.fx_mxcsr_mask
118#define fp_st fxstate.fx_st
119#define fp_xmm fxstate.fx_xmm
120
121#ifdef _KERNEL
122int check_context(const struct reg *, struct trapframe *);
123#endif
124
125#endif /* !_MACHINE_REG_H_ */