xref: /illumos-gate/usr/src/uts/i86pc/boot/boot_gdt.s (revision a92282e44f968185a6bba094d1e5fece2da819cf)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2020 Joyent, Inc.
27 */
28
29
30/*
31 * The boot GDT must remain in sync with the entries in intel/sys/segments.h; in
32 * particular kmdb uses B64CODE_SEL or B32CODE_SEL in perpetuity for its IDT
33 * entries (they're copied to the kernel's GDT in init_idt()).
34 *
35 * The GDT is effectively an array of user_desc_t entries.
36 */
37
38	.align 16
39	.data
40
41global_descriptor_table:
42	.long   0
43	.long   0
44
45	/* GDT_B32DATA: 32 bit flat data descriptor */
46	.value  0xFFFF	/* segment limit 0..15 */
47	.value  0x0000	/* segment base 0..15 */
48	.byte   0x0	/* segment base 16..23 */
49	.byte   0x92	/* P = 1, read/write data */
50	.byte   0xCF	/* G=1, B=1, Limit (16..19)=1111 */
51	.byte   0x0	/* segment base 24..32 */
52
53	/* GDT_B32CODE 32 bit flat code descriptor */
54	.value  0xFFFF	/* segment limit 0..15 */
55	.value  0x0000	/* segment base 0..15 */
56	.byte   0x0	/* segment base 16..23 */
57	.byte   0x9A	/* P=1, code, exec, readable */
58	.byte   0xCF	/* G=1, D=1, Limit (16..19)=1111 */
59	.byte   0x0	/* segment base 24..32 */
60
61	/*
62	 * GDT_B16CODE 16 bit code descriptor for doing BIOS calls
63	 */
64	.value  0xFFFF	/* segment limit 0..15 */
65	.value  0x0000	/* segment base 0..15 */
66	.byte   0x0	/* segment base 16..23 */
67	.byte   0x9A	/* P=1, code, exec, readable */
68	.byte   0x0F	/* G=0, D=0, Limit (16..19)=1111 */
69	.byte   0x0	/* segment base 24..32 */
70
71	/*
72	 * GDT_B16DATA 16 bit data descriptor for doing BIOS calls
73	 */
74	.value  0xFFFF	/* segment limit 0..15 */
75	.value  0x0000	/* segment base 0..15 */
76	.byte   0x0	/* segment base 16..23 */
77	.byte   0x92	/* P = 1, read/write data */
78	.byte   0x4F	/* G=0, D=1, Limit (16..19)=1111 */
79	.byte   0x0	/* segment base 24..32 */
80
81	/* GDT_B64CODE: 64 bit flat code descriptor - only L bit has meaning */
82	.value  0xFFFF	/* segment limit 0..15 */
83	.value  0x0000	/* segment base 0..15 */
84	.byte   0x0	/* segment base 16..23 */
85	.byte   0x9A	/* P=1, code, exec, readable */
86	.byte   0xAF	/* G=1, D=0, L=1, Limit (16..19)=1111 */
87	.byte   0x0	/* segment base 24..32 */
88
89	/*
90	 * unused
91	 */
92	.long	0
93	.long	0
94
95        /*
96         * GDT_BGSTMP -- an entry for kmdb to use during boot
97         * the fast reboot code uses this entry for memory copies, too.
98         */
99	.value  0x0001	/* segment limit 0..15 */
100
101	.globl fake_cpu_gdt_base_0_15
102fake_cpu_gdt_base_0_15:
103
104	.value  0x0000	/* segment base 0..15 */
105
106	.globl fake_cpu_gdt_base_16_23
107fake_cpu_gdt_base_16_23:
108	.byte   0x0	/* segment base 16..23 */
109	.byte   0x9A	/* P=1, code, exec, readable */
110	.byte   0xC0	/* G=1, D=1, Limit (16..19)=0000 */
111
112	.globl fake_cpu_gdt_base_24_31
113fake_cpu_gdt_base_24_31:
114	.byte   0x0	/* segment base 24..32 */
115
116/	.long	0
117/	.long	0
118
119
120/*
121 * This is a desctbr_t.
122 */
123gdt_info:
124	.value	gdt_info - global_descriptor_table - 1
125	.long	global_descriptor_table
126	.long   0		/* needed for 64 bit */
127
128fake_cpu:
129	.4byte 0
130	.4byte 0
131	.4byte 0
132	.globl fake_cpu_ptr
133fake_cpu_ptr:
134	.4byte 0
135	.skip 0x6c0, 0
136
137