2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _I386_THREAD_ACT_H_
27 #define _I386_THREAD_ACT_H_
29 #include <mach/boolean.h>
30 #include <mach/i386/vm_types.h>
31 #include <mach/i386/fp_reg.h>
32 #include <mach/thread_status.h>
34 #include <kern/lock.h>
36 #include <i386/iopb.h>
38 #include <i386/eflags.h>
43 * Has been exported to servers. See: mach/i386/thread_status.h
45 * This structure corresponds to the state of user registers
46 * as saved upon kernel entry. It lives in the pcb.
47 * It is also pushed onto the stack for exceptions in the kernel.
48 * For performance, it is also used directly in syscall exceptions
49 * if the server has requested i386_THREAD_STATE flavor for the exception
52 * We define the following as an alias for the "esp" field of the
53 * structure, because we actually save cr2 here, not the kernel esp.
58 * Save area for user floating-point state.
59 * Allocated only when necessary.
62 struct i386_fpsave_state
{
64 struct i386_fp_save fp_save_state
;
65 struct i386_fp_regs fp_regs
;
71 * This structure provides data to simulate 8086 mode
72 * interrupts. It lives in the pcb.
75 struct v86_assist_state
{
76 vm_offset_t int_table
;
77 unsigned short int_count
;
78 unsigned short flags
; /* 8086 flag bits */
80 #define V86_IF_PENDING 0x8000 /* unused bit */
83 * i386_interrupt_state:
85 * This structure describes the set of registers that must
86 * be pushed on the current ring-0 stack by an interrupt before
87 * we can switch to the interrupt stack.
90 struct i386_interrupt_state
{
104 * This structure corresponds to the state of kernel registers
105 * as saved in a context-switch. It lives at the base of the stack.
108 struct i386_kernel_state
{
109 int k_ebx
; /* kernel context */
118 * i386_machine_state:
120 * This structure corresponds to special machine state.
121 * It lives in the pcb. It is not saved by default.
124 struct i386_machine_state
{
126 struct user_ldt
* ldt
;
127 struct i386_fpsave_state
*ifps
;
128 struct v86_assist_state v86s
;
132 struct i386_interrupt_state iis
[2]; /* interrupt and NMI */
133 struct i386_saved_state iss
;
134 struct i386_machine_state ims
;
136 unsigned long cthread_self
; /* for use of cthread package */
138 decl_simple_lock_data(,lock
)
142 * Maps state flavor to number of words in the state:
144 extern unsigned int state_count
[];
147 #define USER_REGS(ThrAct) (&(ThrAct)->mact.pcb->iss)
149 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
152 #define is_user_thread(ThrAct) \
153 ((USER_REGS(ThrAct)->efl & EFL_VM) \
154 || ((USER_REGS(ThrAct)->cs & 0x03) != 0))
156 #define user_pc(ThrAct) (USER_REGS(ThrAct)->eip)
157 #define user_sp(ThrAct) (USER_REGS(ThrAct)->uesp)
159 #define syscall_emulation_sync(task) /* do nothing */
161 typedef struct MachineThrAct
{
163 * pointer to process control block
164 * (actual storage may as well be here, too)
169 } MachineThrAct
, *MachineThrAct_t
;
171 extern void *act_thread_csave(void);
172 extern void act_thread_catt(void *ctx
);
173 extern void act_thread_cfree(void *ctx
);
175 #define current_act_fast() (current_thread()->top_act)
176 #define current_act_slow() ((current_thread()) ? \
177 current_act_fast() : \
180 #define current_act() current_act_slow() /* JMM - til we find the culprit */
182 #endif /* _I386_THREAD_ACT_H_ */