2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #ifndef _I386_THREAD_ACT_H_
30 #define _I386_THREAD_ACT_H_
32 #include <mach/boolean.h>
33 #include <mach/i386/vm_types.h>
34 #include <mach/i386/fp_reg.h>
35 #include <mach/thread_status.h>
37 #include <kern/lock.h>
39 #include <i386/iopb.h>
41 #include <i386/eflags.h>
46 * Has been exported to servers. See: mach/i386/thread_status.h
48 * This structure corresponds to the state of user registers
49 * as saved upon kernel entry. It lives in the pcb.
50 * It is also pushed onto the stack for exceptions in the kernel.
51 * For performance, it is also used directly in syscall exceptions
52 * if the server has requested i386_THREAD_STATE flavor for the exception
55 * We define the following as an alias for the "esp" field of the
56 * structure, because we actually save cr2 here, not the kernel esp.
61 * Save area for user floating-point state.
62 * Allocated only when necessary.
65 struct i386_fpsave_state
{
67 struct i386_fp_save fp_save_state
;
68 struct i386_fp_regs fp_regs
;
74 * This structure provides data to simulate 8086 mode
75 * interrupts. It lives in the pcb.
78 struct v86_assist_state
{
79 vm_offset_t int_table
;
80 unsigned short int_count
;
81 unsigned short flags
; /* 8086 flag bits */
83 #define V86_IF_PENDING 0x8000 /* unused bit */
86 * i386_interrupt_state:
88 * This structure describes the set of registers that must
89 * be pushed on the current ring-0 stack by an interrupt before
90 * we can switch to the interrupt stack.
93 struct i386_interrupt_state
{
107 * This structure corresponds to the state of kernel registers
108 * as saved in a context-switch. It lives at the base of the stack.
111 struct i386_kernel_state
{
112 int k_ebx
; /* kernel context */
121 * i386_machine_state:
123 * This structure corresponds to special machine state.
124 * It lives in the pcb. It is not saved by default.
127 struct i386_machine_state
{
129 struct user_ldt
* ldt
;
130 struct i386_fpsave_state
*ifps
;
131 struct v86_assist_state v86s
;
135 struct i386_interrupt_state iis
[2]; /* interrupt and NMI */
136 struct i386_saved_state iss
;
137 struct i386_machine_state ims
;
139 unsigned long cthread_self
; /* for use of cthread package */
141 decl_simple_lock_data(,lock
)
145 * Maps state flavor to number of words in the state:
147 extern unsigned int state_count
[];
150 #define USER_REGS(ThrAct) (&(ThrAct)->mact.pcb->iss)
152 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
155 #define is_user_thread(ThrAct) \
156 ((USER_REGS(ThrAct)->efl & EFL_VM) \
157 || ((USER_REGS(ThrAct)->cs & 0x03) != 0))
159 #define user_pc(ThrAct) (USER_REGS(ThrAct)->eip)
160 #define user_sp(ThrAct) (USER_REGS(ThrAct)->uesp)
162 #define syscall_emulation_sync(task) /* do nothing */
164 typedef struct MachineThrAct
{
166 * pointer to process control block
167 * (actual storage may as well be here, too)
172 } MachineThrAct
, *MachineThrAct_t
;
174 extern void *act_thread_csave(void);
175 extern void act_thread_catt(void *ctx
);
176 extern void act_thread_cfree(void *ctx
);
178 #define current_act_fast() (current_thread()->top_act)
179 #define current_act_slow() ((current_thread()) ? \
180 current_act_fast() : \
183 #define current_act() current_act_slow() /* JMM - til we find the culprit */
185 #endif /* _I386_THREAD_ACT_H_ */