]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/gdt.c
7186ee889c187f9523c2831b97c6a6d258f5d868
[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 struct fake_descriptor master_gdt[GDTSZ] __attribute__ ((aligned (4096))) = {
72 [SEL_TO_INDEX(KERNEL_CS)] { /* kernel code */
73 0,
74 0xfffff,
75 SZ_32|SZ_G,
76 ACC_P|ACC_PL_K|ACC_CODE_R,
77 },
78 [SEL_TO_INDEX(KERNEL_DS)] { /* kernel data */
79 0,
80 0xfffff,
81 SZ_32|SZ_G,
82 ACC_P|ACC_PL_K|ACC_DATA_W
83 },
84 [SEL_TO_INDEX(KERNEL_LDT)] { /* local descriptor table */
85 (uint32_t) &master_ldt,
86 LDTSZ_MIN*sizeof(struct fake_descriptor)-1,
87 0,
88 ACC_P|ACC_PL_K|ACC_LDT
89 }, /* The slot KERNEL_LDT_2 is reserved. */
90 [SEL_TO_INDEX(KERNEL_TSS)] { /* TSS for this processor */
91 (uint32_t) &master_ktss,
92 sizeof(struct i386_tss)-1,
93 0,
94 ACC_P|ACC_PL_K|ACC_TSS
95 }, /* The slot KERNEL_TSS_2 is reserved. */
96 [SEL_TO_INDEX(CPU_DATA_GS)] { /* per-CPU current thread address */
97 (uint32_t) &cpu_data_master,
98 sizeof(cpu_data_t)-1,
99 SZ_32,
100 ACC_P|ACC_PL_K|ACC_DATA_W
101 },
102 [SEL_TO_INDEX(USER_LDT)] { /* user local descriptor table */
103 (uint32_t) &master_ldt,
104 LDTSZ_MIN*sizeof(struct fake_descriptor)-1,
105 0,
106 ACC_P|ACC_PL_K|ACC_LDT
107 },
108 [SEL_TO_INDEX(KERNEL64_CS)] { /* kernel 64-bit code */
109 0,
110 0xfffff,
111 SZ_64|SZ_G,
112 ACC_P|ACC_PL_K|ACC_CODE_R
113 },
114 [SEL_TO_INDEX(KERNEL64_SS)] { /* kernel 64-bit syscall stack */
115 0,
116 0xfffff,
117 SZ_32|SZ_G,
118 ACC_P|ACC_PL_K|ACC_DATA_W
119 },
120 #if MACH_KDB
121 [SEL_TO_INDEX(DEBUG_TSS)] { /* TSS for this processor */
122 (uint32_t)&master_dbtss,
123 sizeof(struct i386_tss)-1,
124 0,
125 ACC_P|ACC_PL_K|ACC_TSS
126 },
127 #endif /* MACH_KDB */
128 };