]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/ktss.c
973fc395adf1a0b4b090845e8fc10fa45a6dc78b
[apple/xnu.git] / osfmk / i386 / ktss.c
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58
59 /*
60 * Kernel task state segment.
61 *
62 * We don't use the i386 task switch mechanism. We need a TSS
63 * only to hold the kernel stack pointer for the current thread.
64 */
65 #include <i386/tss.h>
66 #include <i386/pmap.h>
67 #include <mach_kdb.h>
68
69 #ifdef __i386__
70 struct i386_tss master_ktss
71 __attribute__ ((section ("__DESC, master_ktss")))
72 __attribute__ ((aligned (4096))) = {
73 0, /* back link */
74 0, /* esp0 */
75 KERNEL_DS, /* ss0 */
76 0, /* esp1 */
77 0, /* ss1 */
78 0, /* esp2 */
79 0, /* ss2 */
80 0, /* cr3 */
81 0, /* eip */
82 0, /* eflags */
83 0, /* eax */
84 0, /* ecx */
85 0, /* edx */
86 0, /* ebx */
87 0, /* esp */
88 0, /* ebp */
89 0, /* esi */
90 0, /* edi */
91 0, /* es */
92 0, /* cs */
93 0, /* ss */
94 0, /* ds */
95 0, /* fs */
96 0, /* gs */
97 KERNEL_LDT, /* ldt */
98 0, /* trace_trap */
99 0x0FFF /* IO bitmap offset -
100 beyond end of TSS segment,
101 so no bitmap */
102 };
103 #endif
104
105 /*
106 * The transient stack for sysenter.
107 * At its top is a 32-bit link to the PCB in legacy mode, 64-bit otherwise.
108 * NB: it also must be large enough to contain a interrupt stack frame
109 * due to a single-step trace trap at system call entry.
110 */
111 struct sysenter_stack master_sstk
112 __attribute__ ((section ("__DESC, master_sstk")))
113 __attribute__ ((aligned (16))) = { {0}, 0 };
114
115 #ifdef X86_64
116 struct x86_64_tss master_ktss64 __attribute__ ((aligned (4096))) = {
117 .io_bit_map_offset = 0x0FFF,
118 };
119 #endif /* X86_64 */
120
121 #ifdef __i386__
122 /*
123 * Task structure for double-fault handler:
124 */
125 struct i386_tss master_dftss
126 __attribute__ ((section ("__DESC, master_dftss")))
127 __attribute__ ((aligned (4096))) = {
128 0, /* back link */
129 (int) &df_task_stack_end - 4, /* esp0 */
130 KERNEL_DS, /* ss0 */
131 0, /* esp1 */
132 0, /* ss1 */
133 0, /* esp2 */
134 0, /* ss2 */
135 (int) IdlePDPT, /* cr3 */
136 (int) &df_task_start, /* eip */
137 0, /* eflags */
138 0, /* eax */
139 0, /* ecx */
140 0, /* edx */
141 0, /* ebx */
142 (int) &df_task_stack_end - 4, /* esp */
143 0, /* ebp */
144 0, /* esi */
145 0, /* edi */
146 KERNEL_DS, /* es */
147 KERNEL32_CS, /* cs */
148 KERNEL_DS, /* ss */
149 KERNEL_DS, /* ds */
150 KERNEL_DS, /* fs */
151 CPU_DATA_GS, /* gs */
152 KERNEL_LDT, /* ldt */
153 0, /* trace_trap */
154 0x0FFF /* IO bitmap offset -
155 beyond end of TSS segment,
156 so no bitmap */
157 };
158
159
160 /*
161 * Task structure for machine_check handler:
162 */
163 struct i386_tss master_mctss
164 __attribute__ ((section ("__DESC, master_mctss")))
165 __attribute__ ((aligned (4096))) = {
166 0, /* back link */
167 (int) &mc_task_stack_end - 4, /* esp0 */
168 KERNEL_DS, /* ss0 */
169 0, /* esp1 */
170 0, /* ss1 */
171 0, /* esp2 */
172 0, /* ss2 */
173 (int) IdlePDPT, /* cr3 */
174 (int) &mc_task_start, /* eip */
175 0, /* eflags */
176 0, /* eax */
177 0, /* ecx */
178 0, /* edx */
179 0, /* ebx */
180 (int) &mc_task_stack_end - 4, /* esp */
181 0, /* ebp */
182 0, /* esi */
183 0, /* edi */
184 KERNEL_DS, /* es */
185 KERNEL32_CS, /* cs */
186 KERNEL_DS, /* ss */
187 KERNEL_DS, /* ds */
188 KERNEL_DS, /* fs */
189 CPU_DATA_GS, /* gs */
190 KERNEL_LDT, /* ldt */
191 0, /* trace_trap */
192 0x0FFF /* IO bitmap offset -
193 beyond end of TSS segment,
194 so no bitmap */
195 };
196
197 #if MACH_KDB
198
199 struct i386_tss master_dbtss
200 __attribute__ ((section ("__DESC, master_dbtss")))
201 __attribute__ ((aligned (4096))) = {
202 0, /* back link */
203 0, /* esp0 */
204 KERNEL_DS, /* ss0 */
205 0, /* esp1 */
206 0, /* ss1 */
207 0, /* esp2 */
208 0, /* ss2 */
209 (int) IdlePDPT, /* cr3 */
210 0, /* eip */
211 0, /* eflags */
212 0, /* eax */
213 0, /* ecx */
214 0, /* edx */
215 0, /* ebx */
216 0, /* esp */
217 0, /* ebp */
218 0, /* esi */
219 0, /* edi */
220 KERNEL_DS, /* es */
221 KERNEL32_CS, /* cs */
222 KERNEL_DS, /* ss */
223 KERNEL_DS, /* ds */
224 KERNEL_DS, /* fs */
225 KERNEL_DS, /* gs */
226 KERNEL_LDT, /* ldt */
227 0, /* trace_trap */
228 0x0FFF /* IO bitmap offset -
229 beyond end of TSS segment,
230 so no bitmap */
231 };
232
233 #endif /* MACH_KDB */
234 #endif