xref: /freebsd/sys/x86/include/frame.h (revision bae28eaa8d26ddd67e9af51979f1a54599e9b3a8)
1 /*-
2  * Copyright (c) 2003 Peter Wemm.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * William Jolitz.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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  * 4. 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.
20  *
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
31  * SUCH DAMAGE.
32  *
33  *	from: @(#)frame.h	5.2 (Berkeley) 1/18/91
34  * $FreeBSD$
35  */
36 
37 #ifndef _MACHINE_FRAME_H_
38 #define _MACHINE_FRAME_H_ 1
39 
40 /*
41  * System stack frames.
42  */
43 
44 #ifdef __i386__
45 /*
46  * Exception/Trap Stack Frame
47  */
48 
49 struct trapframe {
50 	int	tf_fs;
51 	int	tf_es;
52 	int	tf_ds;
53 	int	tf_edi;
54 	int	tf_esi;
55 	int	tf_ebp;
56 	int	tf_isp;
57 	int	tf_ebx;
58 	int	tf_edx;
59 	int	tf_ecx;
60 	int	tf_eax;
61 	int	tf_trapno;
62 	/* below portion defined in 386 hardware */
63 	int	tf_err;
64 	int	tf_eip;
65 	int	tf_cs;
66 	int	tf_eflags;
67 	/* below only when crossing rings (e.g. user to kernel) */
68 	int	tf_esp;
69 	int	tf_ss;
70 };
71 
72 /* Superset of trap frame, for traps from virtual-8086 mode */
73 
74 struct trapframe_vm86 {
75 	int	tf_fs;
76 	int	tf_es;
77 	int	tf_ds;
78 	int	tf_edi;
79 	int	tf_esi;
80 	int	tf_ebp;
81 	int	tf_isp;
82 	int	tf_ebx;
83 	int	tf_edx;
84 	int	tf_ecx;
85 	int	tf_eax;
86 	int	tf_trapno;
87 	/* below portion defined in 386 hardware */
88 	int	tf_err;
89 	int	tf_eip;
90 	int	tf_cs;
91 	int	tf_eflags;
92 	/* below only when crossing rings (e.g. user to kernel) */
93 	int	tf_esp;
94 	int	tf_ss;
95 	/* below only when switching out of VM86 mode */
96 	int	tf_vm86_es;
97 	int	tf_vm86_ds;
98 	int	tf_vm86_fs;
99 	int	tf_vm86_gs;
100 };
101 #endif /* __i386__ */
102 
103 #ifdef __amd64__
104 /*
105  * Exception/Trap Stack Frame
106  *
107  * The ordering of this is specifically so that we can take first 6
108  * the syscall arguments directly from the beginning of the frame.
109  */
110 
111 struct trapframe {
112 	register_t	tf_rdi;
113 	register_t	tf_rsi;
114 	register_t	tf_rdx;
115 	register_t	tf_rcx;
116 	register_t	tf_r8;
117 	register_t	tf_r9;
118 	register_t	tf_rax;
119 	register_t	tf_rbx;
120 	register_t	tf_rbp;
121 	register_t	tf_r10;
122 	register_t	tf_r11;
123 	register_t	tf_r12;
124 	register_t	tf_r13;
125 	register_t	tf_r14;
126 	register_t	tf_r15;
127 	uint32_t	tf_trapno;
128 	uint16_t	tf_fs;
129 	uint16_t	tf_gs;
130 	register_t	tf_addr;
131 	uint32_t	tf_flags;
132 	uint16_t	tf_es;
133 	uint16_t	tf_ds;
134 	/* below portion defined in hardware */
135 	register_t	tf_err;
136 	register_t	tf_rip;
137 	register_t	tf_cs;
138 	register_t	tf_rflags;
139 	register_t	tf_rsp;
140 	register_t	tf_ss;
141 };
142 
143 #define	TF_HASSEGS	0x1
144 #define	TF_HASBASES	0x2
145 #define	TF_HASFPXSTATE	0x4
146 #endif /* __amd64__ */
147 
148 #endif /* _MACHINE_FRAME_H_ */
149