xref: /titanic_52/usr/src/uts/intel/sys/segments.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_SEGMENTS_H
7*7c478bd9Sstevel@tonic-gate #define	_SYS_SEGMENTS_H
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
12*7c478bd9Sstevel@tonic-gate extern "C" {
13*7c478bd9Sstevel@tonic-gate #endif
14*7c478bd9Sstevel@tonic-gate 
15*7c478bd9Sstevel@tonic-gate /*
16*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1989, 1990 William F. Jolitz
17*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1990 The Regents of the University of California.
18*7c478bd9Sstevel@tonic-gate  * All rights reserved.
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * This code is derived from software contributed to Berkeley by
21*7c478bd9Sstevel@tonic-gate  * William Jolitz.
22*7c478bd9Sstevel@tonic-gate  *
23*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
24*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
25*7c478bd9Sstevel@tonic-gate  * are met:
26*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
27*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
28*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
29*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
30*7c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
31*7c478bd9Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
32*7c478bd9Sstevel@tonic-gate  *    must display the following acknowledgement:
33*7c478bd9Sstevel@tonic-gate  *	This product includes software developed by the University of
34*7c478bd9Sstevel@tonic-gate  *	California, Berkeley and its contributors.
35*7c478bd9Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
36*7c478bd9Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
37*7c478bd9Sstevel@tonic-gate  *    without specific prior written permission.
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
40*7c478bd9Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42*7c478bd9Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
43*7c478bd9Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44*7c478bd9Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45*7c478bd9Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46*7c478bd9Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47*7c478bd9Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48*7c478bd9Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49*7c478bd9Sstevel@tonic-gate  * SUCH DAMAGE.
50*7c478bd9Sstevel@tonic-gate  *
51*7c478bd9Sstevel@tonic-gate  *	from: @(#)segments.h	7.1 (Berkeley) 5/9/91
52*7c478bd9Sstevel@tonic-gate  * $FreeBSD: src/sys/i386/include/segments.h,v 1.34 2003/09/10 01:07:04
53*7c478bd9Sstevel@tonic-gate  * jhb Exp $
54*7c478bd9Sstevel@tonic-gate  *
55*7c478bd9Sstevel@tonic-gate  * 386 Segmentation Data Structures and definitions
56*7c478bd9Sstevel@tonic-gate  *	William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate #include <sys/tss.h>
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Selector register format
63*7c478bd9Sstevel@tonic-gate  * CS, DS, ES, FS, GS, SS
64*7c478bd9Sstevel@tonic-gate  *
65*7c478bd9Sstevel@tonic-gate  *  15                  3  2  1 0
66*7c478bd9Sstevel@tonic-gate  * +---------------------+---+----+
67*7c478bd9Sstevel@tonic-gate  * |          SI         |TI |RPL |
68*7c478bd9Sstevel@tonic-gate  * +---------------------+---+----+
69*7c478bd9Sstevel@tonic-gate  *
70*7c478bd9Sstevel@tonic-gate  * SI  = selector index
71*7c478bd9Sstevel@tonic-gate  * TI  = table indicator (0 = GDT, 1 = LDT)
72*7c478bd9Sstevel@tonic-gate  * RPL = requestor privilege level
73*7c478bd9Sstevel@tonic-gate  */
74*7c478bd9Sstevel@tonic-gate #if !defined(_ASM) || defined(__GNUC_AS__)
75*7c478bd9Sstevel@tonic-gate #define	IDXTOSEL(s)	((s) << 3)		/* index to selector */
76*7c478bd9Sstevel@tonic-gate #define	SEL_GDT(s, r)	(IDXTOSEL(s) | r)	/* global sel */
77*7c478bd9Sstevel@tonic-gate #else
78*7c478bd9Sstevel@tonic-gate #define	IDXTOSEL(s)	[s << 3]
79*7c478bd9Sstevel@tonic-gate #define	SEL_GDT(s, r)	[IDXTOSEL(s) | r]
80*7c478bd9Sstevel@tonic-gate #endif
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #define	SELTOIDX(s)	((s) >> 3)	/* selector to index */
83*7c478bd9Sstevel@tonic-gate #define	SEL_KPL		0		/* kernel priority level */
84*7c478bd9Sstevel@tonic-gate #define	SEL_UPL		3		/* user priority level */
85*7c478bd9Sstevel@tonic-gate #define	SEL_TI_LDT	4		/* local descriptor table */
86*7c478bd9Sstevel@tonic-gate #define	SEL_LDT(s)	(IDXTOSEL(s) | SEL_TI_LDT | SEL_UPL)	/* local sel */
87*7c478bd9Sstevel@tonic-gate #define	CPL_MASK	3		/* RPL mask for selector */
88*7c478bd9Sstevel@tonic-gate #define	SELISLDT(s)	(((s) & SEL_TI_LDT) == SEL_TI_LDT)
89*7c478bd9Sstevel@tonic-gate #define	SELISUPL(s)	(((s) & CPL_MASK) == SEL_UPL)
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate typedef	uint16_t	selector_t;	/* selector reigster */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * Hardware descriptor table register format for GDT and IDT.
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #pragma pack(2)
101*7c478bd9Sstevel@tonic-gate typedef struct {
102*7c478bd9Sstevel@tonic-gate 	uint16_t dtr_limit;	/* table limit */
103*7c478bd9Sstevel@tonic-gate 	uint64_t dtr_base;	/* table base address  */
104*7c478bd9Sstevel@tonic-gate } desctbr_t;
105*7c478bd9Sstevel@tonic-gate #pragma	pack()
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #pragma pack(2)
110*7c478bd9Sstevel@tonic-gate typedef struct {
111*7c478bd9Sstevel@tonic-gate 	uint16_t dtr_limit;	/* table limit */
112*7c478bd9Sstevel@tonic-gate 	uint32_t dtr_base;	/* table base address  */
113*7c478bd9Sstevel@tonic-gate } desctbr_t;
114*7c478bd9Sstevel@tonic-gate #pragma	pack()
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #endif	/* __i386 */
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate  * Functions for loading and storing descriptor table
120*7c478bd9Sstevel@tonic-gate  * registers.
121*7c478bd9Sstevel@tonic-gate  */
122*7c478bd9Sstevel@tonic-gate extern void rd_idtr(desctbr_t *);
123*7c478bd9Sstevel@tonic-gate extern void wr_idtr(desctbr_t *);
124*7c478bd9Sstevel@tonic-gate extern void rd_gdtr(desctbr_t *);
125*7c478bd9Sstevel@tonic-gate extern void wr_gdtr(desctbr_t *);
126*7c478bd9Sstevel@tonic-gate extern void wr_ldtr(selector_t);
127*7c478bd9Sstevel@tonic-gate extern selector_t rd_ldtr(void);
128*7c478bd9Sstevel@tonic-gate extern void wr_tsr(selector_t);
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
131*7c478bd9Sstevel@tonic-gate extern void clr_ldt_sregs(void);
132*7c478bd9Sstevel@tonic-gate #endif
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate #if !defined(__amd64)
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /*
137*7c478bd9Sstevel@tonic-gate  * User segment descriptors (code and data).
138*7c478bd9Sstevel@tonic-gate  * Legacy mode 64-bits wide.
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate typedef struct user_desc {
141*7c478bd9Sstevel@tonic-gate 	uint32_t usd_lolimit:16;	/* segment limit 15:0 */
142*7c478bd9Sstevel@tonic-gate 	uint32_t usd_lobase:16;		/* segment base 15:0 */
143*7c478bd9Sstevel@tonic-gate 	uint32_t usd_midbase:8;		/* segment base 23:16 */
144*7c478bd9Sstevel@tonic-gate 	uint32_t usd_type:5;		/* segment type, includes S bit */
145*7c478bd9Sstevel@tonic-gate 	uint32_t usd_dpl:2;		/* segment descriptor priority level */
146*7c478bd9Sstevel@tonic-gate 	uint32_t usd_p:1;		/* segment descriptor present */
147*7c478bd9Sstevel@tonic-gate 	uint32_t usd_hilimit:4;		/* segment limit 19:16 */
148*7c478bd9Sstevel@tonic-gate 	uint32_t usd_avl:1;		/* available to sw, but not used */
149*7c478bd9Sstevel@tonic-gate 	uint32_t usd_reserved:1;	/* unused, ignored */
150*7c478bd9Sstevel@tonic-gate 	uint32_t usd_def32:1;		/* default 32 vs 16 bit operand */
151*7c478bd9Sstevel@tonic-gate 	uint32_t usd_gran:1;		/* limit units (bytes vs pages) */
152*7c478bd9Sstevel@tonic-gate 	uint32_t usd_hibase:8;		/* segment base 31:24 */
153*7c478bd9Sstevel@tonic-gate } user_desc_t;
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #define	USEGD_GETBASE(usd)		((usd)->usd_lobase |		\
156*7c478bd9Sstevel@tonic-gate 					(usd)->usd_midbase << 16 |	\
157*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hibase << (16 + 8))
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #define	USEGD_SETBASE(usd, b)		((usd)->usd_lobase = (b),	\
160*7c478bd9Sstevel@tonic-gate 					(usd)->usd_midbase = (b) >> 16, \
161*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hibase = (b) >> (16 + 8))
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate #define	USEGD_GETLIMIT(usd)		((usd)->usd_lolimit |		\
164*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hilimit << 16)
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate #define	USEGD_SETLIMIT(usd, lim)	((usd)->usd_lolimit = lim,	\
167*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hilimit = lim >> 16)
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate #define	USD_TYPESHIFT			5	/* size of usd_type field */
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate #else	/* __amd64 */
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate /*
174*7c478bd9Sstevel@tonic-gate  * User segment descriptors.
175*7c478bd9Sstevel@tonic-gate  * Long mode 64-bits wide.
176*7c478bd9Sstevel@tonic-gate  *
177*7c478bd9Sstevel@tonic-gate  * In 32-bit compatibility mode (%cs:usd_long=0) all fields are interpreted
178*7c478bd9Sstevel@tonic-gate  * as in legacy mode for both code and data.
179*7c478bd9Sstevel@tonic-gate  *
180*7c478bd9Sstevel@tonic-gate  * In 64-bit mode (%cs:usd_long=1) code segments only have the conforming
181*7c478bd9Sstevel@tonic-gate  * bit in usd_type, usd_dpl, usd_p, usd_long and usd_def32=0. usd_def32
182*7c478bd9Sstevel@tonic-gate  * must be zero in 64-bit mode. Setting it to 1 is reserved for future use.
183*7c478bd9Sstevel@tonic-gate  * All other fields are loaded but ignored by hardware.
184*7c478bd9Sstevel@tonic-gate  *
185*7c478bd9Sstevel@tonic-gate  * 64-bit data segments only have usd_p. All other fields are loaded but
186*7c478bd9Sstevel@tonic-gate  * ignored by hardware when in 64-bit mode.
187*7c478bd9Sstevel@tonic-gate  */
188*7c478bd9Sstevel@tonic-gate typedef struct user_desc {
189*7c478bd9Sstevel@tonic-gate 	uint64_t usd_lolimit:16;	/* segment limit 15:0 */
190*7c478bd9Sstevel@tonic-gate 	uint64_t usd_lobase:16;		/* segment base 15:0 */
191*7c478bd9Sstevel@tonic-gate 	uint64_t usd_midbase:8;		/* segment base 23:16 */
192*7c478bd9Sstevel@tonic-gate 	uint64_t usd_type:5;		/* segment type, includes S bit */
193*7c478bd9Sstevel@tonic-gate 	uint64_t usd_dpl:2;		/* segment descriptor priority level */
194*7c478bd9Sstevel@tonic-gate 	uint64_t usd_p:1;		/* segment descriptor present */
195*7c478bd9Sstevel@tonic-gate 	uint64_t usd_hilimit:4;		/* segment limit 19:16 */
196*7c478bd9Sstevel@tonic-gate 	uint64_t usd_avl:1;		/* available to sw, but not used */
197*7c478bd9Sstevel@tonic-gate 	uint64_t usd_long:1;		/* long mode (%cs only) */
198*7c478bd9Sstevel@tonic-gate 	uint64_t usd_def32:1;		/* default 32 vs 16 bit operand */
199*7c478bd9Sstevel@tonic-gate 	uint64_t usd_gran:1;		/* limit units (bytes vs page) */
200*7c478bd9Sstevel@tonic-gate 	uint64_t usd_hibase:8;		/* segment base 31:24 */
201*7c478bd9Sstevel@tonic-gate } user_desc_t;
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate #define	USEGD_GETBASE(usd)		((usd)->usd_lobase |		\
204*7c478bd9Sstevel@tonic-gate 					(usd)->usd_midbase << 16 |	\
205*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hibase << (16 + 8))
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate #define	USEGD_SETBASE(usd, b)		((usd)->usd_lobase = (b),	\
208*7c478bd9Sstevel@tonic-gate 					(usd)->usd_midbase = (b) >> 16, \
209*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hibase = (b) >> (16 + 8))
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate #define	USEGD_GETLIMIT(usd)		((usd)->usd_lolimit |		\
212*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hilimit << 16)
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #define	USEGD_SETLIMIT(usd, lim)	((usd)->usd_lolimit = lim,	\
215*7c478bd9Sstevel@tonic-gate 					(usd)->usd_hilimit = lim >> 16)
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #define	USD_TYPESHIFT			5	/* size of usd_type field */
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate #endif /* __amd64 */
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate #if !defined(__amd64)
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate /*
224*7c478bd9Sstevel@tonic-gate  * System segment descriptors for LDT and TSS segments.
225*7c478bd9Sstevel@tonic-gate  * Legacy mode 64-bits wide.
226*7c478bd9Sstevel@tonic-gate  */
227*7c478bd9Sstevel@tonic-gate typedef struct system_desc {
228*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_lolimit:16;	/* segment limit 15:0 */
229*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_lobase:16;		/* segment base 15:0 */
230*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_midbase:8;		/* segment base 23:16 */
231*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_type:4;		/* segment type */
232*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_zero:1;		/* must be zero */
233*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_dpl:2;		/* segment descriptor priority level */
234*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_p:1;		/* segment descriptor present */
235*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_hilimit:4;		/* segment limit 19:16 */
236*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_avl:1;		/* available to sw, but not used */
237*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_reserved:2;	/* unused, ignored */
238*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_gran:1;		/* limit unit (bytes vs pages) */
239*7c478bd9Sstevel@tonic-gate 	uint32_t ssd_hibase:8;		/* segment base 31:24 */
240*7c478bd9Sstevel@tonic-gate } system_desc_t;
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate #else	/* __amd64 */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate /*
245*7c478bd9Sstevel@tonic-gate  * System segment descriptors for LDT and TSS segments.
246*7c478bd9Sstevel@tonic-gate  * Long mode 128-bits wide.
247*7c478bd9Sstevel@tonic-gate  *
248*7c478bd9Sstevel@tonic-gate  * 32-bit LDT and TSS descriptor types are redefined to 64-bit equivalents.
249*7c478bd9Sstevel@tonic-gate  * All other legacy types are reserved and illegal.
250*7c478bd9Sstevel@tonic-gate  */
251*7c478bd9Sstevel@tonic-gate typedef struct system_desc {
252*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_lolimit:16;	/* segment limit 15:0 */
253*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_lobase:16;		/* segment base 15:0 */
254*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_midbase:8;		/* segment base 23:16 */
255*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_type:4;		/* segment type */
256*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_zero1:1;		/* must be zero */
257*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_dpl:2;		/* segment descriptor priority level */
258*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_p:1;		/* segment descriptor present */
259*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_hilimit:4;		/* segment limit 19:16 */
260*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_avl:1;		/* available to sw, but not used */
261*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_resv1:2;		/* unused, ignored */
262*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_gran:1;		/* limit unit (bytes vs pages) */
263*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_hibase:8;		/* segment base 31:24 */
264*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_hi64base:32;	/* segment base 63:32 */
265*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_resv2:8;		/* unused, ignored */
266*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_zero2:5;		/* must be zero */
267*7c478bd9Sstevel@tonic-gate 	uint64_t ssd_resv3:19;		/* unused, ignored */
268*7c478bd9Sstevel@tonic-gate } system_desc_t;
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate #endif	/* __amd64 */
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate #define	SYSSEGD_SETLIMIT(ssd, lim)	((ssd)->ssd_lolimit = lim,	\
273*7c478bd9Sstevel@tonic-gate 					(ssd)->ssd_hilimit = lim >> 16)
274*7c478bd9Sstevel@tonic-gate #if !defined(__amd64)
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate /*
277*7c478bd9Sstevel@tonic-gate  * System gate segment descriptors for interrupt, trap, call and task gates.
278*7c478bd9Sstevel@tonic-gate  * Legacy mode 64-bits wide.
279*7c478bd9Sstevel@tonic-gate  */
280*7c478bd9Sstevel@tonic-gate typedef struct gate_desc {
281*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_looffset:16;	/* segment code offset 15:0 */
282*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_selector:16;	/* target code or task selector */
283*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_stkcpy:5;		/* number of stack wds to cpy */
284*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_resv:3;		/* unused, ignored */
285*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_type:5;		/* segment type, includes S bit */
286*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_dpl:2;		/* segment descriptor priority level */
287*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_p:1;		/* segment descriptor present */
288*7c478bd9Sstevel@tonic-gate 	uint32_t sgd_hioffset:16;	/* code seg off 31:16 */
289*7c478bd9Sstevel@tonic-gate } gate_desc_t;
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate #define	GATESEG_GETOFFSET(sgd)		((sgd)->sgd_looffset |		\
292*7c478bd9Sstevel@tonic-gate 					(sgd)->sgd_hioffset << 16)
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate #else	/* __amd64 */
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate  * System segment descriptors for interrupt, trap and call gates.
298*7c478bd9Sstevel@tonic-gate  * Long mode 128-bits wide.
299*7c478bd9Sstevel@tonic-gate  *
300*7c478bd9Sstevel@tonic-gate  * 32-bit interrupt, trap and call gate types are redefined to 64-bit
301*7c478bd9Sstevel@tonic-gate  * equivalents. Task gates along with all other legacy types are reserved
302*7c478bd9Sstevel@tonic-gate  * and illegal.
303*7c478bd9Sstevel@tonic-gate  */
304*7c478bd9Sstevel@tonic-gate typedef struct gate_desc {
305*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_looffset:16;	/* segment code offset 15:0 */
306*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_selector:16;	/* target code or task selector */
307*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_ist:3;		/* IST table index */
308*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_resv1:5;		/* unused, ignored */
309*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_type:5;		/* segment type, includes S bit */
310*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_dpl:2;		/* segment descriptor priority level */
311*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_p:1;		/* segment descriptor present */
312*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_hioffset:16;	/* segment code offset 31:16 */
313*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_hi64offset:32;	/* segment code offset 63:32 */
314*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_resv2:8;		/* unused, ignored */
315*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_zero:5;		/* call gate only: must be zero */
316*7c478bd9Sstevel@tonic-gate 	uint64_t sgd_resv3:19;		/* unused, ignored */
317*7c478bd9Sstevel@tonic-gate } gate_desc_t;
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate #define	GATESEG_GETOFFSET(sgd)		((sgd)->sgd_looffset |		\
320*7c478bd9Sstevel@tonic-gate 					(sgd)->sgd_hioffset << 16 |	\
321*7c478bd9Sstevel@tonic-gate 					(sgd)->sgd_hi64offset << 32)
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate #endif	/* __amd64 */
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate /*
326*7c478bd9Sstevel@tonic-gate  * functions for initializing and updating segment descriptors.
327*7c478bd9Sstevel@tonic-gate  */
328*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
329*7c478bd9Sstevel@tonic-gate 
330*7c478bd9Sstevel@tonic-gate extern void set_usegd(user_desc_t *, uint_t, void *, size_t, uint_t, uint_t,
331*7c478bd9Sstevel@tonic-gate     uint_t, uint_t);
332*7c478bd9Sstevel@tonic-gate extern void set_gatesegd(gate_desc_t *, void (*)(void), selector_t, uint_t,
333*7c478bd9Sstevel@tonic-gate     uint_t, uint_t);
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
336*7c478bd9Sstevel@tonic-gate 
337*7c478bd9Sstevel@tonic-gate extern void set_usegd(user_desc_t *, void *, size_t, uint_t, uint_t,
338*7c478bd9Sstevel@tonic-gate     uint_t, uint_t);
339*7c478bd9Sstevel@tonic-gate extern void set_gatesegd(gate_desc_t *, void (*)(void), selector_t,
340*7c478bd9Sstevel@tonic-gate     uint_t, uint_t, uint_t);
341*7c478bd9Sstevel@tonic-gate 
342*7c478bd9Sstevel@tonic-gate #endif	/* __i386 */
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate void set_syssegd(system_desc_t *, void *, size_t, uint_t, uint_t);
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate #endif	/* _ASM */
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate /*
349*7c478bd9Sstevel@tonic-gate  * Common segment parameter defintions for granularity, default
350*7c478bd9Sstevel@tonic-gate  * operand size and operaton mode.
351*7c478bd9Sstevel@tonic-gate  */
352*7c478bd9Sstevel@tonic-gate #define	SDP_BYTES	0	/* segment limit scaled to bytes */
353*7c478bd9Sstevel@tonic-gate #define	SDP_PAGES	1	/* segment limit scaled to pages */
354*7c478bd9Sstevel@tonic-gate #define	SDP_OP32	1	/* code and data default operand = 32 bits */
355*7c478bd9Sstevel@tonic-gate #define	SDP_LONG	1	/* long mode code segment (64 bits) */
356*7c478bd9Sstevel@tonic-gate #define	SDP_SHORT	0	/* compat/legacy code segment (32 bits) */
357*7c478bd9Sstevel@tonic-gate /*
358*7c478bd9Sstevel@tonic-gate  * System segments and gate types.
359*7c478bd9Sstevel@tonic-gate  *
360*7c478bd9Sstevel@tonic-gate  * In long mode i386 32-bit ldt, tss, call, interrupt and trap gate
361*7c478bd9Sstevel@tonic-gate  * types are redefined into 64-bit equivalents.
362*7c478bd9Sstevel@tonic-gate  */
363*7c478bd9Sstevel@tonic-gate #define	SDT_SYSNULL	 0	/* system null */
364*7c478bd9Sstevel@tonic-gate #define	SDT_SYS286TSS	 1	/* system 286 TSS available */
365*7c478bd9Sstevel@tonic-gate #define	SDT_SYSLDT	 2	/* system local descriptor table */
366*7c478bd9Sstevel@tonic-gate #define	SDT_SYS286BSY	 3	/* system 286 TSS busy */
367*7c478bd9Sstevel@tonic-gate #define	SDT_SYS286CGT	 4	/* system 286 call gate */
368*7c478bd9Sstevel@tonic-gate #define	SDT_SYSTASKGT	 5	/* system task gate */
369*7c478bd9Sstevel@tonic-gate #define	SDT_SYS286IGT	 6	/* system 286 interrupt gate */
370*7c478bd9Sstevel@tonic-gate #define	SDT_SYS286TGT	 7	/* system 286 trap gate */
371*7c478bd9Sstevel@tonic-gate #define	SDT_SYSNULL2	 8	/* system null again */
372*7c478bd9Sstevel@tonic-gate #define	SDT_SYSTSS	 9	/* system TSS available */
373*7c478bd9Sstevel@tonic-gate #define	SDT_SYSNULL3	10	/* system null again */
374*7c478bd9Sstevel@tonic-gate #define	SDT_SYSTSSBSY	11	/* system TSS busy */
375*7c478bd9Sstevel@tonic-gate #define	SDT_SYSCGT	12	/* system call gate */
376*7c478bd9Sstevel@tonic-gate #define	SDT_SYSNULL4	13	/* system null again */
377*7c478bd9Sstevel@tonic-gate #define	SDT_SYSIGT	14	/* system interrupt gate */
378*7c478bd9Sstevel@tonic-gate #define	SDT_SYSTGT	15	/* system trap gate */
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate /*
381*7c478bd9Sstevel@tonic-gate  * Memory segment types.
382*7c478bd9Sstevel@tonic-gate  *
383*7c478bd9Sstevel@tonic-gate  * While in long mode expand-down, writable and accessed type field
384*7c478bd9Sstevel@tonic-gate  * attributes are ignored. Only the conforming bit is loaded by hardware
385*7c478bd9Sstevel@tonic-gate  * for long mode code segment descriptors.
386*7c478bd9Sstevel@tonic-gate  */
387*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRO	16	/* read only */
388*7c478bd9Sstevel@tonic-gate #define	SDT_MEMROA	17	/* read only accessed */
389*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRW	18	/* read write */
390*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRWA	19	/* read write accessed */
391*7c478bd9Sstevel@tonic-gate #define	SDT_MEMROD	20	/* read only expand dwn limit */
392*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRODA	21	/* read only expand dwn limit accessed */
393*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRWD	22	/* read write expand dwn limit */
394*7c478bd9Sstevel@tonic-gate #define	SDT_MEMRWDA	23	/* read write expand dwn limit accessed */
395*7c478bd9Sstevel@tonic-gate #define	SDT_MEME	24	/* execute only */
396*7c478bd9Sstevel@tonic-gate #define	SDT_MEMEA	25	/* execute only accessed */
397*7c478bd9Sstevel@tonic-gate #define	SDT_MEMER	26	/* execute read */
398*7c478bd9Sstevel@tonic-gate #define	SDT_MEMERA	27	/* execute read accessed */
399*7c478bd9Sstevel@tonic-gate #define	SDT_MEMEC	28	/* execute only conforming */
400*7c478bd9Sstevel@tonic-gate #define	SDT_MEMEAC	29	/* execute only accessed conforming */
401*7c478bd9Sstevel@tonic-gate #define	SDT_MEMERC	30	/* execute read conforming */
402*7c478bd9Sstevel@tonic-gate #define	SDT_MEMERAC	31	/* execute read accessed conforming */
403*7c478bd9Sstevel@tonic-gate 
404*7c478bd9Sstevel@tonic-gate /*
405*7c478bd9Sstevel@tonic-gate  * Entries in the Interrupt Descriptor Table (IDT)
406*7c478bd9Sstevel@tonic-gate  */
407*7c478bd9Sstevel@tonic-gate #define	IDT_DE		0	/* #DE: Divide Error */
408*7c478bd9Sstevel@tonic-gate #define	IDT_DB		1	/* #DB: Debug */
409*7c478bd9Sstevel@tonic-gate #define	IDT_NMI		2	/* Nonmaskable External Interrupt */
410*7c478bd9Sstevel@tonic-gate #define	IDT_BP		3	/* #BP: Breakpoint */
411*7c478bd9Sstevel@tonic-gate #define	IDT_OF		4	/* #OF: Overflow */
412*7c478bd9Sstevel@tonic-gate #define	IDT_BR		5	/* #BR: Bound Range Exceeded */
413*7c478bd9Sstevel@tonic-gate #define	IDT_UD		6	/* #UD: Undefined/Invalid Opcode */
414*7c478bd9Sstevel@tonic-gate #define	IDT_NM		7	/* #NM: No Math Coprocessor */
415*7c478bd9Sstevel@tonic-gate #define	IDT_DF		8	/* #DF: Double Fault */
416*7c478bd9Sstevel@tonic-gate #define	IDT_FPUGP	9	/* Coprocessor Segment Overrun */
417*7c478bd9Sstevel@tonic-gate #define	IDT_TS		10	/* #TS: Invalid TSS */
418*7c478bd9Sstevel@tonic-gate #define	IDT_NP		11	/* #NP: Segment Not Present */
419*7c478bd9Sstevel@tonic-gate #define	IDT_SS		12	/* #SS: Stack Segment Fault */
420*7c478bd9Sstevel@tonic-gate #define	IDT_GP		13	/* #GP: General Protection Fault */
421*7c478bd9Sstevel@tonic-gate #define	IDT_PF		14	/* #PF: Page Fault */
422*7c478bd9Sstevel@tonic-gate #define	IDT_MF		16	/* #MF: FPU Floating-Point Error */
423*7c478bd9Sstevel@tonic-gate #define	IDT_AC		17	/* #AC: Alignment Check */
424*7c478bd9Sstevel@tonic-gate #define	IDT_MC		18	/* #MC: Machine Check */
425*7c478bd9Sstevel@tonic-gate #define	IDT_XF		19	/* #XF: SIMD Floating-Point Exception */
426*7c478bd9Sstevel@tonic-gate #define	NIDT		256	/* size in entries of IDT */
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate /*
429*7c478bd9Sstevel@tonic-gate  * Entries in the Global Descriptor Table (GDT)
430*7c478bd9Sstevel@tonic-gate  *
431*7c478bd9Sstevel@tonic-gate  * We make sure to space the system descriptors (LDT's, TSS')
432*7c478bd9Sstevel@tonic-gate  * such that they are double gdt slot aligned. This is because
433*7c478bd9Sstevel@tonic-gate  * in long mode system segment decriptors expand to 128 bits.
434*7c478bd9Sstevel@tonic-gate  *
435*7c478bd9Sstevel@tonic-gate  * GDT_LWPFS and GDT_LWPGS must be the same for both 32 and 64-bit
436*7c478bd9Sstevel@tonic-gate  * kernels. See setup_context in libc.
437*7c478bd9Sstevel@tonic-gate  */
438*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
439*7c478bd9Sstevel@tonic-gate 
440*7c478bd9Sstevel@tonic-gate #define	GDT_NULL	0	/* null */
441*7c478bd9Sstevel@tonic-gate #define	GDT_B32DATA	1	/* copied from boot */
442*7c478bd9Sstevel@tonic-gate #define	GDT_B32CODE	2	/* copied from boot */
443*7c478bd9Sstevel@tonic-gate #define	GDT_B64DATA	3	/* copied from boot */
444*7c478bd9Sstevel@tonic-gate #define	GDT_B64CODE	4	/* copied from boot */
445*7c478bd9Sstevel@tonic-gate #define	GDT_KCODE	5	/* kernel code seg %cs */
446*7c478bd9Sstevel@tonic-gate #define	GDT_KDATA	6	/* kernel data seg %ds */
447*7c478bd9Sstevel@tonic-gate #define	GDT_U32CODE	7	/* 32-bit process on 64-bit kernel %cs */
448*7c478bd9Sstevel@tonic-gate #define	GDT_UDATA	8	/* user data seg %ds (32 and 64 bit) */
449*7c478bd9Sstevel@tonic-gate #define	GDT_UCODE	9	/* native user code  seg %cs */
450*7c478bd9Sstevel@tonic-gate #define	GDT_LDT		10	/* LDT for current process */
451*7c478bd9Sstevel@tonic-gate #define	GDT_KTSS	12	/* kernel tss */
452*7c478bd9Sstevel@tonic-gate #define	GDT_FS		GDT_NULL /* kernel %fs segment selector */
453*7c478bd9Sstevel@tonic-gate #define	GDT_GS		GDT_NULL /* kernel %gs segment selector */
454*7c478bd9Sstevel@tonic-gate #define	GDT_LWPFS	55	/* lwp private %fs segment selector */
455*7c478bd9Sstevel@tonic-gate #define	GDT_LWPGS	56	/* lwp private %gs segment selector */
456*7c478bd9Sstevel@tonic-gate #define	NGDT		58	/* number of entries in GDT */
457*7c478bd9Sstevel@tonic-gate 
458*7c478bd9Sstevel@tonic-gate /*
459*7c478bd9Sstevel@tonic-gate  * This selector is only used in the temporary GDT used to bring additional
460*7c478bd9Sstevel@tonic-gate  * CPUs from 16-bit real mode into long mode in real_mode_start().
461*7c478bd9Sstevel@tonic-gate  */
462*7c478bd9Sstevel@tonic-gate #define	TEMPGDT_KCODE64	1	/* 64-bit code selector */
463*7c478bd9Sstevel@tonic-gate 
464*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
465*7c478bd9Sstevel@tonic-gate 
466*7c478bd9Sstevel@tonic-gate #define	GDT_NULL	0	/* null */
467*7c478bd9Sstevel@tonic-gate #define	GDT_BOOTFLAT	1	/* copied from boot */
468*7c478bd9Sstevel@tonic-gate #define	GDT_BOOTCODE	2	/* copied from boot */
469*7c478bd9Sstevel@tonic-gate #define	GDT_BOOTCODE16	3	/* copied from boot */
470*7c478bd9Sstevel@tonic-gate #define	GDT_BOOTDATA	4	/* copied from boot */
471*7c478bd9Sstevel@tonic-gate #define	GDT_LDT		40	/* LDT for current process */
472*7c478bd9Sstevel@tonic-gate #define	GDT_KTSS	42	/* kernel tss */
473*7c478bd9Sstevel@tonic-gate #define	GDT_KCODE	43	/* kernel code seg %cs */
474*7c478bd9Sstevel@tonic-gate #define	GDT_KDATA	44	/* kernel data seg %ds */
475*7c478bd9Sstevel@tonic-gate #define	GDT_UCODE	45	/* native user code  seg %cs */
476*7c478bd9Sstevel@tonic-gate #define	GDT_UDATA	46	/* user data seg %ds (32 and 64 bit) */
477*7c478bd9Sstevel@tonic-gate #define	GDT_DBFLT	47	/* double fault #DF selector */
478*7c478bd9Sstevel@tonic-gate #define	GDT_FS		53	/* kernel %fs segment selector */
479*7c478bd9Sstevel@tonic-gate #define	GDT_GS		54	/* kernel %gs segment selector */
480*7c478bd9Sstevel@tonic-gate #define	GDT_LWPFS	55	/* lwp private %fs segment selector */
481*7c478bd9Sstevel@tonic-gate #define	GDT_LWPGS	56	/* lwp private %gs segment selector */
482*7c478bd9Sstevel@tonic-gate #define	NGDT		90	/* number of entries in GDT */
483*7c478bd9Sstevel@tonic-gate 
484*7c478bd9Sstevel@tonic-gate #endif	/* __i386 */
485*7c478bd9Sstevel@tonic-gate 
486*7c478bd9Sstevel@tonic-gate /*
487*7c478bd9Sstevel@tonic-gate  * Convenient selector definitions.
488*7c478bd9Sstevel@tonic-gate  */
489*7c478bd9Sstevel@tonic-gate #define	KCS_SEL		SEL_GDT(GDT_KCODE, SEL_KPL)
490*7c478bd9Sstevel@tonic-gate #define	KDS_SEL		SEL_GDT(GDT_KDATA, SEL_KPL)
491*7c478bd9Sstevel@tonic-gate #define	UCS_SEL		SEL_GDT(GDT_UCODE, SEL_UPL)
492*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
493*7c478bd9Sstevel@tonic-gate #define	TEMP_CS64_SEL	SEL_GDT(TEMPGDT_KCODE64, SEL_KPL)
494*7c478bd9Sstevel@tonic-gate #define	U32CS_SEL	SEL_GDT(GDT_U32CODE, SEL_UPL)
495*7c478bd9Sstevel@tonic-gate #endif	/* __amd64 */
496*7c478bd9Sstevel@tonic-gate #define	UDS_SEL		SEL_GDT(GDT_UDATA, SEL_UPL)
497*7c478bd9Sstevel@tonic-gate #define	ULDT_SEL	SEL_GDT(GDT_LDT, SEL_KPL)
498*7c478bd9Sstevel@tonic-gate #define	KTSS_SEL	SEL_GDT(GDT_KTSS, SEL_KPL)
499*7c478bd9Sstevel@tonic-gate #define	DFTSS_SEL	SEL_GDT(GDT_DBFLT, SEL_KPL)
500*7c478bd9Sstevel@tonic-gate #define	KFS_SEL		SEL_GDT(GDT_NULL, SEL_KPL)
501*7c478bd9Sstevel@tonic-gate #define	KGS_SEL		SEL_GDT(GDT_GS, SEL_KPL)
502*7c478bd9Sstevel@tonic-gate #define	LWPFS_SEL	SEL_GDT(GDT_LWPFS, SEL_UPL)
503*7c478bd9Sstevel@tonic-gate #define	LWPGS_SEL	SEL_GDT(GDT_LWPGS, SEL_UPL)
504*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
505*7c478bd9Sstevel@tonic-gate #define	B64CODE_SEL	SEL_GDT(GDT_B64CODE, SEL_KPL)
506*7c478bd9Sstevel@tonic-gate #else
507*7c478bd9Sstevel@tonic-gate #define	BOOTCODE_SEL	SEL_GDT(GDT_BOOTCODE, SEL_KPL)
508*7c478bd9Sstevel@tonic-gate #define	BOOTFLAT_SEL	SEL_GDT(GDT_BOOTFLAT, SEL_KPL)
509*7c478bd9Sstevel@tonic-gate #endif
510*7c478bd9Sstevel@tonic-gate 
511*7c478bd9Sstevel@tonic-gate /*
512*7c478bd9Sstevel@tonic-gate  * Entries in default Local Descriptor Table (LDT) for every process.
513*7c478bd9Sstevel@tonic-gate  */
514*7c478bd9Sstevel@tonic-gate #define	LDT_SYSCALL	0	/* call gate for libc.a (obsolete) */
515*7c478bd9Sstevel@tonic-gate #define	LDT_SIGCALL	1	/* EOL me, call gate for static sigreturn */
516*7c478bd9Sstevel@tonic-gate #define	LDT_RESVD1	2	/* old user %cs */
517*7c478bd9Sstevel@tonic-gate #define	LDT_RESVD2	3	/* old user %ds */
518*7c478bd9Sstevel@tonic-gate #define	LDT_ALTSYSCALL	4	/* alternate call gate for system calls */
519*7c478bd9Sstevel@tonic-gate #define	LDT_ALTSIGCALL	5	/* EOL me, alternate call gate for sigreturn */
520*7c478bd9Sstevel@tonic-gate #define	LDT_UDBASE	6	/* user descriptor base index */
521*7c478bd9Sstevel@tonic-gate #define	MINNLDT		64	/* Current min solaris ldt size */
522*7c478bd9Sstevel@tonic-gate #define	MAXNLDT		8192	/* max solaris ldt size */
523*7c478bd9Sstevel@tonic-gate 
524*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
525*7c478bd9Sstevel@tonic-gate 
526*7c478bd9Sstevel@tonic-gate #pragma	align	16(idt0)
527*7c478bd9Sstevel@tonic-gate extern	gate_desc_t	idt0[NIDT];
528*7c478bd9Sstevel@tonic-gate extern	desctbr_t	idt0_default_reg;
529*7c478bd9Sstevel@tonic-gate #pragma	align	16(gdt0)
530*7c478bd9Sstevel@tonic-gate extern	user_desc_t	gdt0[NGDT];
531*7c478bd9Sstevel@tonic-gate #pragma	align	16(ldt0_default)
532*7c478bd9Sstevel@tonic-gate extern	user_desc_t	ldt0_default[MINNLDT];
533*7c478bd9Sstevel@tonic-gate extern	system_desc_t	ldt0_default_desc;
534*7c478bd9Sstevel@tonic-gate #pragma align	16(ldt0_default64)
535*7c478bd9Sstevel@tonic-gate extern user_desc_t	ldt0_default64[MINNLDT];
536*7c478bd9Sstevel@tonic-gate extern system_desc_t	ldt0_default64_desc;
537*7c478bd9Sstevel@tonic-gate extern user_desc_t	zero_udesc;
538*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
539*7c478bd9Sstevel@tonic-gate extern user_desc_t	zero_u32desc;
540*7c478bd9Sstevel@tonic-gate #endif
541*7c478bd9Sstevel@tonic-gate 
542*7c478bd9Sstevel@tonic-gate #pragma	align	16(ktss0)
543*7c478bd9Sstevel@tonic-gate extern struct tss ktss0;
544*7c478bd9Sstevel@tonic-gate 
545*7c478bd9Sstevel@tonic-gate #if defined(__i386)
546*7c478bd9Sstevel@tonic-gate extern struct tss dftss0;
547*7c478bd9Sstevel@tonic-gate #endif	/* __i386 */
548*7c478bd9Sstevel@tonic-gate 
549*7c478bd9Sstevel@tonic-gate extern void div0trap(), dbgtrap(), nmiint(), brktrap(), ovflotrap();
550*7c478bd9Sstevel@tonic-gate extern void boundstrap(), invoptrap(), ndptrap(), syserrtrap();
551*7c478bd9Sstevel@tonic-gate extern void invaltrap(), invtsstrap(), segnptrap(), stktrap();
552*7c478bd9Sstevel@tonic-gate extern void gptrap(), pftrap(), ndperr();
553*7c478bd9Sstevel@tonic-gate extern void overrun(), resvtrap();
554*7c478bd9Sstevel@tonic-gate extern void _start(), cmnint();
555*7c478bd9Sstevel@tonic-gate extern void achktrap(), mcetrap();
556*7c478bd9Sstevel@tonic-gate extern void xmtrap();
557*7c478bd9Sstevel@tonic-gate extern void fasttrap();
558*7c478bd9Sstevel@tonic-gate extern void dtrace_fasttrap(), dtrace_ret();
559*7c478bd9Sstevel@tonic-gate 
560*7c478bd9Sstevel@tonic-gate #if !defined(__amd64)
561*7c478bd9Sstevel@tonic-gate extern void pentium_pftrap();
562*7c478bd9Sstevel@tonic-gate #endif
563*7c478bd9Sstevel@tonic-gate 
564*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
565*7c478bd9Sstevel@tonic-gate 
566*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
567*7c478bd9Sstevel@tonic-gate }
568*7c478bd9Sstevel@tonic-gate #endif
569*7c478bd9Sstevel@tonic-gate 
570*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SEGMENTS_H */
571