]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/thread.h
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 * Mach Operating System
27 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
54 * File: machine/thread.h
56 * This file contains the structure definitions for the thread
57 * state as applied to I386 processors.
60 #ifndef _I386_THREAD_H_
61 #define _I386_THREAD_H_
63 #include <mach/boolean.h>
64 #include <mach/i386/vm_types.h>
65 #include <mach/i386/fp_reg.h>
67 #include <kern/lock.h>
69 #include <i386/iopb.h>
72 #include <i386/eflags.h>
73 #include <i386/thread_act.h>
76 * i386_exception_link:
78 * This structure lives at the high end of the kernel stack.
79 * It points to the current thread`s user registers.
81 struct i386_exception_link
{
82 struct i386_saved_state
*saved_state
;
87 * On the kernel stack is:
89 * struct i386_exception_link
90 * struct i386_kernel_state
91 * stack+KERNEL_STACK_SIZE
94 #define STACK_IKS(stack) \
95 ((struct i386_kernel_state *)((stack) + KERNEL_STACK_SIZE) - 1)
96 #define STACK_IEL(stack) \
97 ((struct i386_exception_link *)STACK_IKS(stack) - 1)
100 #include <i386/mp_desc.h>
104 * Boot-time data for master (or only) CPU
106 extern struct fake_descriptor idt
[IDTSZ
];
107 extern struct fake_descriptor gdt
[GDTSZ
];
108 extern struct fake_descriptor ldt
[LDTSZ
];
109 extern struct i386_tss ktss
;
111 extern char db_stack_store
[];
112 extern char db_task_stack_store
[];
113 extern struct i386_tss dbtss
;
114 extern void db_task_start(void);
115 #endif /* MACH_KDB */
117 #define curr_gdt(mycpu) (mp_gdt[mycpu])
118 #define curr_ktss(mycpu) (mp_ktss[mycpu])
120 #define curr_gdt(mycpu) (gdt)
121 #define curr_ktss(mycpu) (&ktss)
124 #define gdt_desc_p(mycpu,sel) \
125 ((struct real_descriptor *)&curr_gdt(mycpu)[sel_idx(sel)])
128 * Return address of the function that called current function, given
129 * address of the first parameter of current function.
131 #define GET_RETURN_PC(addr) (*((vm_offset_t *)addr - 1))
134 * Defining this indicates that MD code will supply an exception()
135 * routine, conformant with kern/exception.c (dependency alert!)
136 * but which does wonderfully fast, machine-dependent magic.
138 #define MACHINE_FAST_EXCEPTION 1
141 * MD Macro to fill up global stack state,
142 * keeping the MD structure sizes + games private
144 #define MACHINE_STACK_STASH(stack) \
146 mp_disable_preemption(); \
147 kernel_stack[cpu_number()] = (stack) + \
148 (KERNEL_STACK_SIZE - sizeof (struct i386_exception_link) \
149 - sizeof (struct i386_kernel_state)), \
150 active_stacks[cpu_number()] = (stack); \
151 mp_enable_preemption(); \
154 #endif /* _I386_THREAD_H_ */