]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/gdt.c
xnu-792.25.20.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 * 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 /* CMU_ENDHIST */
26 /*
27 * Mach Operating System
28 * Copyright (c) 1991,1990 Carnegie Mellon University
29 * All Rights Reserved.
30 *
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
36 *
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 *
41 * Carnegie Mellon requests users of this software to return to
42 *
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
47 *
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
50 */
51 /*
52 */
53
54 /*
55 * Global descriptor table.
56 */
57 #include <mach/machine.h>
58 #include <mach/i386/vm_param.h>
59 #include <kern/thread.h>
60 #include <i386/cpu_data.h>
61 #include <i386/mp_desc.h>
62
63 struct fake_descriptor master_gdt[GDTSZ] __attribute__ ((aligned (4096))) = {
64 [SEL_TO_INDEX(KERNEL_CS)] { /* kernel code */
65 0,
66 0xfffff,
67 SZ_32|SZ_G,
68 ACC_P|ACC_PL_K|ACC_CODE_R,
69 },
70 [SEL_TO_INDEX(KERNEL_DS)] { /* kernel data */
71 0,
72 0xfffff,
73 SZ_32|SZ_G,
74 ACC_P|ACC_PL_K|ACC_DATA_W
75 },
76 [SEL_TO_INDEX(KERNEL_LDT)] { /* local descriptor table */
77 (uint32_t) &master_ldt,
78 LDTSZ_MIN*sizeof(struct fake_descriptor)-1,
79 0,
80 ACC_P|ACC_PL_K|ACC_LDT
81 }, /* The slot KERNEL_LDT_2 is reserved. */
82 [SEL_TO_INDEX(KERNEL_TSS)] { /* TSS for this processor */
83 (uint32_t) &master_ktss,
84 sizeof(struct i386_tss)-1,
85 0,
86 ACC_P|ACC_PL_K|ACC_TSS
87 }, /* The slot KERNEL_TSS_2 is reserved. */
88 [SEL_TO_INDEX(CPU_DATA_GS)] { /* per-CPU current thread address */
89 (uint32_t) &cpu_data_master,
90 sizeof(cpu_data_t)-1,
91 SZ_32,
92 ACC_P|ACC_PL_K|ACC_DATA_W
93 },
94 [SEL_TO_INDEX(USER_LDT)] { /* user local descriptor table */
95 (uint32_t) &master_ldt,
96 LDTSZ_MIN*sizeof(struct fake_descriptor)-1,
97 0,
98 ACC_P|ACC_PL_K|ACC_LDT
99 },
100 [SEL_TO_INDEX(KERNEL64_CS)] { /* kernel 64-bit code */
101 0,
102 0xfffff,
103 SZ_64|SZ_G,
104 ACC_P|ACC_PL_K|ACC_CODE_R
105 },
106 [SEL_TO_INDEX(KERNEL64_SS)] { /* kernel 64-bit syscall stack */
107 0,
108 0xfffff,
109 SZ_32|SZ_G,
110 ACC_P|ACC_PL_K|ACC_DATA_W
111 },
112 #if MACH_KDB
113 [SEL_TO_INDEX(DEBUG_TSS)] { /* TSS for this processor */
114 (uint32_t)&master_dbtss,
115 sizeof(struct i386_tss)-1,
116 0,
117 ACC_P|ACC_PL_K|ACC_TSS
118 },
119 #endif /* MACH_KDB */
120 };