-
Notifications
You must be signed in to change notification settings - Fork 2
/
x86_desc.S
118 lines (87 loc) · 2.21 KB
/
x86_desc.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# x86_desc.S - Set up x86 segment descriptors, descriptor tables
# vim:ts=4 noexpandtab
#define ASM 1
#include "x86_desc.h"
.text
.globl ldt_size, tss_size
.globl gdt_desc, ldt_desc, tss_desc
.globl tss, tss_desc_ptr, ldt, ldt_desc_ptr
.globl gdt_ptr
.globl idt_desc_ptr, idt
.globl gdt_desc_ptr, globldt
.align 4
tss_size:
.long tss_bottom - tss - 1
ldt_size:
.long ldt_bottom - ldt - 1
.word 0 # Padding
ldt_desc:
.word KERNEL_LDT
.long ldt
.align 4
tss:
_tss:
.rept 104
.byte 0
.endr
tss_bottom:
.align 16
gdt:
_gdt:
# First GDT entry cannot be used
.quad 0
# NULL entry
.quad 0
# Segmentation will not be used
# CS and DS both are 0-4GB r/w segments
#
# The layout is (from Intel IA-32 reference manual):
# 31 24 23 22 21 20 19 16 15 14 13 12 11 8 7 0
# |----------------------------------------------------------------------|
# | | | D | | A | Seg | | D | | | |
# | Base 31:24 | G | / | 0 | V | Limit | P | P | S | Type | Base 23:16 |
# | | | B | | L | 19:16 | | L | | | |
# |----------------------------------------------------------------------|
#
# |----------------------------------------------------------------------|
# | | |
# | Base 15:0 | Segment Limit 15:0 |
# | | |
# |----------------------------------------------------------------------|
gdt_ptr:
# Set up an entry for kernel CS
.quad 0x00CF9A000000FFFF
# Set up an entry for kernel DS
.quad 0x00CF92000000FFFF
# Set up an entry for user CS
.quad 0x00CFFA000000FFFF
# Set up an entry for user DS
.quad 0x00CFF2000000FFFF
# Set up an entry for TSS
tss_desc_ptr:
.quad 0
# Set up one LDT
ldt_desc_ptr:
.quad 0
gdt_bottom:
gdt_desc_ptr: # gdt descriptor pointer
.word gdt_bottom - gdt - 1 # length
.long gdt # pointer
.align 16
ldt:
.rept 4
.quad 0
.endr
ldt_bottom:
.align 4
.word 0 # Padding
idt_desc_ptr:
.word idt_bottom - idt - 1
.long idt
.align 16
idt:
_idt:
.rept NUM_VEC
.quad 0
.endr
idt_bottom: