master
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2003 Peter Wemm.
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 * from: @(#)frame.h 5.2 (Berkeley) 1/18/91
36 */
37
38#ifndef _MACHINE_FRAME_H_
39#define _MACHINE_FRAME_H_ 1
40
41/*
42 * System stack frames.
43 */
44
45#ifdef __i386__
46/*
47 * Exception/Trap Stack Frame
48 */
49
50struct trapframe {
51 int tf_fs;
52 int tf_es;
53 int tf_ds;
54 int tf_edi;
55 int tf_esi;
56 int tf_ebp;
57 int tf_isp;
58 int tf_ebx;
59 int tf_edx;
60 int tf_ecx;
61 int tf_eax;
62 int tf_trapno;
63 /* below portion defined in 386 hardware */
64 int tf_err;
65 int tf_eip;
66 int tf_cs;
67 int tf_eflags;
68 /* below only when crossing rings (user to kernel) */
69 int tf_esp;
70 int tf_ss;
71};
72
73/* Superset of trap frame, for traps from virtual-8086 mode */
74
75struct trapframe_vm86 {
76 int tf_fs;
77 int tf_es;
78 int tf_ds;
79 int tf_edi;
80 int tf_esi;
81 int tf_ebp;
82 int tf_isp;
83 int tf_ebx;
84 int tf_edx;
85 int tf_ecx;
86 int tf_eax;
87 int tf_trapno;
88 /* below portion defined in 386 hardware */
89 int tf_err;
90 int tf_eip;
91 int tf_cs;
92 int tf_eflags;
93 /* below only when crossing rings (user (including vm86) to kernel) */
94 int tf_esp;
95 int tf_ss;
96 /* below only when crossing from vm86 mode to kernel */
97 int tf_vm86_es;
98 int tf_vm86_ds;
99 int tf_vm86_fs;
100 int tf_vm86_gs;
101};
102
103/*
104 * This alias for the MI TRAPF_USERMODE() should be used when we don't
105 * care about user mode itself, but need to know if a frame has stack
106 * registers. The difference is only logical, but on i386 the logic
107 * for using TRAPF_USERMODE() is complicated by sometimes treating vm86
108 * bioscall mode (which is a special ring 3 user mode) as kernel mode.
109 */
110#define TF_HAS_STACKREGS(tf) TRAPF_USERMODE(tf)
111#endif /* __i386__ */
112
113#ifdef __amd64__
114/*
115 * Exception/Trap Stack Frame
116 *
117 * The ordering of this is specifically so that we can take first 6
118 * the syscall arguments directly from the beginning of the frame.
119 */
120
121struct trapframe {
122 register_t tf_rdi;
123 register_t tf_rsi;
124 register_t tf_rdx;
125 register_t tf_rcx;
126 register_t tf_r8;
127 register_t tf_r9;
128 register_t tf_rax;
129 register_t tf_rbx;
130 register_t tf_rbp;
131 register_t tf_r10;
132 register_t tf_r11;
133 register_t tf_r12;
134 register_t tf_r13;
135 register_t tf_r14;
136 register_t tf_r15;
137 uint32_t tf_trapno;
138 uint16_t tf_fs;
139 uint16_t tf_gs;
140 register_t tf_addr;
141 uint32_t tf_flags;
142 uint16_t tf_es;
143 uint16_t tf_ds;
144 /* below portion defined in hardware */
145 register_t tf_err;
146 register_t tf_rip;
147 register_t tf_cs;
148 register_t tf_rflags;
149 /* the amd64 frame always has the stack registers */
150 register_t tf_rsp;
151 register_t tf_ss;
152};
153
154#define TF_HASSEGS 0x1
155#define TF_HASBASES 0x2
156#define TF_HASFPXSTATE 0x4
157#endif /* __amd64__ */
158
159#endif /* _MACHINE_FRAME_H_ */