FreeBSD/Linux Kernel Cross Reference
sys/i386/thread.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: thread.h,v $
29 * Revision 2.12 93/11/17 16:39:59 dbg
30 * Added INTERRUPTED_PC for pc sampling.
31 * [93/10/14 dbg]
32 *
33 * Revision 2.11 92/03/03 14:22:42 rpd
34 * Added dummy definition of syscall_emulation_sync.
35 * [92/03/03 rpd]
36 *
37 * Revision 2.10 92/01/03 20:09:15 dbg
38 * Add lock to PCB to govern separate state fields (e.g.
39 * floating-point status, io_tss, user_ldt).
40 * [91/11/01 dbg]
41 *
42 * Add user_ldt pointer to machine_state.
43 * [91/08/20 dbg]
44 *
45 * Revision 2.9 91/07/31 17:41:31 dbg
46 * Save user regs directly in PCB on trap, and switch to separate
47 * kernel stack.
48 *
49 * Add fields for v86 interrupt simulation.
50 * [91/07/30 16:58:18 dbg]
51 *
52 * Revision 2.8 91/05/14 16:17:39 mrt
53 * Correcting copyright
54 *
55 * Revision 2.7 91/05/08 12:43:08 dbg
56 * Change ktss to iopb_tss in pcb.
57 * [91/04/26 14:39:10 dbg]
58 *
59 * Revision 2.6 91/03/16 14:45:21 rpd
60 * Removed k_ipl from i386_kernel_state.
61 * [91/03/01 rpd]
62 *
63 * Pulled i386_fpsave_state out of i386_machine_state.
64 * [91/02/18 rpd]
65 *
66 * Renamed unused field in i386_saved_state to cr2.
67 * Removed switch_thread_context.
68 * [91/02/05 rpd]
69 *
70 * Revision 2.5 91/02/05 17:15:03 mrt
71 * Changed to new Mach copyright
72 * [91/02/01 17:38:28 mrt]
73 *
74 * Revision 2.4 91/01/09 22:41:49 rpd
75 * Added dummy switch_thread_context macro.
76 * Added ktss to i386_machine_state.
77 * Removed user_regs, k_stack_top.
78 * [91/01/09 rpd]
79 *
80 * Revision 2.3 91/01/08 15:11:12 rpd
81 * Added i386_machine_state.
82 * [91/01/03 22:05:01 rpd]
83 *
84 * Reorganized the pcb.
85 * [90/12/11 rpd]
86 *
87 * Revision 2.2 90/05/03 15:37:59 dbg
88 * Created.
89 * [90/02/08 dbg]
90 *
91 */
92
93 /*
94 * File: machine/thread.h
95 *
96 * This file contains the structure definitions for the thread
97 * state as applied to I386 processors.
98 */
99
100 #ifndef _I386_THREAD_H_
101 #define _I386_THREAD_H_
102
103 #include <mach/boolean.h>
104 #include <mach/i386/vm_types.h>
105 #include <mach/i386/fp_reg.h>
106
107 #include <kern/lock.h>
108
109 #include <i386/iopb.h>
110 #include <i386/tss.h>
111
112 /*
113 * i386_saved_state:
114 *
115 * This structure corresponds to the state of user registers
116 * as saved upon kernel entry. It lives in the pcb.
117 * It is also pushed onto the stack for exceptions in the kernel.
118 */
119
120 struct i386_saved_state {
121 unsigned int gs;
122 unsigned int fs;
123 unsigned int es;
124 unsigned int ds;
125 unsigned int edi;
126 unsigned int esi;
127 unsigned int ebp;
128 unsigned int cr2; /* kernel esp stored by pusha -
129 we save cr2 here later */
130 unsigned int ebx;
131 unsigned int edx;
132 unsigned int ecx;
133 unsigned int eax;
134 unsigned int trapno;
135 unsigned int err;
136 unsigned int eip;
137 unsigned int cs;
138 unsigned int efl;
139 unsigned int uesp;
140 unsigned int ss;
141 struct v86_segs {
142 unsigned int v86_es; /* virtual 8086 segment registers */
143 unsigned int v86_ds;
144 unsigned int v86_fs;
145 unsigned int v86_gs;
146 } v86_segs;
147 };
148
149 /*
150 * i386_exception_link:
151 *
152 * This structure lives at the high end of the kernel stack.
153 * It points to the current thread`s user registers.
154 */
155 struct i386_exception_link {
156 struct i386_saved_state *saved_state;
157 };
158
159 /*
160 * i386_kernel_state:
161 *
162 * This structure corresponds to the state of kernel registers
163 * as saved in a context-switch. It lives at the base of the stack.
164 */
165
166 struct i386_kernel_state {
167 int k_ebx; /* kernel context */
168 int k_esp;
169 int k_ebp;
170 int k_edi;
171 int k_esi;
172 int k_eip;
173 };
174
175 /*
176 * Save area for user floating-point state.
177 * Allocated only when necessary.
178 */
179
180 struct i386_fpsave_state {
181 boolean_t fp_valid;
182 struct i386_fp_save fp_save_state;
183 struct i386_fp_regs fp_regs;
184 };
185
186 /*
187 * v86_assist_state:
188 *
189 * This structure provides data to simulate 8086 mode
190 * interrupts. It lives in the pcb.
191 */
192
193 struct v86_assist_state {
194 vm_offset_t int_table;
195 unsigned short int_count;
196 unsigned short flags; /* 8086 flag bits */
197 };
198 #define V86_IF_PENDING 0x8000 /* unused bit */
199
200 /*
201 * i386_interrupt_state:
202 *
203 * This structure describes the set of registers that must
204 * be pushed on the current ring-0 stack by an interrupt before
205 * we can switch to the interrupt stack.
206 */
207
208 struct i386_interrupt_state {
209 int es;
210 int ds;
211 int edx;
212 int ecx;
213 int eax;
214 int eip;
215 int cs;
216 int efl;
217 };
218
219 /*
220 * i386_machine_state:
221 *
222 * This structure corresponds to special machine state.
223 * It lives in the pcb. It is not saved by default.
224 */
225
226 struct i386_machine_state {
227 iopb_tss_t io_tss;
228 struct user_ldt * ldt;
229 struct i386_fpsave_state *ifps;
230 struct v86_assist_state v86s;
231 };
232
233 typedef struct pcb {
234 struct i386_interrupt_state iis[2]; /* interrupt and NMI */
235 struct i386_saved_state iss;
236 struct i386_machine_state ims;
237 decl_simple_lock_data(, lock)
238 } *pcb_t;
239
240 /*
241 * On the kernel stack is:
242 * stack: ...
243 * struct i386_exception_link
244 * struct i386_kernel_state
245 * stack+KERNEL_STACK_SIZE
246 */
247
248 #define STACK_IKS(stack) \
249 ((struct i386_kernel_state *)((stack) + KERNEL_STACK_SIZE) - 1)
250 #define STACK_IEL(stack) \
251 ((struct i386_exception_link *)STACK_IKS(stack) - 1)
252
253 #define USER_REGS(thread) (&(thread)->pcb->iss)
254
255 #define INTERRUPTED_PC(thread) (USER_REGS(thread)->eip)
256
257 #define syscall_emulation_sync(task) /* do nothing */
258
259 #endif /* _I386_THREAD_H_ */
Cache object: 5f99cb97217977f68a7a1cf960c51941
|