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