-
Notifications
You must be signed in to change notification settings - Fork 47
/
data16.asm
167 lines (135 loc) · 6.46 KB
/
data16.asm
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
SEGMENT DATA16 USE16
; --------------------------------------- 16 bit data ---------------------------------------
a20enabled db 0
numcpus db 0
somecpu A_CPU 0,0,0,0
cpusstructize = $-(somecpu)
CpusOfs:
cpus db cpusstructize*64 dup(0)
MainCPUAPIC db 0
LocalApic dd 0xFEE00000
RsdtAddress dd 0
XsdtAddress dq 0
ProcedureStart dd 0
FromThread1 db 0
FromThread2 db 0
FromThread3 db 0
FromThread4 db 0
FromThread5 db 0
FromThread6 db 0
of0s dw 0
of0o dw 0
LongModeSupported db 0
Support1GBPaging db 0
VMXSupported db 0
VMXUnrestrictedSupported db 0
Paging32InXMS dd 0
Paging32InXMSH dw 0
Paging64InXMS dd 0
Paging64InXMSH dw 0
PagingVMInXMS dd 0
PagingVMInXMSH dw 0
; --------------------------------------- VMX tests---------------------------------------
vmt1 db 0 ; existence
vmt2 db 0 ; protected mode guest
vmt3 db 0 ; unrestricted guest
vmm1 db "[VMX] ","$"
vmm2 db "[VMX Launch] ","$"
; --------------------------------------- 16 bit mutexes ---------------------------------------
mut_ipi db 0xFF
mut_1 db 0xFF
mut_i21 db 0xFF
; --------------------------------------- Messages ---------------------------------------
rm1 db "[Real mode] ","$"
pm1 db "[Protected mode] ","$"
lm1 db "[Long mode] ","$"
ap1 db "Apic 1 found ","$"
ap2 db "Apic 2 found ","$"
cpuf db "CPU $"
thrm1 db "Message from real mode thread",0dh,0ah,"$"
thrm2 db "Message from real mode thread called from protected mode",0dh,0ah,"$"
thrm3 db "Message from real mode thread called from long mode",0dh,0ah,"$"
thr1 db "[T1 RM] $"
thr2 db "[T2 RM] $"
thr3 db "[T3 PM->RM] $"
thr4 db "[T4 LM->RM] $"
thr5 db "[T5 RM->PM] $"
thr6 db "[T6 RM->LM] $"
resm db "DMMI Server Active",0dh,0ah,"$"
resm2 db "DMMI Server Already installed",0dh,0ah,"$"
a20off db "Restoring A20",0dh,0ah,"$"
crlf db 0dh,0ah,"$"
; --------------------------------------- GDT ---------------------------------------
gdt_start dw gdt_size
gdt_ptr dd 0
dummy_descriptor GDT_STR 0,0,0,0,0,0
code32_descriptor GDT_STR 0ffffh,0,0,9ah,0cfh,0 ; 4GB 32-bit code , 9ah = 10011010b = Present, DPL 00,No System, Code Exec/Read. 0cfh access = 11001111b = Big,32bit,<resvd 0>,1111 more size
data32_descriptor GDT_STR 0ffffh,0,0,92h,0cfh,0 ; 4GB 32-bit data, 92h = 10010010b = Presetn , DPL 00, No System, Data Read/Write
stack32_descriptor GDT_STR 0ffffh,0,0,92h,0cfh,0 ; 4GB 32-bit stack
code16_descriptor GDT_STR 0ffffh,0,0,9ah,0,0 ; 64k 16-bit code
data16_descriptor GDT_STR 0ffffh,0,0,92h,0,0 ; 64k 16-bit data
stack16_descriptor GDT_STR 0ffffh,0,0,92h,0,0 ; 64k 16-bit data
ldt_descriptor GDT_STR ldt_size,0,0,82h,0,0 ; pointer to LDT, 82h = 10000010b = Present, DPL 00, System , Type "0010b" = LDT entry
code64_descriptor GDT_STR 0ffffh,0,0,9ah,0afh,0 ; 16TB 64-bit code, 08cfh access = 01001111b = Big,64bit (0), 1111 more size
page32_descriptor GDT_STR 0ffffh,0,0,92h,0cfh,0 ; 4GB 32-bit data, 92h = 10010010b = Presetn , DPL 00, No System, Data Read/Write
page64_descriptor GDT_STR 0ffffh,0,0,92h,0cfh,0 ; 4GB 32-bit data, 92h = 10010010b = Presetn , DPL 00, No System, Data Read/Write
absd32_descriptor GDT_STR 0ffffh,0,0,92h,0cfh,0 ; 4GB 32-bit data, 92h = 10010010b = Presetn , DPL 00, No System, Data Read/Write
data64_descriptor GDT_STR 0ffffh,0,0,92h,0afh,0 ; 16TB 64-bit data, 08cfh access = 10001111b = Big,64bit (0), 1111 more size
absd64_descriptor GDT_STR 0ffffh,0,0,92h,0afh,0 ; 16TB 64-bit data, 08cfh access = 10001111b = Big,64bit (0), 1111 more size
tssd32_descriptor GDT_STR 0h,0,0,89h,040h,0 ; TSS segment in GDT
vmx32_descriptor GDT_STR 0ffffh,0,0,9ah,0cfh,0 ; 4GB 32-bit code , 9ah = 10011010b = Present, DPL 00,No System, Code Exec/Read. 0cfh access = 11001111b = Big,32bit,<resvd 0>,1111 more size
raw32_descriptor GDT_STR 0ffffh,0,0,9ah,0cfh,0 ; 4GB 32-bit code , 9ah = 10011010b = Present, DPL 00,No System, Code Exec/Read. 0cfh access = 11001111b = Big,32bit,<resvd 0>,1111 more size
tssd64_descriptor GDT_STR 0h,0,0,89h,040h,0 ; TSS segment in GDT
gdt_size = $-(dummy_descriptor)
dummy_idx = 0h ; dummy selector
code32_idx = 08h ; offset of 32-bit code segment in GDT
data32_idx = 10h ; offset of 32-bit data segment in GDT
stack32_idx = 18h ; offset of 32-bit stack segment in GDT
code16_idx = 20h ; offset of 16-bit code segment in GDT
data16_idx = 28h ; offset of 16-bit data segment in GDT
stack16_idx = 30h ; offset of 16-bit stack segment in GDT
ldt_idx = 38h ; offset of LDT in GDT
code64_idx = 40h ; offset of 64-bit code segment in GDT
page32_idx = 48h ; offset of 32-bit data segment in GDT
page64_idx = 50h ; offset of 64-bit data segment in GDT
absd32_idx = 58h ; offset of 32-bit data segment in GDT
data64_idx = 60h ; offset of 64-bit data segment in GDT
absd64_idx = 68h ; offset of 64-bit data segment in GDT
tssd32_idx = 70h ; TSS descriptor
vmx32_idx = 78h ; offset of 32-bit code segment in GDT
raw32_idx = 80h ; offset of 32-bit code segment in GDT
tssd64_idx = 88h ; TSS descriptor
data32_ldt_idx = 04h ; offset of 32-bit data segment in LDT
; And For Quick Unreal
gdt_startUNR dw gdt_sizeUNR
gdt_ptrUNR dd 0
dummy_descriptorUNR GDT_STR 0,0,0,0,0,0
code16_descriptorUNR GDT_STR 0ffffh,0,0,9ah,0,0
data32_descriptorUNR GDT_STR 0ffffh,0,0,92h,0cfh,0
gdt_sizeUNR = $-(dummy_descriptorUNR)
; --------------------------------------- IDT ---------------------------------------
idt_RM_start dw 0
idt_RM_ptr dd 0
idt_PM_start dw idt_size
idt_PM_ptr dd 0
interruptsall rb 256*8
;interruptsall IDT_STR 0,0,0,0,0
; rb 256 * 8
idt_size=$-(interruptsall)
idt_LM_start dw idtl_size
idt_LM_ptr db 0 dup(8)
interruptsall64 rb 256*16
idtl_size=$-(interruptsall64)
; --------------------------------------- PAGE ---------------------------------------
PhysicalPagingOffset32 dd 0
PhysicalPagingOffset64 dd 0
PhysicalEptOffset64 dq 0
; --------------------------------------- Supported ---------------------------------------
supportlm db "[Long Mode] ","$"
support1gb db "[1GB Paging] ","$"
supportvm db "[VM] ",0x0d,0x0a,"$"
;supportvmu db "VM Unrestricted Supported",0x0d,0x0a,"$"
; --- DISM
dismdata db 1000 dup (0) ; 1 type byte, 2 length, 3+data
dismdatac dd 0
dismdata2 db 2000 dup (0) ; Result