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