1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * Copyright (c) 1992 NeXT Computer, Inc.
25 *
26 * Intel386 Family:	Segment descriptors.
27 *
28 * HISTORY
29 *
30 * 29 March 1992 ? at NeXT
31 *	Created.
32 */
33
34#ifndef _ARCH_I386_DESC_H_
35#define _ARCH_I386_DESC_H_
36
37/*
38 * Code segment descriptor.
39 */
40
41typedef struct code_desc {
42    unsigned short	limit00;
43    unsigned short	base00;
44    unsigned char	base16;
45    unsigned char	type	:5,
46#define DESC_CODE_EXEC	0x18
47#define DESC_CODE_READ	0x1a
48			dpl	:2,
49			present	:1;
50    unsigned char	limit16	:4,
51				:2,
52			opsz	:1,
53#define DESC_CODE_16B	0
54#define DESC_CODE_32B	1
55			granular:1;
56#define DESC_GRAN_BYTE	0
57#define DESC_GRAN_PAGE	1
58    unsigned char	base24;
59} code_desc_t;
60
61/*
62 * Data segment descriptor.
63 */
64
65typedef struct data_desc {
66    unsigned short	limit00;
67    unsigned short	base00;
68    unsigned char	base16;
69    unsigned char	type	:5,
70#define DESC_DATA_RONLY	0x10
71#define DESC_DATA_WRITE	0x12
72			dpl	:2,
73			present	:1;
74    unsigned char	limit16	:4,
75				:2,
76			stksz	:1,
77#define DESC_DATA_16B	0
78#define DESC_DATA_32B	1
79			granular:1;
80    unsigned char	base24;
81} data_desc_t;
82
83/*
84 * LDT segment descriptor.
85 */
86
87typedef struct ldt_desc {
88    unsigned short	limit00;
89    unsigned short	base00;
90    unsigned char	base16;
91    unsigned char	type	:5,
92#define DESC_LDT	0x02
93				:2,
94			present	:1;
95    unsigned char	limit16	:4,
96				:3,
97			granular:1;
98    unsigned char	base24;
99} ldt_desc_t;
100
101#include <architecture/i386/sel.h>
102
103/*
104 * Call gate descriptor.
105 */
106
107typedef struct call_gate {
108    unsigned short	offset00;
109    sel_t		seg;
110    unsigned int	argcnt	:5,
111    				:3,
112			type	:5,
113#define DESC_CALL_GATE	0x0c
114			dpl	:2,
115			present	:1,
116			offset16:16;
117} call_gate_t;
118
119/*
120 * Trap gate descriptor.
121 */
122
123typedef struct trap_gate {
124    unsigned short	offset00;
125    sel_t		seg;
126    unsigned int		:8,
127    			type	:5,
128#define DESC_TRAP_GATE	0x0f
129			dpl	:2,
130			present	:1,
131			offset16:16;
132} trap_gate_t;
133
134
135/*
136 * Interrupt gate descriptor.
137 */
138
139typedef struct intr_gate {
140    unsigned short	offset00;
141    sel_t		seg;
142    unsigned int		:8,
143    			type	:5,
144#define DESC_INTR_GATE	0x0e
145			dpl	:2,
146			present	:1,
147			offset16:16;
148} intr_gate_t;
149
150#endif	/* _ARCH_I386_DESC_H_ */
151