preparing for GRUB

git-svn-id: svn://kolibrios.org@846 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-08-07 09:14:48 +00:00
parent 94aed463d5
commit 94030d053e
11 changed files with 967 additions and 47 deletions

View File

@ -40,7 +40,7 @@ save_image:
mov [FDD_Track],0 ; Öèëèíäð
mov [FDD_Head],0 ; Ñòîðîíà
mov [FDD_Sector],1 ; Ñåêòîð
mov esi,RAMDISK
mov esi, [_rd_base]
call SeekTrack
save_image_1:
push esi

View File

@ -18,7 +18,7 @@ calculatefatchain:
pushad
mov esi,RAMDISK+512
mov esi, [_rd_fat]
mov edi,RAMDISK_FAT
fcnew:
@ -56,7 +56,7 @@ restorefatchain: ; restore fat chain
pushad
mov esi,RAMDISK_FAT
mov edi,RAMDISK+512
mov edi, [_rd_fat]
fcnew2:
mov eax,dword [esi]
@ -72,11 +72,11 @@ restorefatchain: ; restore fat chain
add edi,6
add esi,8
cmp edi,RAMDISK+512+4278 ;4274 bytes - all used FAT
cmp edi, [_rd_fat_end] ;4274 bytes - all used FAT
jb fcnew2
mov esi,RAMDISK+512 ; duplicate fat chain
mov edi,RAMDISK+512+0x1200
mov esi,[_rd_fat] ; duplicate fat chain
lea edi,[esi+0x1200]
mov ecx,1069 ;4274/4
cld
rep movsd
@ -208,7 +208,7 @@ fileread:
sub ecx,edx
fr_do1:
shl ebx,9
mov esi,RAMDISK+512*19
mov esi, [_rd_root]
add esi,ebx
shl ecx,7
cld
@ -252,7 +252,7 @@ fileread:
add eax,31 ;bootsector+2*fat+filenames
shl eax,9 ;*512
add eax,RAMDISK ;image base
add eax, [_rd_base] ;image base
mov ebx,[esp+8]
mov ecx,512 ;[esp+4]
@ -304,7 +304,7 @@ fileread:
;by Mihasik
;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx
mov edi,RAMDISK+512*18+512 ;Point at directory
mov edi, [_rd_root] ;Point at directory
cld
rd_newsearch:
mov esi,eax
@ -313,7 +313,7 @@ fileread:
je rd_ff
add cl,21
add edi,ecx
cmp edi,RAMDISK+512*33
cmp edi, [_rd_root_end]
jb rd_newsearch
mov eax,5 ;if file not found - eax=5
xor ebx,ebx
@ -750,12 +750,12 @@ bdfe_to_fat_entry:
ret
ramdisk_root_first:
mov edi, RAMDISK+512*19
mov edi, [_rd_root]
clc
ret
ramdisk_root_next:
add edi, 0x20
cmp edi, RAMDISK+512*33
cmp edi, [_rd_root_end]
cmc
ret
@ -793,7 +793,8 @@ ramdisk_notroot_first:
cmp eax, 2849
jae .err
shl eax, 9
lea edi, [eax+(31 shl 9)+RAMDISK]
lea edi, [eax+(31 shl 9)]
add edi, [_rd_base]
clc
ret
.err2:
@ -823,7 +824,8 @@ ramdisk_notroot_extend_dir:
mov [RAMDISK_FAT+ecx*2], di
mov [eax], edi
shl edi, 9
add edi, (31 shl 9)+RAMDISK
add edi, (31 shl 9)
add edi, [_rd_base]
mov [esp], edi
xor eax, eax
mov ecx, 128
@ -934,7 +936,7 @@ fs_RamdiskRead:
jae .eof
lea eax, [edi+31] ; bootsector+2*fat+filenames
shl eax, 9 ; *512
add eax, RAMDISK ; image base
add eax, [_rd_base] ; image base
; now eax points to data of cluster
sub ebx, 512
jae .skip
@ -1023,7 +1025,7 @@ fs_RamdiskReadFolder:
.main_loop:
mov edi, eax
shl edi, 9
add edi, RAMDISK
add edi, [_rd_base]
push eax
.l1:
call fat_get_name
@ -1048,7 +1050,7 @@ fs_RamdiskReadFolder:
@@:
mov edi, eax
shl edi, 9
add edi, RAMDISK
add edi, [_rd_base]
push eax
.do_bdfe:
inc dword [edx+8] ; new file found
@ -1694,7 +1696,8 @@ fs_RamdiskRewrite:
cmp byte [esp+16+20+28], 0
jnz .writedir
shl eax, 9
add eax, RAMDISK+31*512
add eax, 31*512
add eax, [_rd_base]
.writefile:
mov ebx, edx
xchg eax, ebx
@ -1733,7 +1736,8 @@ fs_RamdiskRewrite:
.writedir:
mov edi, eax
shl edi, 9
add edi, RAMDISK+31*512
add edi, [_rd_base]
add edi, 31*512
mov esi, edx
mov ecx, 32/4
push ecx
@ -1882,7 +1886,8 @@ fs_RamdiskWrite:
@@:
mov eax, edi
shl eax, 9
add eax, RAMDISK+31*512+0x200
add eax, [_rd_base]
add eax, 31*512+0x200
sub eax, ebx
mov ebx, eax
mov eax, edx
@ -1936,7 +1941,8 @@ ramdisk_extend_file:
push eax edi
mov edi, eax
shl edi, 9
lea edi, [edi+RAMDISK+31*512+0x200+ecx]
add edi, [_rd_base]
lea edi, [edi+31*512+0x200+ecx]
neg ecx
xor eax, eax
rep stosb
@ -1978,7 +1984,8 @@ ramdisk_extend_file:
@@:
push edi
shl edi, 9
add edi, RAMDISK+31*512
add edi, [_rd_base]
add edi, 31*512
xor eax, eax
mov ecx, 512/4
rep stosd
@ -2082,7 +2089,8 @@ fs_RamdiskSetFileEnd:
push ecx
mov edi, ecx
shl edi, 9
lea edi, [edi+RAMDISK+31*512+eax+0x200]
add edi, [_rd_base]
lea edi, [edi+31*512+eax+0x200]
mov ecx, eax
neg ecx
xor eax, eax
@ -2195,7 +2203,8 @@ fs_RamdiskDelete:
push ebx
mov ebx, eax
shl ebx, 9
add ebx, RAMDISK + 31*0x200 + 2*0x20
add ebx, [_rd_base]
add ebx, 31*0x200 + 2*0x20
.checkempty:
cmp byte [ebx], 0
jz .empty
@ -2209,7 +2218,8 @@ fs_RamdiskDelete:
jz .empty
mov ebx, eax
shl ebx, 9
add ebx, RAMDISK + 31*0x200
add ebx, [_rd_base]
add ebx, 31*0x200
jmp .checkempty
.notempty:
pop ebx
@ -2235,7 +2245,8 @@ fs_RamdiskDelete:
pop [rd_prev_sector]
or [rd_prev_prev_sector], -1
shl edi, 9
add edi, RAMDISK + 31*0x200 + 0x200
add edi, [_rd_base]
add edi, 31*0x200 + 0x200
@@:
sub edi, 0x20
cmp byte [edi], 0xE5

View File

@ -14,13 +14,15 @@ saverd_fileinfo:
dd 0 ; (reserved)
dd 0 ; (reserved)
dd 1440*1024 ; size 1440 Kb
dd RAMDISK
dd 0 ; [_rd_base]
db 0
.name:
dd ?
endg
sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
call restorefatchain
mov eax, [_rd_base]
mov [saverd_fileinfo+4], eax
mov eax, saverd_fileinfo
mov [saverd_fileinfo.name], ecx
pushad

View File

@ -262,7 +262,6 @@ ScreenBPP equ (OS_BASE+0x000FBF1)
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
LFBAddress equ (OS_BASE+0x000FE80)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
Screen_Max_X equ (OS_BASE+0x000FE00)
Screen_Max_Y equ (OS_BASE+0x000FE04)
@ -295,7 +294,7 @@ TMP_BUFF equ (OS_BASE+0x0090000)
VGABasePtr equ (OS_BASE+0x00A0000)
RAMDISK equ (OS_BASE+0x0100000)
;RAMDISK equ (OS_BASE+0x0100000)
RAMDISK_FAT equ (OS_BASE+0x0280000)
FLOPPY_FAT equ (OS_BASE+0x0282000)

View File

@ -1073,7 +1073,7 @@ proc init_mtrr
mov ecx, 0x2FF
wrmsr ;disable all MTRR
mov eax, [MEM_AMOUNT]
mov eax, [_mem_amount]
; round eax up to next power of 2
dec eax
bsr ecx, eax

View File

@ -0,0 +1,720 @@
DWORD equ dword
WORD equ word
BYTE equ byte
PTR equ
_mem_counter equ (BOOT_VAR + 0x9100)
_mem_table equ (BOOT_VAR + 0x9104)
_spinlock_initialize:
mov eax, DWORD PTR [esp+4]
mov DWORD PTR [eax], 0
ret
_buddy_find_block:
push ebx
mov eax, DWORD PTR [eax+12]
mov ebx, ecx
sub edx, eax
sar edx, 2
imul ecx, edx, -858993459
lea eax, [eax+edx*4]
.L4:
cmp DWORD PTR [eax+12], ebx
jne .L7
sub ecx, 1
sub eax, 20
cmp ecx, -1
jne .L4
xor eax, eax
.L7:
pop ebx
ret
@buddy_system_free@8:
push ebp
mov ebp, edx
push edi
push esi
mov esi, edx
push ebx
sub esp, 8
mov ebx, DWORD PTR [edx+12]
mov DWORD PTR [esp+4], ecx
cmp BYTE PTR [ecx+24], bl
mov edi, ebx
je .L17
mov edx, DWORD PTR [ecx+12]
mov DWORD PTR [esp], edx
jmp .L15
.L30:
mov eax, 1
sal eax, cl
add edx, eax
mov eax, DWORD PTR [esp+4]
cmp edx, DWORD PTR [eax+8]
jae .L17
.L31:
lea eax, [edx+edx*4]
mov edx, DWORD PTR [esp]
lea ecx, [edx+eax*4]
cmp ebx, DWORD PTR [ecx+12]
jne .L17
mov eax, DWORD PTR [ecx+8]
test eax, eax
jne .L17
mov eax, DWORD PTR [ecx+4]
cmp esi, ecx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [esi+12], 255
mov DWORD PTR [ecx+12], 255
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx], 0
mov DWORD PTR [edx+4], eax
mov edx, ebp
mov DWORD PTR [ecx+4], 0
jb .L26
mov edx, ecx
.L26:
mov ecx, edi
mov esi, edx
movzx eax, cl
mov ebp, edx
lea ebx, [eax+1]
mov eax, DWORD PTR [esp+4]
mov DWORD PTR [edx+12], ebx
movzx edi, BYTE PTR [eax+24]
mov edx, edi
cmp dl, bl
je .L17
mov edi, ebx
.L15:
mov eax, esi
mov ecx, ebx
sub eax, DWORD PTR [esp]
sar eax, 2
imul edx, eax, -858993459
mov eax, edx
shr eax, cl
test al, 1
je .L30
mov eax, 1
mov ecx, ebx
sal eax, cl
sub edx, eax
mov eax, DWORD PTR [esp+4]
cmp edx, DWORD PTR [eax+8]
jb .L31
.L17:
mov ecx, edi
movzx edx, cl
mov ecx, DWORD PTR [esp+4]
mov eax, DWORD PTR [ecx+28+edx*8]
mov DWORD PTR [ebp], eax
lea eax, [ecx+28+edx*8]
mov DWORD PTR [ebp+4], eax
mov eax, DWORD PTR [ecx+28+edx*8]
mov DWORD PTR [ecx+28+edx*8], ebp
mov DWORD PTR [eax+4], ebp
add esp, 8
pop ebx
pop esi
pop edi
pop ebp
ret
@buddy_system_alloc_block@8:
push ebp
mov ebp, ecx
push edi
mov ecx, 255
push esi
mov eax, ebp
push ebx
sub esp, 4
mov DWORD PTR [esp], edx
call _buddy_find_block
mov ebx, eax
mov eax, DWORD PTR [eax+4]
mov edx, DWORD PTR [ebx]
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ebx]
mov DWORD PTR [ebx], 0
mov DWORD PTR [edx+4], eax
mov eax, DWORD PTR [ebx+12]
mov DWORD PTR [ebx+4], 0
test eax, eax
jne .L38
jmp .L34
.L35:
mov DWORD PTR [ebx+8], 1
mov edx, esi
mov ecx, ebp
call @buddy_system_free@8
mov eax, DWORD PTR [ebx+12]
mov DWORD PTR [ebx+8], 0
test eax, eax
je .L34
.L38:
lea ecx, [eax-1]
mov edx, DWORD PTR [esp]
mov eax, 20
sal eax, cl
lea edi, [ebx+eax]
mov eax, ebp
mov DWORD PTR [ebx+12], ecx
mov esi, edi
mov DWORD PTR [edi+12], ecx
mov ecx, 255
call _buddy_find_block
cmp edi, eax
jne .L35
mov esi, ebx
mov ebx, edi
jmp .L35
.L34:
mov DWORD PTR [ebx+8], 1
mov eax, ebx
add esp, 4
pop ebx
pop esi
pop edi
pop ebp
ret
_zone_release:
push edi
push esi
push ebx
mov esi, DWORD PTR [esp+16]
mov eax, DWORD PTR [esp+20]
mov edi, DWORD PTR [esp+24]
mov edx, DWORD PTR [esi+4]
add edi, eax
cmp edi, edx
jb .L48
mov ebx, edx
add ebx, DWORD PTR [esi+8]
cmp eax, ebx
ja .L48
cmp eax, edx
mov ecx, eax
jae .L44
mov ecx, edx
.L44:
cmp edi, ebx
jbe .L45
mov edi, ebx
.L45:
cmp ecx, edi
jae .L48
mov ebx, ecx
.L47:
mov edx, DWORD PTR [esi+12]
mov eax, ecx
add ebx, 1
sub eax, DWORD PTR [esi+4]
lea eax, [eax+eax*4]
mov DWORD PTR [edx+8+eax*4], 0
sub ecx, DWORD PTR [esi+4]
lea edx, [ecx+ecx*4]
mov ecx, esi
sal edx, 2
add edx, DWORD PTR [esi+12]
call @buddy_system_free@8
cmp edi, ebx
mov ecx, ebx
ja .L47
.L48:
pop ebx
pop esi
pop edi
ret
_zone_reserve:
push edi
push esi
push ebx
mov esi, DWORD PTR [esp+16]
mov eax, DWORD PTR [esp+20]
mov ebx, DWORD PTR [esp+24]
mov edx, DWORD PTR [esi+4]
add ebx, eax
cmp ebx, edx
jb .L61
mov ecx, edx
add ecx, DWORD PTR [esi+8]
cmp eax, ecx
ja .L61
cmp eax, edx
jae .L54
mov eax, edx
.L54:
cmp ebx, ecx
mov edi, ebx
jbe .L55
mov edi, ecx
.L55:
cmp eax, edi
jae .L61
mov ebx, eax
jmp .L57
.L58:
add ebx, 1
cmp edi, ebx
mov eax, ebx
jbe .L61
.L62:
mov edx, DWORD PTR [esi+4]
.L57:
sub eax, edx
lea eax, [eax+eax*4]
lea edx, [0+eax*4]
add edx, DWORD PTR [esi+12]
mov ecx, DWORD PTR [edx+8]
test ecx, ecx
jne .L58
add ebx, 1
mov ecx, esi
call @buddy_system_alloc_block@8
mov eax, ebx
sub DWORD PTR [esi+16], 1
cmp edi, ebx
ja .L62
.L61:
pop ebx
pop esi
pop edi
ret
@buddy_system_alloc@8:
sub esp, 12
mov DWORD PTR [esp], ebx
lea eax, [ecx+28+edx*8]
mov ebx, edx
mov DWORD PTR [esp+4], esi
mov esi, ecx
mov DWORD PTR [esp+8], edi
cmp DWORD PTR [ecx+32+edx*8], eax
je .L64
mov ecx, DWORD PTR [ecx+32+edx*8]
mov eax, DWORD PTR [ecx+4]
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx+8], 1
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx], 0
mov DWORD PTR [edx+4], eax
mov DWORD PTR [ecx+4], 0
.L66:
mov ebx, DWORD PTR [esp]
mov eax, ecx
mov esi, DWORD PTR [esp+4]
mov edi, DWORD PTR [esp+8]
add esp, 12
ret
.L64:
movzx eax, BYTE PTR [ecx+24]
cmp eax, edx
jne .L71
.L67:
xor ecx, ecx
jmp .L66
.L71:
lea edx, [edx+1]
call @buddy_system_alloc@8
test eax, eax
mov edi, eax
je .L67
mov ecx, DWORD PTR [eax+12]
mov edx, 20
mov DWORD PTR [eax+12], ebx
mov DWORD PTR [eax+8], 1
sub ecx, 1
sal edx, cl
mov ecx, esi
add edx, eax
mov DWORD PTR [edx+12], ebx
call @buddy_system_free@8
mov ecx, edi
jmp .L66
_zone_frame_alloc:
sub esp, 8
mov ecx, eax
mov DWORD PTR [esp], ebx
mov ebx, eax
mov DWORD PTR [esp+4], esi
mov esi, edx
call @buddy_system_alloc@8
mov ecx, esi
mov edx, 1
sal edx, cl
mov esi, DWORD PTR [esp+4]
sub DWORD PTR [ebx+16], edx
sub eax, DWORD PTR [ebx+12]
add DWORD PTR [ebx+20], edx
mov ebx, DWORD PTR [esp]
add esp, 8
sar eax, 2
imul eax, eax, -858993459
ret
_frame_set_parent:
mov eax, DWORD PTR [esp+4]
sub eax, DWORD PTR [_z_core+4]
mov ecx, DWORD PTR [esp+8]
mov edx, DWORD PTR [_z_core+12]
lea eax, [eax+eax*4]
mov DWORD PTR [edx+16+eax*4], ecx
ret
@zone_free@8:
sub esp, 8
lea edx, [edx+edx*4]
mov DWORD PTR [esp], ebx
sal edx, 2
mov ebx, ecx
mov DWORD PTR [esp+4], esi
add edx, DWORD PTR [ecx+12]
mov eax, DWORD PTR [edx+8]
mov esi, DWORD PTR [edx+12]
sub eax, 1
test eax, eax
mov DWORD PTR [edx+8], eax
jne .L79
call @buddy_system_free@8
mov eax, 1
mov ecx, esi
sal eax, cl
add DWORD PTR [ebx+16], eax
sub DWORD PTR [ebx+20], eax
.L79:
mov ebx, DWORD PTR [esp]
mov esi, DWORD PTR [esp+4]
add esp, 8
ret
@zone_alloc@8:
sub esp, 8
mov DWORD PTR [esp], ebx
mov ebx, ecx
mov DWORD PTR [esp+4], esi
pushf
pop esi
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
mov eax, ecx
call _zone_frame_alloc
mov edx, DWORD PTR [ebx+4]
mov DWORD PTR [ebx], 0
push esi
popf
mov ebx, DWORD PTR [esp]
add eax, edx
mov esi, DWORD PTR [esp+4]
sal eax, 12
add esp, 8
ret
alloc_page:
_alloc_page:
push ebx
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
push edx
xor edx, edx
mov eax, _z_core
call _zone_frame_alloc
pop edx
mov [_z_core], 0
push ebx
popf
pop ebx
sal eax, 12
ret
alloc_pages:
_alloc_pages@4:
push ebx
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
mov eax, DWORD PTR [esp+8]
add eax, 7
and eax, -8
xor ecx, ecx
bsr ecx, eax
inc ecx
push edx
mov edx, ecx
mov eax, _z_core
call _zone_frame_alloc
pop edx
mov [_z_core], 0
push ebx
popf
pop ebx
sal eax, 12
ret 4
_zone_create:
push esi
push ebx
sub esp, 4
mov ebx, DWORD PTR [esp+16]
mov esi, DWORD PTR [esp+24]
mov DWORD PTR [esp], ebx
call _spinlock_initialize
mov eax, DWORD PTR [esp+20]
mov DWORD PTR [ebx+8], esi
mov DWORD PTR [ebx+16], esi
mov DWORD PTR [ebx+20], 0
mov DWORD PTR [ebx+4], eax
xor eax, eax
bsr eax, esi
xor edx, edx
mov BYTE PTR [ebx+24], al
.L81:
lea eax, [ebx+28+edx*8]
mov DWORD PTR [ebx+28+edx*8], eax
mov DWORD PTR [ebx+32+edx*8], eax
movzx eax, BYTE PTR [ebx+24]
add edx, 1
cmp eax, edx
jae .L81
lea ecx, [esi+esi*4]
sal ecx, 2
call @balloc@4
test esi, esi
mov DWORD PTR [ebx+12], eax
je .L83
xor ecx, ecx
xor edx, edx
.L85:
mov eax, edx
add ecx, 1
add eax, DWORD PTR [ebx+12]
add edx, 20
cmp ecx, esi
mov DWORD PTR [eax+8], 1
mov DWORD PTR [eax+12], 0
jne .L85
.L83:
add esp, 4
mov eax, 1
pop ebx
pop esi
ret
_init_mm:
push esi
xor eax, eax
push ebx
xor esi, esi
sub esp, 20
mov ebx, DWORD PTR [_mem_counter]
test ebx, ebx
jle .L93
xor ecx, ecx
xor edx, edx
jmp .L94
.L95:
add ecx, 1
add edx, 20
cmp ecx, ebx
je .L103
.L94:
cmp DWORD PTR [_mem_table+edx+16], 1
jne .L95
mov eax, DWORD PTR [_mem_table+edx]
add eax, DWORD PTR [_mem_table+edx+8]
and eax, -4096
cmp esi, eax
jae .L95
add ecx, 1
add edx, 20
cmp ecx, ebx
mov esi, eax
jne .L94
.L103:
cmp esi, 268435456
mov eax, esi
ja .L104
mov esi, eax
shr esi, 12
.L93:
mov DWORD PTR [_mem_amount], eax
mov [pg_data.mem_amount], eax
mov [pg_data.pages_count], esi
mov DWORD PTR [esp+8], esi
mov DWORD PTR [esp+4], eax
mov DWORD PTR [esp], .LC1
call _printf
mov DWORD PTR [esp+8], esi
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
call _zone_create
mov DWORD PTR [esp+8], esi
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
call _zone_release
mov eax, DWORD PTR [_pg_balloc]
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
shr eax, 12
mov DWORD PTR [esp+8], eax
call _zone_reserve
add esp, 20
pop ebx
pop esi
ret
.L104:
mov eax, 268435456
mov esi, eax
shr esi, 12
jmp .L93
.LC1:
db 'memory size = %x total pages = %x',10,0
_frame_free:
push ebx
mov edx, DWORD PTR [esp+8]
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
mov ecx, _z_core
shr edx, 12
call @zone_free@8
mov [_z_core], 0
push ebx
popf
pop ebx
ret
_core_free:
push ebx
mov edx, DWORD PTR [esp+8]
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
mov ecx, _z_core
shr edx, 12
call @zone_free@8
mov [_z_core], 0
push ebx
popf
pop ebx
ret
_core_alloc:
push ebx
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
mov edx, DWORD PTR [esp+8]
mov eax, _z_core
call _zone_frame_alloc
mov [_z_core], 0
push ebx
popf
pop ebx
sal eax, 12
ret
restore DWORD
restore WORD
restore BYTE
restore PTR

View File

@ -283,14 +283,22 @@ irq15read rd 16
irq_tab rd 16
_z_core rd 52
mem_block_map rb 512
event_map rb 64
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
large_block_mask rd 1
_z_core rd 50
_mem_amount rd 1
_rd_base rd 1
_rd_fat rd 1 ;RAMDISK + 512
_rd_fat_end rd 1 ;RAMDISK + 512 + 4278
_rd_root rd 1 ;RAMDISK + 512*18 + 512
_rd_root_end rd 1 ;RAMDISK + 512*33
mem_used.fd rd 1
mem_used.bk rd 1

View File

@ -541,7 +541,7 @@ LBA_read_ramdisk:
mov esi,eax
shl esi,9
add esi,RAMDISK
add esi, [_rd_base]
mov ecx,512/4
; cld
rep movsd

View File

@ -294,6 +294,7 @@ MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
include 'printf.inc'
include 'core/mm.asm'
@ -328,6 +329,10 @@ high_code:
mov cr3, eax ; flush TLB
mov edx, 0x3fB
mov eax, 3
out dx, al
; MEMORY MODEL
mov ecx, 1280*1024
@ -619,18 +624,19 @@ include 'detect/disks.inc'
; READ RAMDISK IMAGE FROM HD
;!!!!!!!!!!!!!!!!!!!!!!!
include 'boot/rdload.inc'
;include 'boot/rdload.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
; mov [dma_hdd],1
; CALCULATE FAT CHAIN FOR RAMDISK
mov [_rd_base], OS_BASE+0x100000
mov [_rd_fat], OS_BASE+0x100000 + 512
mov [_rd_fat_end], OS_BASE+0x100000 + 512 + 4278
mov [_rd_root], OS_BASE+0x100000 + 512*19
mov [_rd_root_end], OS_BASE+0x100000 + 512*33
call calculatefatchain
; LOAD VMODE DRIVER
;!!!!!!!!!!!!!!!!!!!!!!!
include 'vmodeld.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
mov ax,[OS_BASE+0x10000+bx_from_load]
cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba}
@ -657,7 +663,7 @@ no_lib_load:
or ecx, (10+29*6) shl 16 ; "Determining amount of memory"
sub ecx, 10
mov edx, 0xFFFFFF
mov ebx, [MEM_AMOUNT]
mov ebx, [_mem_amount]
shr ebx, 20
mov edi, 1
mov eax, 0x00040000
@ -2166,7 +2172,7 @@ sysfn_getfreemem:
ret
sysfn_getallmem:
mov eax,[MEM_AMOUNT]
mov eax,[_mem_amount]
shr eax, 10
mov [esp+32],eax
ret

View File

@ -0,0 +1,174 @@
DWORD equ dword
WORD equ word
BYTE equ byte
PTR equ
_putc:
mov ecx, DWORD PTR [esp+4]
.L13:
mov edx, 1021
in al, dx
test al, 96
je .L13
mov dl, -8
mov eax, ecx
out dx, al
cmp ecx, 10
jne .L7
mov cl, 13
jmp .L13
.L7:
ret
_printf:
push ebp
push edi
push esi
push ebx
sub esp, 40
lea eax, [esp+64]
mov DWORD PTR [esp+4], eax
.L50:
mov ecx, DWORD PTR [esp+60]
movzx edx, BYTE PTR [ecx]
test dl, dl
je .L51
.L17:
lea eax, [ecx+1]
cmp dl, 37
mov DWORD PTR [esp+60], eax
je .L18
movsx eax, dl
mov DWORD PTR [esp], eax
call _putc
mov ecx, DWORD PTR [esp+60]
movzx edx, BYTE PTR [ecx]
test dl, dl
jne .L17
.L51:
add esp, 40
pop ebx
pop esi
pop edi
pop ebp
ret
.L18:
movzx edx, BYTE PTR [ecx+1]
lea eax, [ecx+2]
mov DWORD PTR [esp+60], eax
cmp dl, 115
je .L22
jg .L23
cmp dl, 100
je .L21
.L20:
mov edx, DWORD PTR [esp+4]
mov eax, DWORD PTR [edx]
add edx, 4
mov DWORD PTR [esp+4], edx
mov DWORD PTR [esp], eax
call _putc
jmp .L50
.L23:
cmp dl, 117
je .L21
cmp dl, 120
jne .L20
.L21:
mov ecx, DWORD PTR [esp+4]
mov eax, DWORD PTR [ecx]
add ecx, 4
cmp dl, 100
mov DWORD PTR [esp+4], ecx
mov ecx, eax
je .L52
.L24:
cmp dl, 120
je .L53
lea ebp, [esp+20]
mov esi, 10
mov ebx, ebp
mov edi, ebp
.L43:
xor edx, edx
mov eax, ecx
div esi
cmp edx, 9
lea eax, [edx+48]
jle .L31
lea eax, [edx+87]
.L31:
mov BYTE PTR [edi], al
xor edx, edx
mov eax, ecx
div esi
add edi, 1
test eax, eax
mov ecx, eax
jne .L43
lea eax, [edi-1]
cmp eax, ebx
mov BYTE PTR [edi], 0
jbe .L33
lea ecx, [edi-2]
.L35:
movzx eax, BYTE PTR [ebx]
movzx edx, BYTE PTR [ecx+1]
mov BYTE PTR [ebx], dl
add ebx, 1
mov BYTE PTR [ecx+1], al
mov eax, ecx
sub ecx, 1
cmp ebx, eax
jb .L35
.L33:
mov edx, ebp
.L36:
movzx eax, BYTE PTR [edx]
test al, al
je .L50
mov ebx, edx
.L39:
movsx eax, al
mov DWORD PTR [esp], eax
call _putc
movzx eax, BYTE PTR [ebx+1]
add ebx, 1
test al, al
jne .L39
jmp .L50
.L22:
mov eax, DWORD PTR [esp+4]
mov edx, DWORD PTR [eax]
add eax, 4
mov DWORD PTR [esp+4], eax
test edx, edx
jne .L36
mov edx, .LC0
jmp .L36
.L52:
test eax, eax
jns .L24
lea ebx, [esp+21]
neg ecx
mov edi, ebx
mov esi, 10
lea ebp, [esp+20]
mov BYTE PTR [esp+20], 45
jmp .L43
.L53:
lea ebp, [esp+20]
mov esi, 16
mov ebx, ebp
mov edi, ebp
jmp .L43
.LC0: db "(null)",0
restore DWORD
restore WORD
restore BYTE
restore PTR

View File

@ -468,14 +468,14 @@ proc init_cursors
.init:
mov [cur_def_interl], ebx
stdcall load_driver, szHwMouse
mov [hw_cursor], eax
test eax, eax
jz .sw_mouse
; stdcall load_driver, szHwMouse
; mov [hw_cursor], eax
; test eax, eax
; jz .sw_mouse
stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
mov [def_cursor], eax
ret
; stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
; mov [def_cursor], eax
; ret
.sw_mouse:
mov [create_cursor], vesa_cursor