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>
39 #include <i386/eflags.h>
44 * Has been exported to servers. See: mach/i386/thread_status.h
46 * This structure corresponds to the state of user registers
47 * as saved upon kernel entry. It lives in the pcb.
48 * It is also pushed onto the stack for exceptions in the kernel.
49 * For performance, it is also used directly in syscall exceptions
50 * if the server has requested i386_THREAD_STATE flavor for the exception
53 * We define the following as an alias for the "esp" field of the
54 * structure, because we actually save cr2 here, not the kernel esp.
59 * Save area for user floating-point state.
60 * Allocated only when necessary.
63 struct i386_fpsave_state
{
65 struct i386_fp_save fp_save_state
;
66 struct i386_fp_regs fp_regs
;
67 struct i386_fx_save fx_save_state
__attribute__ ((aligned (16)));
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
{
109 * This structure corresponds to the state of kernel registers
110 * as saved in a context-switch. It lives at the base of the stack.
113 struct i386_kernel_state
{
114 int k_ebx
; /* kernel context */
123 * i386_machine_state:
125 * This structure corresponds to special machine state.
126 * It lives in the pcb. It is not saved by default.
129 struct i386_machine_state
{
131 struct user_ldt
* ldt
;
132 struct i386_fpsave_state
*ifps
;
133 struct v86_assist_state v86s
;
137 struct i386_interrupt_state iis
[2]; /* interrupt and NMI */
138 struct i386_saved_state iss
;
139 struct i386_machine_state ims
;
141 unsigned long cthread_self
; /* for use of cthread package */
142 struct real_descriptor cthread_desc
;
144 decl_simple_lock_data(,lock
)
148 * Maps state flavor to number of words in the state:
150 extern unsigned int state_count
[];
153 #define USER_REGS(ThrAct) (&(ThrAct)->mact.pcb->iss)
155 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
158 #define is_user_thread(ThrAct) \
159 ((USER_REGS(ThrAct)->efl & EFL_VM) \
160 || ((USER_REGS(ThrAct)->cs & 0x03) != 0))
162 #define user_pc(ThrAct) (USER_REGS(ThrAct)->eip)
163 #define user_sp(ThrAct) (USER_REGS(ThrAct)->uesp)
165 #define syscall_emulation_sync(task) /* do nothing */
167 typedef struct MachineThrAct
{
169 * pointer to process control block
170 * (actual storage may as well be here, too)
175 } MachineThrAct
, *MachineThrAct_t
;
177 extern void *act_thread_csave(void);
178 extern void act_thread_catt(void *ctx
);
179 extern void act_thread_cfree(void *ctx
);
181 extern vm_offset_t active_stacks
[NCPUS
];
182 extern vm_offset_t kernel_stack
[NCPUS
];
183 extern thread_act_t active_kloaded
[NCPUS
];
185 #endif /* _I386_THREAD_ACT_H_ */