]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/ktss.c
24d031229e021fca9837027e5946b7d43d87dfc3
[apple/xnu.git] / osfmk / i386 / ktss.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
29 *
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.
35 *
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.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 */
52
53 /*
54 * Kernel task state segment.
55 *
56 * We don't use the i386 task switch mechanism. We need a TSS
57 * only to hold the kernel stack pointer for the current thread.
58 *
59 */
60 #include <i386/tss.h>
61 #include <i386/seg.h>
62 #include <mach_kdb.h>
63
64 struct i386_tss master_ktss
65 __attribute__ ((section ("__DESC, master_ktss")))
66 __attribute__ ((aligned (4096))) = {
67 0, /* back link */
68 0, /* esp0 */
69 KERNEL_DS, /* ss0 */
70 0, /* esp1 */
71 0, /* ss1 */
72 0, /* esp2 */
73 0, /* ss2 */
74 0, /* cr3 */
75 0, /* eip */
76 0, /* eflags */
77 0, /* eax */
78 0, /* ecx */
79 0, /* edx */
80 0, /* ebx */
81 0, /* esp */
82 0, /* ebp */
83 0, /* esi */
84 0, /* edi */
85 0, /* es */
86 0, /* cs */
87 0, /* ss */
88 0, /* ds */
89 0, /* fs */
90 0, /* gs */
91 KERNEL_LDT, /* ldt */
92 0, /* trace_trap */
93 0x0FFF /* IO bitmap offset -
94 beyond end of TSS segment,
95 so no bitmap */
96 };
97
98 /*
99 * The transient stack for sysenter.
100 * At its top is a 32-bit link to the PCB in legacy mode, 64-bit otherwise.
101 * NB: it also must be large enough to contain a interrupt stack frame
102 * due to a single-step trace trap at system call entry.
103 */
104 struct sysenter_stack master_sstk
105 __attribute__ ((section ("__DESC, master_sstk")))
106 __attribute__ ((aligned (16))) = { {0}, 0 };
107
108 #ifdef X86_64
109 struct x86_64_tss master_ktss64 __attribute__ ((aligned (4096))) = {
110 .io_bit_map_offset = 0x0FFF,
111 };
112 #endif /* X86_64 */
113
114
115
116 /*
117 * Task structure for double-fault handler:
118 */
119 struct i386_tss master_dftss
120 __attribute__ ((section ("__DESC, master_dftss")))
121 __attribute__ ((aligned (4096))) = {
122 0, /* back link */
123 (int) &df_task_stack_end - 4, /* esp0 */
124 KERNEL_DS, /* ss0 */
125 0, /* esp1 */
126 0, /* ss1 */
127 0, /* esp2 */
128 0, /* ss2 */
129 0, /* cr3 */
130 (int) &df_task_start, /* eip */
131 0, /* eflags */
132 0, /* eax */
133 0, /* ecx */
134 0, /* edx */
135 0, /* ebx */
136 (int) &df_task_stack_end - 4, /* esp */
137 0, /* ebp */
138 0, /* esi */
139 0, /* edi */
140 KERNEL_DS, /* es */
141 KERNEL_CS, /* cs */
142 KERNEL_DS, /* ss */
143 KERNEL_DS, /* ds */
144 KERNEL_DS, /* fs */
145 CPU_DATA_GS, /* gs */
146 KERNEL_LDT, /* ldt */
147 0, /* trace_trap */
148 0x0FFF /* IO bitmap offset -
149 beyond end of TSS segment,
150 so no bitmap */
151 };
152
153
154 /*
155 * Task structure for machine_check handler:
156 */
157 struct i386_tss master_mctss
158 __attribute__ ((section ("__DESC, master_mctss")))
159 __attribute__ ((aligned (4096))) = {
160 0, /* back link */
161 (int) &mc_task_stack_end - 4, /* esp0 */
162 KERNEL_DS, /* ss0 */
163 0, /* esp1 */
164 0, /* ss1 */
165 0, /* esp2 */
166 0, /* ss2 */
167 0, /* cr3 */
168 (int) &mc_task_start, /* eip */
169 0, /* eflags */
170 0, /* eax */
171 0, /* ecx */
172 0, /* edx */
173 0, /* ebx */
174 (int) &mc_task_stack_end - 4, /* esp */
175 0, /* ebp */
176 0, /* esi */
177 0, /* edi */
178 KERNEL_DS, /* es */
179 KERNEL_CS, /* cs */
180 KERNEL_DS, /* ss */
181 KERNEL_DS, /* ds */
182 KERNEL_DS, /* fs */
183 CPU_DATA_GS, /* gs */
184 KERNEL_LDT, /* ldt */
185 0, /* trace_trap */
186 0x0FFF /* IO bitmap offset -
187 beyond end of TSS segment,
188 so no bitmap */
189 };
190
191 #if MACH_KDB
192
193 struct i386_tss master_dbtss
194 __attribute__ ((section ("__DESC, master_dbtss")))
195 __attribute__ ((aligned (4096))) = {
196 0, /* back link */
197 0, /* esp0 */
198 KERNEL_DS, /* ss0 */
199 0, /* esp1 */
200 0, /* ss1 */
201 0, /* esp2 */
202 0, /* ss2 */
203 0, /* cr3 */
204 0, /* eip */
205 0, /* eflags */
206 0, /* eax */
207 0, /* ecx */
208 0, /* edx */
209 0, /* ebx */
210 0, /* esp */
211 0, /* ebp */
212 0, /* esi */
213 0, /* edi */
214 KERNEL_DS, /* es */
215 KERNEL_CS, /* cs */
216 KERNEL_DS, /* ss */
217 KERNEL_DS, /* ds */
218 KERNEL_DS, /* fs */
219 KERNEL_DS, /* gs */
220 KERNEL_LDT, /* ldt */
221 0, /* trace_trap */
222 0x0FFF /* IO bitmap offset -
223 beyond end of TSS segment,
224 so no bitmap */
225 };
226
227 #endif /* MACH_KDB */