Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | |
3 | * | |
4 | * Mach Operating System | |
5 | * Copyright (c) 1992, 1991 Carnegie Mellon University | |
6 | * All Rights Reserved. | |
7 | * | |
8 | * Permission to use, copy, modify and distribute this software and its | |
9 | * documentation is hereby granted, provided that both the copyright | |
10 | * notice and this permission notice appear in all copies of the | |
11 | * software, derivative works or modified versions, and any portions | |
12 | * thereof, and that both notices appear in supporting documentation. | |
13 | * | |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
15 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
16 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
17 | * | |
18 | * Carnegie Mellon requests users of this software to return to | |
19 | * | |
20 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
21 | * School of Computer Science | |
22 | * Carnegie Mellon University | |
23 | * Pittsburgh PA 15213-3890 | |
24 | * | |
25 | * any improvements or extensions that they make and grant Carnegie Mellon | |
26 | * the rights to redistribute these changes. | |
27 | */ | |
28 | ||
29 | /* | |
30 | * HISTORY | |
a27f4645 RM |
31 | * $Log: table.c,v $ |
32 | * Revision 1.2 1993/07/11 12:02:25 andrew | |
33 | * Fixes from bde, including support for loading @ any MB boundary (e.g. a | |
34 | * kernel linked for 0xfe100000 will load at the 1MB mark) and read-ahead | |
35 | * buffering to speed booting from floppies. Also works with aha174x | |
36 | * controllers in enhanced mode. | |
37 | * | |
38 | * | |
39 | * 93/06/28 bde | |
40 | * Remove remaining magic numbers that depend on the load address. | |
41 | * IDTs and many more GDT entries to support my debugger. | |
42 | * | |
43 | * 93/06/27 bde | |
44 | * Remove unused Gdtr2. | |
45 | * Remove some magic numbers from Gdtr and Gdt. The boot loader may | |
46 | * override the ones related to the standard load address of 0x90000. | |
47 | * | |
48 | * Revision 1.1 1993/03/21 18:08:47 cgd | |
49 | * after 0.2.2 "stable" patches applied | |
50 | * | |
15637ed4 RG |
51 | * Revision 2.2 92/04/04 11:36:43 rpd |
52 | * Fix Intel Copyright as per B. Davies authorization. | |
53 | * [92/04/03 rvb] | |
54 | * Taken from 2.5 bootstrap. | |
55 | * [92/03/30 rvb] | |
56 | * | |
57 | * Revision 2.2 91/04/02 14:42:22 mbj | |
58 | * Add Intel copyright | |
59 | * [90/02/09 rvb] | |
60 | * | |
61 | */ | |
62 | ||
63 | /* | |
64 | Copyright 1988, 1989, 1990, 1991, 1992 | |
65 | by Intel Corporation, Santa Clara, California. | |
66 | ||
67 | All Rights Reserved | |
68 | ||
69 | Permission to use, copy, modify, and distribute this software and | |
70 | its documentation for any purpose and without fee is hereby | |
71 | granted, provided that the above copyright notice appears in all | |
72 | copies and that both the copyright notice and this permission notice | |
73 | appear in supporting documentation, and that the name of Intel | |
74 | not be used in advertising or publicity pertaining to distribution | |
75 | of the software without specific, written prior permission. | |
76 | ||
77 | INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE | |
78 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, | |
79 | IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR | |
80 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
81 | LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, | |
82 | NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | |
83 | WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
84 | */ | |
85 | ||
15637ed4 RG |
86 | /* Segment Descriptor |
87 | * | |
88 | * 31 24 19 16 7 0 | |
89 | * ------------------------------------------------------------ | |
90 | * | | |B| |A| | | |1|0|E|W|A| | | |
91 | * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 | | |
92 | * | | |D| |L| 19..16| | |1|1|C|R|A| | | |
93 | * ------------------------------------------------------------ | |
94 | * | | | | |
95 | * | BASE 15..0 | LIMIT 15..0 | | |
96 | * | | | | |
97 | * ------------------------------------------------------------ | |
98 | */ | |
99 | ||
100 | struct seg_desc { | |
101 | unsigned short limit_15_0; | |
102 | unsigned short base_15_0; | |
103 | unsigned char base_23_16; | |
a27f4645 RM |
104 | unsigned char p_dpl_type; |
105 | unsigned char g_b_a_limit; | |
15637ed4 RG |
106 | unsigned char base_31_24; |
107 | }; | |
108 | ||
a27f4645 | 109 | #define RUN 0 /* not really 0, but filled in at boot time */ |
15637ed4 | 110 | |
a27f4645 | 111 | struct seg_desc Gdt[] = { |
15637ed4 RG |
112 | {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* 0x0 : null */ |
113 | {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0}, /* 0x08 : kernel code */ | |
a27f4645 | 114 | /* 0x9E? */ |
15637ed4 | 115 | {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */ |
a27f4645 RM |
116 | /* 0x92? */ |
117 | {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */ | |
118 | {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */ | |
119 | {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */ | |
120 | /* More for bdb. */ | |
121 | {}, /* BIOS_CS_INDEX = 6 : null */ | |
122 | {}, /* BIOS_TMP_INDEX = 7 : null */ | |
123 | {}, /* TSS_INDEX = 8 : null */ | |
124 | {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* DS_286_INDEX = 9 */ | |
125 | {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* ES_286_INDEX = 10 */ | |
126 | {}, /* Unused = 11 : null */ | |
127 | {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */ | |
128 | {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0}, /* MONO_INDEX = 13 */ | |
129 | {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0}, /* DB_CS_INDEX = 14 */ | |
130 | {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0}, /* DB_CS16_INDEX = 15 */ | |
131 | {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* DB_DS_INDEX = 16 */ | |
132 | {8*18-1, RUN, RUN, 0x92, 0x40, 0x0}, /* GDT_INDEX = 17 */ | |
133 | }; | |
134 | ||
135 | struct idt_desc { | |
136 | unsigned short entry_15_0; | |
137 | unsigned short selector; | |
138 | unsigned char padding; | |
139 | unsigned char p_dpl_type; | |
140 | unsigned short entry_31_16; | |
141 | }; | |
15637ed4 | 142 | |
a27f4645 RM |
143 | struct idt_desc Idt[] = { |
144 | {}, /* Null (int 0) */ | |
145 | {RUN, 0x70, 0, 0x8E, 0}, /* DEBUG_VECTOR = 1 */ | |
146 | {}, /* Null (int 2) */ | |
147 | {RUN, 0x70, 0, 0xEE, 0}, /* BREAKPOINT_VECTOR = 3 */ | |
148 | }; | |
15637ed4 RG |
149 | |
150 | struct pseudo_desc { | |
151 | unsigned short limit; | |
152 | unsigned short base_low; | |
153 | unsigned short base_high; | |
154 | }; | |
155 | ||
a27f4645 RM |
156 | struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; |
157 | struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; | |
158 | struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; |