Skip to content

Commit b096bd7

Browse files
author
Michael Chourdakis
committed
ΗΙΜΕΜ ψαλλσ
1 parent 8283c49 commit b096bd7

10 files changed

+189
-18
lines changed

asm.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
<None Include="gdt.asm" />
175175
<None Include="guest16.asm" />
176176
<None Include="guest32.asm" />
177+
<None Include="himem16.asm" />
177178
<None Include="idt.asm" />
178179
<None Include="int16.asm" />
179180
<None Include="int32.asm" />

asm.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,8 @@
153153
<None Include="int32.asm">
154154
<Filter>32 bit code</Filter>
155155
</None>
156+
<None Include="himem16.asm">
157+
<Filter>16 bit code</Filter>
158+
</None>
156159
</ItemGroup>
157160
</Project>

bx_enh_dbg.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ isLittleEndian = TRUE
1919
DefaultAsmLines = 512
2020
DumpWSIndex = 0
2121
DockOrder = 0x132
22-
ListWidthPix[0] = 465
23-
ListWidthPix[1] = 302
24-
ListWidthPix[2] = 243
22+
ListWidthPix[0] = 541
23+
ListWidthPix[1] = 371
24+
ListWidthPix[2] = 98
2525
FontName = System
2626
FontSize = -16
2727
MainWindow = 208, 0, 1234, 722

code16.asm

+70-10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ macro break16
66
xchg bx,bx
77
}
88

9+
INCLUDE 'himem16.asm'
910
INCLUDE 'unreal.asm'
1011
INCLUDE 'page16.asm'
1112
INCLUDE 'acpi16.asm'
@@ -63,6 +64,13 @@ sti
6364
mov bx,idt_RM_start
6465
sidt [bx]
6566

67+
; --------------------------------------- HIMEM.SYS test ---------------------------------------
68+
69+
call himemthere
70+
mov edx,1024
71+
call allochigh
72+
mov dx,cx
73+
call freehigh
6674

6775
; --------------------------------------- A20 line ---------------------------------------
6876

@@ -93,11 +101,23 @@ end if
93101

94102
; --------------------------------------- Protected Mode Find Page Entry ---------------------------------------
95103
xor ecx,ecx
104+
105+
if STATIC_PAGE32 = 0
106+
; Alloc 32 Pages high, preserve low ram
107+
mov edx,1024*20
108+
call allochigh
109+
mov [Paging32InXMSH],cx
110+
mov [Paging32InXMS],edi
111+
end if
112+
96113
LoopPMR:
97114
xor eax,eax
98-
mov ax,PAGE32
99-
shl eax,4
100-
add eax,Page32Null
115+
if STATIC_PAGE32 = 1
116+
linear eax,Page32Null,PAGE32
117+
else
118+
mov eax,[Paging32InXMS]
119+
end if
120+
101121
add eax,ecx
102122
mov ebx,eax
103123
shr eax,12
@@ -112,12 +132,23 @@ mov [PhysicalPagingOffset32],eax
112132
; --------------------------------------- Long Mode Find Page Entry ---------------------------------------
113133
if TEST_LONG > 0
114134

135+
if STATIC_PAGE64 = 0
136+
; Alloc 64 Pages high, preserve low ram
137+
mov edx,1024*40
138+
call allochigh
139+
mov [Paging64InXMSH],cx
140+
mov [Paging64InXMS],edi
141+
end if
142+
143+
115144
xor ecx,ecx
116145
LoopPMR2:
117146
xor eax,eax
118-
mov ax,PAGE64
119-
shl eax,4
120-
add eax,Page64Null
147+
if STATIC_PAGE64 = 1
148+
linear eax,Page64Null,PAGE64
149+
else
150+
mov eax,[Paging64InXMS]
151+
end if
121152
add eax,ecx
122153
mov ebx,eax
123154
shr eax,12
@@ -135,12 +166,23 @@ end if
135166
; --------------------------------------- VMX EPT Find Page Entry ---------------------------------------
136167
if TEST_VMX_1 > 0
137168

169+
if STATIC_PAGEVM = 0
170+
; Alloc VMX Pages high, preserve low ram
171+
mov edx,1024*100
172+
call allochigh
173+
mov [PagingVMInXMSH],cx
174+
mov [PagingVMInXMS],edi
175+
end if
176+
138177
xor ecx,ecx
139178
LoopPMR5:
140179
xor eax,eax
141-
mov ax,VMXPAGE64
142-
shl eax,4
143-
add eax,Ept64Null
180+
181+
if STATIC_PAGEVM = 1
182+
linear eax,Ept64Null,VMXPAGE64
183+
else
184+
mov eax,[PagingVMInXMS]
185+
end if
144186
add eax,ecx
145187
mov ebx,eax
146188
shr eax,12
@@ -230,7 +272,7 @@ jnz .nores
230272
pop ds
231273

232274
mov ax,0x4c00
233-
int 0x21
275+
int 0x21
234276

235277
mov ax,0x35F0
236278
int 0x21
@@ -286,6 +328,24 @@ lidt [di]
286328
sti
287329
; = END NO DEBUG HERE =
288330

331+
if STATIC_PAGE32 = 0
332+
; Free Paging 32 bit reserved in XMS
333+
mov dx,[Paging32InXMSH]
334+
call freehigh
335+
end if
336+
337+
if STATIC_PAGE64 = 0
338+
; Free Paging 64 bit reserved in XMS
339+
mov dx,[Paging64InXMSH]
340+
call freehigh
341+
end if
342+
343+
if STATIC_PAGEVM = 0
344+
; Free Paging VM bit reserved in XMS
345+
mov dx,[PagingVMInXMSH]
346+
call freehigh
347+
end if
348+
289349
; --------------------------------------- Quick Unreal ---------------------------------------
290350
push cs
291351
cli

config.asm

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ TEST_PM_SIPI = 1
55
TEST_LM_SIPI = 1
66
TEST_VMX_1 = 1
77
TEST_VMX_2 = 0
8+
9+
STATIC_PAGE32 = 0
10+
STATIC_PAGE64 = 0
11+
STATIC_PAGEVM = 1

data16.asm

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ FromThread6 db 0
2323
of0s dw 0
2424
of0o dw 0
2525

26+
27+
if STATIC_PAGE32 = 0
28+
Paging32InXMS dd 0
29+
Paging32InXMSH dw 0
30+
end if
31+
32+
if STATIC_PAGE64 = 0
33+
Paging64InXMS dd 0
34+
Paging64InXMSH dw 0
35+
end if
36+
37+
if STATIC_PAGEVM = 0
38+
PagingVMInXMS dd 0
39+
PagingVMInXMSH dw 0
40+
end if
41+
2642
; --------------------------------------- VMX tests---------------------------------------
2743
vmt1 db 0 ; existence
2844
vmt2 db 0 ; protected mode guest

data32.asm

+2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ d32 dd 0
1111

1212

1313

14+
if STATIC_PAGE32 = 1
1415
; --------------------------------------- 32 bit Page Segment ---------------------------------------
1516
SEGMENT PAGE32 USE32
1617
ORG 0
1718

1819
Page32Null dd 2050 DUP (0)
20+
end if
1921

data64.asm

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ TempData db 128 dup(0)
2222
; --------------------------------------- 64 bit Data another segment---------------------------------------
2323
SEGMENT ABSD64 USE64
2424

25+
26+
if STATIC_PAGE64 = 1
2527
; --------------------------------------- 64 bit Page Directory ---------------------------------------
2628
SEGMENT PAGE64 USE64
2729
ORG 0
2830

2931
Page64Null dq 3000 dup (0)
32+
end if
3033

34+
if STATIC_PAGEVM = 1
3135
;
3236
; --------------------------------------- VMX 64 bit EPT ---------------------------------------
3337
SEGMENT VMXPAGE64 USE64
3438
ORG 0
3539

3640
Ept64Null dq 8192 dup (0);
3741

38-
;EPT_PML4T dq 512 dup (0) ; 512 64-bit entries for EPT Top Level Page Directory
39-
;EPT_PDPT dq 512 dup (0) ; 512 64-bit entries for EPT Page Directory Pointer Table
40-
;EPT_PDT dq 512 dup (0) ; 512 64-bit entries for EPT Page Directory Table
41-
;EPT_PG dq 512 dup (0) ; 512 64-bit entries for EPT Page Table
42-
42+
end if
4343

4444

entry.exe

-31.3 KB
Binary file not shown.

himem16.asm

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
himaddrx:
3+
himaddr dd 0
4+
5+
himemthere:
6+
7+
mov ax,0x4300
8+
int 0x2F
9+
cmp al,0x80
10+
jz .hi
11+
12+
ret
13+
.hi:
14+
15+
mov ax,0x4310
16+
int 0x2F
17+
mov word [cs:himaddrx + 2],es
18+
mov word [cs:himaddrx],bx
19+
20+
mov al,0x80
21+
ret
22+
23+
allochigh: ; EDX = bytes, return ECX = handle, EDI = linear
24+
25+
xor ecx,ecx
26+
cmp [cs:himaddr],0
27+
jnz .useh
28+
29+
.noh:
30+
mov ecx,0
31+
mov edi,0
32+
ret
33+
34+
.useh:
35+
36+
mov ax,0x0900
37+
shr edx,10
38+
call far [cs:himaddr]
39+
cmp dx,0
40+
jz .noh
41+
42+
mov ax,0x0C00
43+
mov cx,dx
44+
xor edx,edx
45+
xor ebx,ebx
46+
mov dx,cx
47+
call far [cs:himaddr]
48+
cmp ax,1
49+
jz .okh
50+
51+
mov ax,0x0A00
52+
mov dx,cx
53+
call far [cs:himaddr]
54+
jmp .noh
55+
56+
.okh:
57+
xor edi,edi
58+
mov di,dx
59+
shl edi,16
60+
add edi,ebx
61+
62+
63+
ret
64+
65+
freehigh: ; DX = handle
66+
67+
cmp dx,0
68+
jz .noh
69+
70+
cmp [cs:himaddr],0
71+
jnz .useh
72+
73+
.noh:
74+
75+
ret
76+
77+
.useh:
78+
79+
mov ax,0x0D00
80+
call far [cs:himaddr]
81+
82+
mov ax,0x0A00
83+
call far [cs:himaddr]
84+
85+
ret

0 commit comments

Comments
 (0)