]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/gdt.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / i386 / gdt.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 /* CMU_ENDHIST */
34 /*
35 * Mach Operating System
36 * Copyright (c) 1991,1990 Carnegie Mellon University
37 * All Rights Reserved.
38 *
39 * Permission to use, copy, modify and distribute this software and its
40 * documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
44 *
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
47 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
48 *
49 * Carnegie Mellon requests users of this software to return to
50 *
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
55 *
56 * any improvements or extensions that they make and grant Carnegie Mellon
57 * the rights to redistribute these changes.
58 */
59 /*
60 */
61
62 /*
63 * Global descriptor table.
64 */
65 #include <mach/machine.h>
66 #include <mach/i386/vm_param.h>
67 #include <kern/thread.h>
68 #include <i386/cpu_data.h>
69 #include <i386/mp_desc.h>
70
71 #ifdef MACH_BSD
72 extern int trap_unix_syscall(void), trap_mach25_syscall(void),
73 trap_machdep_syscall(void), syscall(void);
74 #endif
75
76 struct fake_descriptor gdt[GDTSZ] = {
77 /* 0x000 */ { 0, 0, 0, 0 }, /* always NULL */
78 /* 0x008 */ { 0,
79 0xfffff,
80 SZ_32|SZ_G,
81 ACC_P|ACC_PL_K|ACC_CODE_R
82 }, /* kernel code */
83 /* 0x010 */ { 0,
84 0xfffff,
85 SZ_32|SZ_G,
86 ACC_P|ACC_PL_K|ACC_DATA_W
87 }, /* kernel data */
88 /* 0x018 */ { (unsigned int)ldt,
89 LDTSZ*sizeof(struct fake_descriptor)-1,
90 0,
91 ACC_P|ACC_PL_K|ACC_LDT
92 }, /* local descriptor table */
93 /* 0x020 */ { (unsigned int)&ktss,
94 sizeof(struct i386_tss)-1,
95 0,
96 ACC_P|ACC_PL_K|ACC_TSS
97 }, /* TSS for this processor */
98 #ifdef MACH_BSD
99 /* 0x28 */ { (unsigned int) &trap_unix_syscall,
100 KERNEL_CS,
101 0, /* no parameters */
102 ACC_P|ACC_PL_U|ACC_CALL_GATE
103 },
104 /* 0x30 */ { (unsigned int) &trap_mach25_syscall,
105 KERNEL_CS,
106 0, /* no parameters */
107 ACC_P|ACC_PL_U|ACC_CALL_GATE
108 },
109 /* 0x38 */ { (unsigned int) &trap_machdep_syscall,
110 KERNEL_CS,
111 0, /* no parameters */
112 ACC_P|ACC_PL_U|ACC_CALL_GATE
113 },
114 #else
115 /* 0x028 */ { 0, 0, 0, 0 }, /* per-thread LDT */
116 /* 0x030 */ { 0, 0, 0, 0 }, /* per-thread TSS for IO bitmap */
117 /* 0x038 */ { 0, 0, 0, 0 },
118 #endif
119 /* 0x040 */ { 0, 0, 0, 0 },
120 /* 0x048 */ { (unsigned int)&cpu_data_master,
121 sizeof(cpu_data_t)-1,
122 SZ_32,
123 ACC_P|ACC_PL_K|ACC_DATA_W
124 }, /* per-CPU current thread address */
125 #if MACH_KDB
126 /* 0x050 */ { (unsigned int)&dbtss,
127 sizeof(struct i386_tss)-1,
128 0,
129 ACC_P|ACC_PL_K|ACC_TSS
130 } /* TSS for this processor */
131 #endif /* MACH_KDB */
132 };