]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/gdt.c
xnu-344.21.74.tar.gz
[apple/xnu.git] / osfmk / i386 / gdt.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28 /* CMU_ENDHIST */
29 /*
30 * Mach Operating System
31 * Copyright (c) 1991,1990 Carnegie Mellon University
32 * All Rights Reserved.
33 *
34 * Permission to use, copy, modify and distribute this software and its
35 * documentation is hereby granted, provided that both the copyright
36 * notice and this permission notice appear in all copies of the
37 * software, derivative works or modified versions, and any portions
38 * thereof, and that both notices appear in supporting documentation.
39 *
40 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
41 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
42 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 *
44 * Carnegie Mellon requests users of this software to return to
45 *
46 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
47 * School of Computer Science
48 * Carnegie Mellon University
49 * Pittsburgh PA 15213-3890
50 *
51 * any improvements or extensions that they make and grant Carnegie Mellon
52 * the rights to redistribute these changes.
53 */
54 /*
55 */
56
57 /*
58 * Global descriptor table.
59 */
60 #include <i386/thread.h>
61 #include <i386/seg.h>
62 #include <mach/i386/vm_param.h>
63 #include <kern/thread.h>
64 #include <mach_kdb.h>
65
66 #ifdef MACH_BSD
67 extern int trap_unix_syscall(void), trap_mach25_syscall(void),
68 trap_machdep_syscall(void), syscall(void);
69 #endif
70
71 struct fake_descriptor gdt[GDTSZ] = {
72 /* 0x000 */ { 0, 0, 0, 0 }, /* always NULL */
73 /* 0x008 */ { LINEAR_KERNEL_ADDRESS + VM_MIN_ADDRESS,
74 (VM_MAX_KERNEL_ADDRESS-1-VM_MIN_KERNEL_ADDRESS)>>12,
75 SZ_32|SZ_G,
76 ACC_P|ACC_PL_K|ACC_CODE_R
77 }, /* kernel code */
78 /* 0x010 */ { LINEAR_KERNEL_ADDRESS + VM_MIN_ADDRESS,
79 (VM_MAX_KERNEL_ADDRESS-1-VM_MIN_KERNEL_ADDRESS)>>12,
80 SZ_32|SZ_G,
81 ACC_P|ACC_PL_K|ACC_DATA_W
82 }, /* kernel data */
83 /* 0x018 */ { LINEAR_KERNEL_ADDRESS + (unsigned int)ldt,
84 LDTSZ*sizeof(struct fake_descriptor)-1,
85 0,
86 ACC_P|ACC_PL_K|ACC_LDT
87 }, /* local descriptor table */
88 /* 0x020 */ { LINEAR_KERNEL_ADDRESS + (unsigned int)&ktss,
89 sizeof(struct i386_tss)-1,
90 0,
91 ACC_P|ACC_PL_K|ACC_TSS
92 }, /* TSS for this processor */
93 #ifdef MACH_BSD
94 /* 0x28 */ { (unsigned int) &trap_unix_syscall,
95 KERNEL_CS,
96 0, /* no parameters */
97 ACC_P|ACC_PL_U|ACC_CALL_GATE
98 },
99 /* 0x30 */ { (unsigned int) &trap_mach25_syscall,
100 KERNEL_CS,
101 0, /* no parameters */
102 ACC_P|ACC_PL_U|ACC_CALL_GATE
103 },
104 /* 0x38 */ { (unsigned int) &trap_machdep_syscall,
105 KERNEL_CS,
106 0, /* no parameters */
107 ACC_P|ACC_PL_U|ACC_CALL_GATE
108 },
109 #else
110 /* 0x028 */ { 0, 0, 0, 0 }, /* per-thread LDT */
111 /* 0x030 */ { 0, 0, 0, 0 }, /* per-thread TSS for IO bitmap */
112 /* 0x038 */ { 0, 0, 0, 0 },
113 #endif
114 /* 0x040 */ { 0, 0, 0, 0 },
115 /* 0x048 */ { LINEAR_KERNEL_ADDRESS + (unsigned int)&cpu_data[0],
116 sizeof(cpu_data)-1,
117 SZ_32,
118 ACC_P|ACC_PL_K|ACC_DATA_W
119 }, /* per-CPU current thread address */
120 #if MACH_KDB
121 /* 0x050 */ { LINEAR_KERNEL_ADDRESS + (unsigned int)&dbtss,
122 sizeof(struct i386_tss)-1,
123 0,
124 ACC_P|ACC_PL_K|ACC_TSS
125 } /* TSS for this processor */
126 #endif /* MACH_KDB */
127 };