source: vendor/emx/current/src/dos/tables.asm

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 17.8 KB
Line 
1;
2; TABLES.ASM -- Protected mode tables
3;
4; Copyright (c) 1991-1999 by Eberhard Mattes
5;
6; This file is part of emx.
7;
8; emx is free software; you can redistribute it and/or modify it
9; under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2, or (at your option)
11; any later version.
12;
13; emx is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17;
18; You should have received a copy of the GNU General Public License
19; along with emx; see the file COPYING. If not, write to
20; the Free Software Foundation, 59 Temple Place - Suite 330,
21; Boston, MA 02111-1307, USA.
22;
23; See emx.asm for a special exception.
24;
25
26;
27; Global descriptor table
28; Local descriptor tables
29; Task state segment
30;
31
32__TABLES = 1
33 INCLUDE EMX.INC
34 INCLUDE SIGNAL.INC
35 INCLUDE PROCESS.INC
36 INCLUDE PMINT.INC
37 INCLUDE TABLES.INC
38 INCLUDE HEADERS.INC
39 INCLUDE EXCEPT.INC
40 INCLUDE MISC.INC
41
42
43 PUBLIC GDT_PTR, GDT_LIN
44 PUBLIC IDT_PTR, IDT_LIN
45 PUBLIC REAL_IDT_PTR
46 PUBLIC GDT, LDTS, IDT, BASE_TABLE
47 PUBLIC G_VCPI_DESC, G_ENV_DESC, G_PHYS_DESC, G_LIN_MAP_DESC
48 PUBLIC G_SWAP_BMP_DESC, G_PAGEDIR_DESC, G_VIDEO_DESC
49 PUBLIC G_PAGE_BMP_DESC, G_TSS_DESC, G_TSS_MEM_DESC
50 PUBLIC G_TMP1_DESC, G_TMP2_DESC
51 PUBLIC G_BUF1_DESC, G_BUF2_DESC
52 PUBLIC TSS_BUSY
53 PUBLIC TSS_EX8_CR3, TSS_EX10_CR3
54
55SV_DATA SEGMENT
56
57GDT_PTR LABEL FWORD
58 WORD END_GDT - GDT - 1 ; Limit of GDT
59GDT_LIN LABEL DWORD
60 WORD GDT, 0 ; Linear address of GDT
61
62IDT_PTR LABEL FWORD
63 WORD END_IDT - IDT - 1 ; Limit of IDT
64IDT_LIN LABEL DWORD
65 WORD IDT, 0 ; Linear address of IDT
66
67REAL_IDT_PTR LABEL FWORD
68 WORD 03FFH ; limit of real-mode IDT
69 DWORD 0 ; Linear address
70
71
72 DALIGN 8
73
74GDT LABEL QWORD
75;
76; The null selector (G_NULL_SEL)
77;
78 QWORD 0
79;
80; The GDT as memory segment (G_GDT_MEM_SEL)
81;
82BTD1 WORD END_GDT-GDT-1 ; Limit (0..15)
83 WORD GDT ; Base (0..15)
84 BYTE 0 ; Base (16..23)
85 BYTE 93H ; Access
86 BYTE 0 ; Granularity
87 BYTE 0 ; Base (24..31)
88;
89; The IDT (G_IDT_SEL), not used, but convenient for debugging
90;
91 QWORD 0
92;
93; Accessing physical memory by physical addresses (G_PHYS_SEL, see note 1)
94;
95G_PHYS_DESC WORD 0FFFFH ; Limit (0..15)
96 WORD 0 ; Base (0..15)
97 BYTE 0 ; Base (16..23)
98 BYTE 93H ; Access
99 BYTE 0CFH ; Granularity
100 BYTE 0 ; Base (24..31)
101;
102; Supervisor code (G_SV_CODE_SEL)
103;
104BTC1 WORD 0FFFFH ; Limit (0..15)
105 WORD 0 ; Base (0..15)
106 BYTE 0 ; Base (16..23)
107 BYTE 9BH ; Access
108 BYTE 0 ; Granularity
109 BYTE 0 ; Base (24..31)
110;
111; Used for switch to real mode (G_REAL_SEL)
112;
113 WORD 0FFFFH ; Limit (0..15)
114 WORD 0 ; Base (0..15)
115 BYTE 0 ; Base (16..23)
116 BYTE 93H ; Access
117 BYTE 0 ; Granularity
118 BYTE 0 ; Base (24..31)
119;
120; Initialization/termination code (G_INIT_SEL)
121;
122BTI1 WORD 0FFFFH ; Limit (0..15) !!! (return to RM)
123 WORD 0 ; Base (0..15)
124 BYTE 0 ; Base (16..23)
125 BYTE 9BH ; Access
126 BYTE 0 ; Granularity
127 BYTE 0 ; Base (24..31)
128;
129; Supervisor data (G_SV_DATA_SEL)
130;
131BTD3 WORD 0FFFFH ; Limit (0..15)
132 WORD 0 ; Base (0..15)
133 BYTE 0 ; Base (16..23)
134 BYTE 93H ; Access
135 BYTE 0 ; Granularity
136 BYTE 0 ; Base (24..31)
137;
138; Supervisor stack (G_SV_STACK_SEL)
139;
140BTS1 WORD OFFSET SV_TOS-1 ; Limit (0..15)
141 WORD 0 ; Base (0..15)
142 BYTE 0 ; Base (16..23)
143 BYTE 93H ; Access
144 BYTE 40H ; Granularity (see note 2)
145 BYTE 0 ; Base (24..31)
146;
147; Video memory (G_VIDEO_SEL)
148;
149G_VIDEO_DESC WORD 4000 - 1 ; Limit (0..15)
150 WORD 0 ; Base (0..15)
151 BYTE 0BH ; Base (16..23)
152 BYTE 93H ; Access
153 BYTE 0 ; Granularity
154 BYTE 0 ; Base (24..31)
155;
156; The TSS (G_TSS_SEL)
157;
158G_TSS_DESC WORD END_TSS-TSS-1 ; Limit (0..15)
159 WORD TSS ; Base (0..15)
160 BYTE 0 ; Base (16..23)
161TSS_BUSY BYTE 89H ; Access
162 BYTE 0 ; Granularity
163 BYTE 0 ; Base (24..31)
164;
165; Three segments for VCPI server (G_SERVER_SEL)
166;
167G_VCPI_DESC QWORD 3 DUP (0)
168;
169; The DOS environment (G_ENV_SEL)
170;
171G_ENV_DESC QWORD 0
172;
173; The HDR_SEG segment (G_HDR_SEL)
174;
175BTH1 WORD SIZE BIND_HEADER - 1
176 WORD 0 ; Base (0..15)
177 BYTE 0 ; Base (16..23)
178 BYTE 91H ; Access
179 BYTE 0 ; Granularity
180 BYTE 0 ; Base (24..31)
181;
182; Two temporary entries (G_TMP1_SEL, G_TMP2_SEL)
183;
184G_TMP1_DESC QWORD 0 ; G_TMP1_SEL
185G_TMP2_DESC QWORD 0 ; G_TMP2_SEL
186;
187; Zero based segment (4G bytes) for returning from protected mode
188; to real mode under VCPI (G_ZERO_SEL)
189;
190 WORD 0FFFFH ; Limit (0..15)
191 WORD 0 ; Base (0..15)
192 BYTE 0 ; Base (16..23)
193 BYTE 93H ; Access
194 BYTE 0CFH ; Granularity
195 BYTE 0 ; Base (24..31)
196;
197; 1st communication buffer (G_BUF1_SEL)
198;
199G_BUF1_DESC WORD 0FFFFH ; Limit 0..15
200 WORD 0 ; Base (0..15)
201 BYTE 0 ; Base (16..23)
202 BYTE 93H ; Access
203 BYTE 0 ; Granularity
204 BYTE 0 ; Base (24..31)
205;
206; 2nd communication buffer (G_BUF2_SEL)
207;
208G_BUF2_DESC WORD 0FFFH+OFFSET_1 ; Limit 0..15
209 WORD 0 ; Base (0..15)
210 BYTE 0 ; Base (16..23)
211 BYTE 93H ; Access
212 BYTE 0 ; Granularity
213 BYTE 0 ; Base (24..31)
214;
215; The page directory (and swapper info directory, G_PAGEDIR_SEL)
216;
217G_PAGEDIR_DESC WORD 2*4096-1 ; Limit 0..15
218 WORD 0 ; Base (0..15)
219 BYTE 0 ; Base (16..23)
220 BYTE 93H ; Access
221 BYTE 0 ; Granularity
222 BYTE 0 ; Base (24..31)
223;
224; The swapper file bitmap (G_SWAP_BMP_SEL)
225;
226G_SWAP_BMP_DESC QWORD 0
227;
228; The linear address map (G_LIN_MAP_SEL)
229;
230G_LIN_MAP_DESC WORD 4096-1 ; Limit 0..15
231 WORD 0 ; Base (0..15)
232 BYTE 0 ; Base (16..23)
233 BYTE 93H ; Access
234 BYTE 0 ; Granularity
235 BYTE 0 ; Base (24..31)
236;
237; The free page bitmap (G_PAGE_BMP_SEL)
238;
239G_PAGE_BMP_DESC QWORD 0
240;
241; The TSS for exception 8 (double fault, G_TSS_EX8_SEL)
242;
243BTD5 WORD END_TSS_EX8 - TSS_EX8 - 1 ; Limit (0..15)
244 WORD TSS_EX8 ; Base (0..15)
245 BYTE 0 ; Base (16..23)
246 BYTE 89H ; Access
247 BYTE 0 ; Granularity
248 BYTE 0 ; Base (24..31)
249;
250; The TSS for exception 10 (invalid TSS, G_TSS_EX10_SEL)
251;
252BTD6 WORD END_TSS_EX10 - TSS_EX10 - 1 ; Limit (0..15)
253 WORD TSS_EX10 ; Base (0..15)
254 BYTE 0 ; Base (16..23)
255 BYTE 89H ; Access
256 BYTE 0 ; Granularity
257 BYTE 0 ; Base (24..31)
258;
259; Stack for exception 8 task (G_EX8_STACK_SEL)
260;
261BTS8 WORD OFFSET EX8_TOS-1 ; Limit (0..15)
262 WORD 0 ; Base (0..15)
263 BYTE 0 ; Base (16..23)
264 BYTE 93H ; Access
265 BYTE 40H ; Granularity
266 BYTE 0 ; Base (24..31)
267;
268; Stack for exception 10 task (G_EX10_STACK_SEL)
269;
270BTS10 WORD OFFSET EX10_TOS-1 ; Limit (0..15)
271 WORD 0 ; Base (0..15)
272 BYTE 0 ; Base (16..23)
273 BYTE 93H ; Access
274 BYTE 40H ; Granularity
275 BYTE 0 ; Base (24..31)
276;
277; The TSS as memory segment (G_TSS_MEM_SEL)
278;
279G_TSS_MEM_DESC WORD END_TSS-TSS-1 ; Limit (0..15)
280 WORD TSS ; Base (0..15)
281 BYTE 0 ; Base (16..23)
282 BYTE 93H ; Access
283 BYTE 0 ; Granularity
284 BYTE 0 ; Base (24..31)
285;
286; The lower 1MB (+64KB)
287;
288 WORD 010FH ; Limit (0..15)
289 WORD 0 ; Base (0..15)
290 BYTE 0 ; Base (16..23)
291 BYTE 91H ; Access (read only)
292 BYTE 0C0H ; Granularity
293 BYTE 0 ; Base (24..31)
294;
295; One LDT per process (G_LDT_SEL, the first entry, is already initialized,
296; because it is used for protected mode startup -- only its existence is
297; required)
298;
299BTD8 WORD 8*LDT_ENTRIES-1 ; Limit (0..15)
300 WORD LDTS ; Base (0..15)
301 BYTE 0 ; Base (16..23)
302 BYTE 82H ; Access
303 BYTE 0 ; Granularity
304 BYTE 0 ; Base (24..31)
305
306 QWORD (MAX_PROCESSES-1) DUP (0)
307
308END_GDT LABEL QWORD
309
310
311;
312; Note 1: When running under VCPI, the base address of the physical
313; memory segment will be changed. See INIT_VCPI for details.
314; The limit will be also changed if not running under VCPI,
315; see INIT_PAGING.
316;
317; Note 2: Setting the B bit is required to make a stack-switch to
318; an inner privilege level load ESP instead of SP from the
319; TSS. With non-zero upper word of ESP the VCPI server doesn't
320; work (tested with CEMM.SYS: crash!).
321;
322LDTS QWORD (MAX_PROCESSES * LDT_ENTRIES) DUP (0)
323
324;
325; The IDT will be filled in by this program. See RMINT module.
326;
327IDT LABEL QWORD
328 QWORD 256 DUP (?)
329END_IDT LABEL QWORD
330
331
332; This TSS is used only for holding the ring 0 SS:ESP. After
333; switching to protected mode, it is replaced with a dynamically
334; allocated TSS which adds an I/O permission bitmap.
335;
336TSS LABEL BYTE
337 DWORD 0 ; Back pointer
338 WORD OFFSET SV_TOS, 0 ; STK0
339 WORD G_SV_STACK_SEL, 0
340 QWORD 0 ; STK1
341 QWORD 0 ; STK2
342 DWORD 0 ; CR3
343 DWORD 0 ; EIP
344 DWORD 0 ; EFLAGS
345 DWORD 0 ; EAX
346 DWORD 0 ; ECX
347 DWORD 0 ; EDX
348 DWORD 0 ; EBX
349 DWORD 0 ; ESP
350 DWORD 0 ; EBP
351 DWORD 0 ; ESI
352 DWORD 0 ; EDI
353 DWORD 0 ; ES
354 DWORD 0 ; CS
355 DWORD 0 ; SS
356 DWORD 0 ; DS
357 DWORD 0 ; FS
358 DWORD 0 ; GS
359 DWORD 0 ; LDT
360 WORD 0 ; DTB
361 WORD $ + 2 - TSS ; I/O bitmap
362 BYTE 0FFH ; End of bitmap
363END_TSS LABEL BYTE
364
365
366;
367; This TSS is used for exception 8 (double fault)
368;
369TSS_EX8 LABEL BYTE
370 DWORD 0 ; Back pointer
371 QWORD 0 ; STK0 (no priv. level chg!)
372 QWORD 0 ; STK1
373 QWORD 0 ; STK2
374TSS_EX8_CR3 DWORD 0 ; CR3
375 DWORD OFFSET EXCEPT_TASK ; EIP
376 DWORD 0 ; EFLAGS
377 DWORD 8 ; EAX (exception #)
378 DWORD 0 ; ECX
379 DWORD 0 ; EDX
380 DWORD 0 ; EBX
381 DWORD OFFSET EX8_TOS ; ESP
382 DWORD 0 ; EBP
383 DWORD 0 ; ESI
384 DWORD 0 ; EDI
385 DWORD G_SV_DATA_SEL ; ES
386 DWORD G_SV_CODE_SEL ; CS
387 DWORD G_EX8_STACK_SEL ; SS
388 DWORD G_SV_DATA_SEL ; DS
389 DWORD G_SV_DATA_SEL ; FS
390 DWORD G_SV_DATA_SEL ; GS
391 DWORD 0 ; LDT
392 WORD 0 ; DTB
393 WORD $ + 2 - TSS_EX8 ; I/O bitmap
394 BYTE 0FFH ; End of bitmap
395END_TSS_EX8 LABEL BYTE
396
397
398;
399; This TSS is used for exception 10 (invalid TSS)
400;
401TSS_EX10 LABEL BYTE
402 DWORD 0 ; Back pointer
403 QWORD 0 ; STK0 (no priv. level chg!)
404 QWORD 0 ; STK1
405 QWORD 0 ; STK2
406TSS_EX10_CR3 DWORD 0 ; CR3
407 DWORD OFFSET EXCEPT_TASK ; EIP
408 DWORD 0 ; EFLAGS
409 DWORD 10 ; EAX (exception #)
410 DWORD 0 ; ECX
411 DWORD 0 ; EDX
412 DWORD 0 ; EBX
413 DWORD OFFSET EX10_TOS ; ESP
414 DWORD 0 ; EBP
415 DWORD 0 ; ESI
416 DWORD 0 ; EDI
417 DWORD G_SV_DATA_SEL ; ES
418 DWORD G_SV_CODE_SEL ; CS
419 DWORD G_EX10_STACK_SEL ; SS
420 DWORD G_SV_DATA_SEL ; DS
421 DWORD G_SV_DATA_SEL ; FS
422 DWORD G_SV_DATA_SEL ; GS
423 DWORD 0 ; LDT
424 WORD 0 ; DTB
425 WORD $ + 2 - TSS_EX10 ; I/O bitmap
426 BYTE 0FFH ; End of bitmap
427END_TSS_EX10 LABEL BYTE
428
429
430;
431; This table is used for converting segment/offset pairs to linear addresses
432; in descriptor tables. The first word of a pair is the real-mode segment,
433; the second word points to the descriptor table entry (ASSUME DS:SV_DATA),
434; which already contains the offset in the base 0..15 field.
435;
436BASE_TABLE LABEL WORD
437 WORD SV_DATA, BTD1
438 WORD SV_DATA, BTD3
439 WORD SV_DATA, G_TSS_DESC
440 WORD SV_DATA, BTD5
441 WORD SV_DATA, BTD6
442 WORD SV_DATA, G_TSS_MEM_DESC
443 WORD SV_DATA, BTD8
444 WORD SV_STACK, BTS1
445 WORD SV_CODE, BTC1
446 WORD INIT_CODE, BTI1
447 WORD HDR_SEG, BTH1
448 WORD EX8_STACK, BTS8
449 WORD EX10_STACK, BTS10
450 WORD 0, 0 ; End of table
451
452
453SV_DATA ENDS
454
455
456EX8_STACK SEGMENT
457 WORD 256 DUP (?)
458EX8_TOS LABEL WORD
459EX8_STACK ENDS
460
461
462EX10_STACK SEGMENT
463 WORD 256 DUP (?)
464EX10_TOS LABEL WORD
465EX10_STACK ENDS
466
467
468 END
Note: See TracBrowser for help on using the repository browser.