]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/seg.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
63 * Real segment descriptor.
65 struct real_descriptor
{
66 unsigned int limit_low
:16, /* limit 0..15 */
67 base_low
:16, /* base 0..15 */
68 base_med
:8, /* base 16..23 */
69 access
:8, /* access byte */
70 limit_high
:4, /* limit 16..19 */
71 granularity
:4, /* granularity */
72 base_high
:8; /* base 24..31 */
76 unsigned int offset_low
:16, /* offset 0..15 */
80 offset_high
:16; /* offset 16..31 */
84 * We build descriptors and gates in a 'fake' format to let the
85 * fields be contiguous. We shuffle them into the real format
88 struct fake_descriptor
{
89 unsigned int offset
:32; /* offset */
90 unsigned int lim_or_seg
:20; /* limit */
91 /* or segment, for gate */
92 unsigned int size_or_wdct
:4; /* size/granularity */
93 /* word count, for gate */
94 unsigned int access
:8; /* access */
96 #endif /*__ASSEMBLER__*/
98 #define SZ_32 0x4 /* 32-bit segment */
99 #define SZ_G 0x8 /* 4K limit field */
101 #define ACC_A 0x01 /* accessed */
102 #define ACC_TYPE 0x1e /* type field: */
104 #define ACC_TYPE_SYSTEM 0x00 /* system descriptors: */
106 #define ACC_LDT 0x02 /* LDT */
107 #define ACC_CALL_GATE_16 0x04 /* 16-bit call gate */
108 #define ACC_TASK_GATE 0x05 /* task gate */
109 #define ACC_TSS 0x09 /* task segment */
110 #define ACC_CALL_GATE 0x0c /* call gate */
111 #define ACC_INTR_GATE 0x0e /* interrupt gate */
112 #define ACC_TRAP_GATE 0x0f /* trap gate */
114 #define ACC_TSS_BUSY 0x02 /* task busy */
116 #define ACC_TYPE_USER 0x10 /* user descriptors */
118 #define ACC_DATA 0x10 /* data */
119 #define ACC_DATA_W 0x12 /* data, writable */
120 #define ACC_DATA_E 0x14 /* data, expand-down */
121 #define ACC_DATA_EW 0x16 /* data, expand-down,
123 #define ACC_CODE 0x18 /* code */
124 #define ACC_CODE_R 0x1a /* code, readable */
125 #define ACC_CODE_C 0x1c /* code, conforming */
126 #define ACC_CODE_CR 0x1e /* code, conforming,
128 #define ACC_PL 0x60 /* access rights: */
129 #define ACC_PL_K 0x00 /* kernel access only */
130 #define ACC_PL_U 0x60 /* user access */
131 #define ACC_P 0x80 /* segment present */
134 * Components of a selector
136 #define SEL_LDTS 0x04 /* local selector */
137 #define SEL_PL 0x03 /* privilege level: */
138 #define SEL_PL_K 0x00 /* kernel selector */
139 #define SEL_PL_U 0x03 /* user selector */
142 * Convert selector to descriptor table index.
144 #define sel_idx(sel) ((sel)>>3)
147 * User descriptors for MACH - 32-bit flat address space
149 #define USER_SCALL 0x07 /* system call gate */
150 #define USER_RPC 0x0f /* mach rpc call gate */
151 #define USER_CS 0x17 /* user code segment */
152 #define USER_DS 0x1f /* user data segment */
157 * Kernel descriptors for MACH - 32-bit flat address space.
159 #define KERNEL_CS 0x08 /* kernel code */
160 #define KERNEL_DS 0x10 /* kernel data */
161 #define KERNEL_LDT 0x18 /* master LDT */
162 #define KERNEL_TSS 0x20 /* master TSS (uniprocessor) */
164 #define BSD_SCALL_SEL 0x28 /* BSD System calls */
165 #define MK25_SCALL_SEL 0x30 /* MK25 System Calls */
166 #define MACHDEP_SCALL_SEL 0x38 /* Machdep SYstem calls */
168 #define USER_LDT 0x28 /* place for per-thread LDT */
169 #define USER_TSS 0x30 /* place for per-thread TSS
170 that holds IO bitmap */
171 #define FPE_CS 0x38 /* floating-point emulator code */
173 #define USER_FPREGS 0x40 /* user-mode access to saved
174 floating-point registers */
175 #define CPU_DATA 0x48 /* per-cpu data */
178 #define USER_LDT 0x58
179 #define USER_TSS 0x60
184 #define DEBUG_TSS 0x50 /* debug TSS (uniprocessor) */
201 * Interrupt table is always 256 entries long.
205 #endif /* _I386_SEG_H_ */