Return value of 58 function is corrected. Shutdown.inc optimized. Changes from diamond.

git-svn-id: svn://kolibrios.org@61 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Andrey Halyavin (halyavin) 2006-03-20 09:57:24 +00:00
parent 0ea1d629b0
commit 03b4d7367e
4 changed files with 304 additions and 305 deletions

View File

@ -10,170 +10,165 @@
system_shutdown: ; shut down the system system_shutdown: ; shut down the system
mov eax,3 ; stop playing cd push 3 ; stop playing cd
pop eax
call sys_cd_audio call sys_cd_audio
cli
cld cld
mov al,[0x2f0000+0x9030] mov al,[0x2f0000+0x9030]
cmp al,1 cmp al,1
jl no_shutdown_parameter jl no_shutdown_parameter
cmp al,4 cmp al,4
jg no_shutdown_parameter jle yes_shutdown_param
jmp yes_shutdown_param
no_shutdown_parameter: no_shutdown_parameter:
movzx ecx,word [0x2f0000+0x900A] ; movzx ecx,word [0x2f0000+0x900A]
movzx esi,word [0x2f0000+0x900C] ; movzx esi,word [0x2f0000+0x900C]
imul ecx,esi ;[0xfe04] ; imul ecx,esi ;[0xfe04]
; mov ecx,0x500000/4 ;3fff00/4 ; darken screen ;; mov ecx,0x500000/4 ;3fff00/4 ; darken screen
push ecx ; push ecx
mov esi,[0xfe80] ; mov esi,[0xfe80]
cmp esi,32*0x100000 ; cmp esi,32*0x100000
jbe no_darken_screen ; jbe no_darken_screen
mov edi,16*0x100000 ; mov edi,16*0x100000
sdnewpix: ; push esi edi
mov eax,[esi] ; sdnewpix:
add esi,4 ; lodsd
shr eax,1 ; shr eax,1
and eax,0x7f7f7f7f ; and eax,0x7f7f7f7f
stosd ; stosd
loop sdnewpix ; loop sdnewpix
pop ecx ; pop ecx
mov esi,16*0x100000 ; pop esi edi
mov edi,[0xfe80] ; rep movsd
cld ; no_darken_screen:
rep movsd
no_darken_screen: ; read shutdown code:
; 1) display shutdown "window"
mov eax,[0xfe00] mov eax,[0xfe00]
shr eax,1 shr eax,1
sub eax,220 lea esi,[eax+220] ; x end
sub eax,220 ; x start
mov ebx,[0xfe04] mov ebx,[0xfe04]
shr ebx,1 shr ebx,1
mov [shutdownpos],ebx mov [shutdownpos],ebx
sub ebx,120 lea ebp,[ebx+105] ; y end
sub ebx,120 ; y start
mov edi,1 xor edi,edi
inc edi ; force putpixel & dtext
mov ecx,0x0000ff mov ecx,0x0000ff
; vertical loop begin
sdnewpix1:
push eax ; save x start
; horizontal loop begin
sdnewpix2: sdnewpix2:
call [putpixel] call [putpixel]
inc eax inc eax
mov esi,[0xfe00]
shr esi,1
add esi,220
cmp eax,esi cmp eax,esi
jnz sdnewpix2 jnz sdnewpix2
; horizontal loop end
dec ecx dec ecx ; color
pop eax ; restore x start
inc ebx ; advance y pos
cmp ebx,ebp
jnz sdnewpix1
; vertical loop end
; 2) display text strings
; a) version
mov eax,[0xfe00] mov eax,[0xfe00]
shr eax,1 shr eax,1
sub eax,220 shl eax,16
mov ax,word [shutdownpos]
inc ebx push eax
sub eax,(220-27)*10000h + 105
mov edx,[shutdownpos]
add edx,105
cmp ebx,edx
jnz sdnewpix2
mov esi,[0xfe00] ; menuet version
shr esi,1
sub esi,220
add esi,27
shl esi,16
mov eax,esi
add eax,[shutdownpos]
sub eax,105
mov ebx,0xffff00 mov ebx,0xffff00
mov ecx,version mov ecx,version
mov edx,34 push 34
mov edi,1 pop edx
call dtext call dtext
mov esi,[0xfe00] ; 'it is safe..' ; b) variants
shr esi,1 add eax,105+33
sub esi,220 push 6
add esi,27 pop esi
shl esi,16 ; mov ebx,0xffffff
mov eax,esi mov bl,0xFF
add eax,[shutdownpos]
add eax,33
mov esi,6
mov ebx,0xffffff
mov ecx,shutdowntext mov ecx,shutdowntext
mov edx,40 mov dl,40
mov edi,1
newsdt: newsdt:
call dtext call dtext
add eax,10 add eax,10
add ecx,40 add ecx,edx
dec esi dec esi
jnz newsdt jnz newsdt
; 3) load & display rose.txt
mov eax,rosef ; load rose.txt mov eax,rosef ; load rose.txt
mov ebx,0 xor ebx,ebx
mov ecx,16800 push 2
pop ecx
mov edx,0x90000 mov edx,0x90000
mov esi,12 push edx
push 12
pop esi
push edi ; may be destroyed
call fileread call fileread
pop edi
mov esi,[0xfe00] ; draw rose pop ecx
shr esi,1 inc ecx ; do not display stars from rose.txt
add esi,20 pop eax
shl esi,16 add eax,20*10000h - 110
mov eax,esi
add eax,[shutdownpos]
sub eax,110
mov ebx,0x00ff00 mov ebx,0x00ff00
mov ecx,0x90001 push 27
mov edx,27 pop edx
mov edi,1
nrl: nrl:
call dtext call dtext
sub ebx,0x050000 sub ebx,0x050000
add eax,8 add eax,8
add ecx,31 add ecx,31
cmp ecx,dword 0x90001+25*31 cmp cx,word 0x0001+25*31
jnz nrl jnz nrl
call checkEgaCga call checkEgaCga
yes_shutdown_param: yes_shutdown_param:
cli cli
mov eax,kernel ; load kernel.mnt to 0x8000:0 mov eax,kernel ; load kernel.mnt to 0x8000:0
mov esi,12 push 12
mov ebx,0 pop esi
mov ecx,-1 xor ebx,ebx
or ecx,-1
mov edx,0x80000 mov edx,0x80000
call fileread call fileread
mov esi,restart_kernel_4000 ; move kernel re-starter to 0x4000:0 mov esi,restart_kernel_4000 ; move kernel re-starter to 0x4000:0
mov edi,0x40000 mov edi,0x40000
mov ecx,1000 mov ecx,1000
cld
rep movsb rep movsb
mov eax,0x2F0000 ; restore 0x0 - 0xffff mov eax,0x2F0000 ; restore 0x0 - 0xffff
mov ebx,0x0000 xor ebx,ebx
mov ecx,0xffff mov ecx,0x10000
call memmove call memmove
call restorefatchain call restorefatchain
mov eax,pr_mode_exit mov word [0x467+0],pr_mode_exit-0x10000
mov [0x467+0],ax mov word [0x467+2],0x1000
mov [0x467+2],word 0x1000
mov al,0x0F mov al,0x0F
out 0x70,al out 0x70,al
@ -195,25 +190,6 @@ pr_mode_exit:
; setup ds ; setup ds
push cs push cs
pop ds pop ds
; mov ax,1000
; mov ds,ax
; mov es,ax
; mov fs,ax
; mov gs,ax
; mov ss,ax
; mov bl,[shutdown_parameter]
; mov [es:shutdown_parameter-0x10000],bl
jmp real_mode-0x10000
old_ints_h:
dw 4*0x20
dd 0
dw 0
rdelay:
ret
real_mode:
lidt [old_ints_h-0x10000] lidt [old_ints_h-0x10000]
;remap IRQs ;remap IRQs
@ -249,14 +225,20 @@ real_mode:
out 0xA1,al out 0xA1,al
sti sti
jmp temp_3456 temp_3456:
nbw:
xor ax,ax xor ax,ax
mov es,ax
mov al,byte [es:0x9030]
cmp al,1
jl nbw
cmp al,4
jle nbw32
nbw:
in al,0x60 in al,0x60
call pause_key call pause_key
cmp al,7 cmp al,6
jge nbw jae nbw
mov bl,al mov bl,al
nbw2: nbw2:
in al,0x60 in al,0x60
@ -266,7 +248,7 @@ real_mode:
cmp al,240 ;ax,240 cmp al,240 ;ax,240
jne nbw31 jne nbw31
mov al,bl mov al,bl
dec al dec ax
jmp nbw32 jmp nbw32
nbw31: nbw31:
add bl,128 add bl,128
@ -275,46 +257,41 @@ real_mode:
sub al,129 sub al,129
nbw32: nbw32:
cmp al,1 ; write floppy dec ax ; 1 = write floppy
jne no_floppy_write js nbw
jnz no_floppy_write
call floppy_write call floppy_write
jmp temp_3456 ;nbw jmp temp_3456 ;nbw
no_floppy_write: no_floppy_write:
cmp al,2 ; poweroff dec ax ; 2 = power off
jne no_apm_off jnz no_apm_off
call APM_PowerOff call APM_PowerOff
jmp $
no_apm_off: no_apm_off:
cmp al,3 ; boot dec ax ; 3 = reboot
jnz no_sys_boot jnz restart_kernel ; 4 = restart kernel
mov ax,0x0040 push 0x40
mov ds,ax pop ds
mov word[0x0072],0x1234 mov word[0x0072],0x1234
jmp 0xF000:0xFFF0 jmp 0xF000:0xFFF0
no_sys_boot:
cmp al,4 ; restart kernel
je restart_kernel
temp_3456:
push word 0x0000
pop es
mov al,byte [es:0x9030]
cmp al,1
jl nbw
cmp al,4
jg nbw
jmp nbw32
; jmp nbw
pause_key: pause_key:
mov ecx,100 mov cx,100
pause_key_1: pause_key_1:
loop pause_key_1 loop pause_key_1
ret ret
old_ints_h:
dw 0x400
dd 0
dw 0
rdelay:
ret
iglobal iglobal
kernel db 'KERNEL MNT' kernel db 'KERNEL MNT'
; shutdown_parameter db 0 ; shutdown_parameter db 0
@ -361,10 +338,10 @@ restart_kernel_4000:
xor si, si xor si, si
xor di, di xor di, di
rep movsw rep movsw
mov ax, 0x9000 push 0x9000
mov ds, ax pop ds
mov ax, 0x2000 push 0x2000
mov es, ax pop es
pop cx pop cx
rep movsw rep movsw
@ -434,93 +411,72 @@ mov bx,1
mov cx,3 mov cx,3
int 0x15 int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!! ;!!!!!!!!!!!!!!!!!!!!!!!!
fwwritedone:
ret ret
uglobal
flm db 0 flm db 0
endg
floppy_write: ; write diskette image to physical floppy floppy_write: ; write diskette image to physical floppy
pusha cmp [flm-0x10000],byte 1
mov ax,0x1000
mov es,ax
cmp [es:flm-0x10000],byte 1
je fwwritedone je fwwritedone
mov [es:flm-0x10000],byte 1 mov [flm-0x10000],byte 1
mov ax,0x0000 ; reset drive xor ax, ax ; reset drive
mov dx,0x0000 xor dx, dx
int 0x13 int 0x13
mov cx,0x0001 ; startcyl,startsector mov cx,0x0001 ; startcyl,startsector
mov dx,0x0000 ; starthead,drive ; mov dx,0x0000 ; starthead,drive
push word 80*2 ; read no of sect xor dx, dx
mov ax, 80*2 ; read no of sect
fwwrites: fwwrites:
pusha push ax
; move 1mb+ -> 0:a000 ; move 1mb+ -> 0:a000
pusha pusha
mov si,fwmovedesc -0x10000 mov si,fwmovedesc -0x10000
push word 0x1000
pop es
mov cx,256*18 mov cx,256*18
mov ah,0x87 mov ah,0x87
push ds
pop es
int 0x15 int 0x15
mov eax,[es:fwmovedesc-0x10000+0x12] add dword [fwmovedesc-0x10000+0x12], 512*18
add eax,512*18
mov [es:fwmovedesc-0x10000+0x12],eax
popa popa
xor si,si xor si,si
mov es,si
fwnewwrite: fwnewwrite:
push word 0x0
pop es
mov bx,0xa000 ; es:bx -> data area mov bx,0xa000 ; es:bx -> data area
mov ax,0x0300+18 ; read, no of sectors to read mov ax,0x0300+18 ; read, no of sectors to read
int 0x13 int 0x13
cmp ah,0 test ah, ah
jz fwgoodwrite jz fwgoodwrite
add si,1 inc si
cmp si,10 cmp si,10
jnz fwnewwrite jnz fwnewwrite
add esp,32+2 ; can't access diskette - return
pop ax
popa ; can't access diskette
ret ret
fwgoodwrite: fwgoodwrite:
popa
inc dh inc dh
cmp dh,2 cmp dh,2
jnz fwbb2 jnz fwbb2
mov dh,0 mov dh,0
inc ch inc ch
fwbb2: fwbb2:
cld
pop ax pop ax
dec ax dec ax
push ax jnz fwwrites
cmp ax,0 ret
jnz fwrs
pop ax
jmp fwwritedone
fwrs:
jmp fwwrites
fwmovedesc: fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0 db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
@ -530,13 +486,6 @@ floppy_write: ; write diskette image to physical floppy
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
fwwritedone:
popa
ret
use32 use32
uglobal uglobal
@ -544,13 +493,15 @@ uglobal
endg endg
iglobal iglobal
;shutdowntext: if lang eq en
; db "IT'S SAFE TO POWER OFF COMPUTER OR " shutdowntext:
; db ' ' db "IT'S SAFE TO POWER OFF COMPUTER OR "
; db '1) SAVE RAMDISK TO FLOPPY ' db ' '
; db '2) APM - POWEROFF ' db '1) SAVE RAMDISK TO FLOPPY '
; db '3) REBOOT ' db '2) APM - POWEROFF '
; db '4) RESTART KERNEL ' db '3) REBOOT '
db '4) RESTART KERNEL '
else
shutdowntext: shutdowntext:
db "<EFBFBD>¥§®¯ á­®¥ ¢ëª«î祭¨¥ ª®¬¯ìîâ¥à  ¨«¨ " db "<EFBFBD>¥§®¯ á­®¥ ¢ëª«î祭¨¥ ª®¬¯ìîâ¥à  ¨«¨ "
db ' ' db ' '
@ -558,6 +509,7 @@ shutdowntext:
db '2) APM - ¢ëª«î祭¨¥ ¯¨â ­¨ï ' db '2) APM - ¢ëª«î祭¨¥ ¯¨â ­¨ï '
db '3) <20>¥à¥§ £à㧪  á¨á⥬ë ' db '3) <20>¥à¥§ £à㧪  á¨á⥬ë '
db '4) <20>¥áâ àâ ï¤à  ¨§ Ž‡“ ' db '4) <20>¥áâ àâ ï¤à  ¨§ Ž‡“ '
end if
rosef: rosef:
db 'ROSE TXT' db 'ROSE TXT'
endg endg

View File

@ -86,6 +86,7 @@ new_start_application_floppy:
call find_new_process_place ;find empty process slot call find_new_process_place ;find empty process slot
sti sti
test eax,eax test eax,eax
mov ecx, -0x20 ; too many processes
jz .failed jz .failed
mov edi,eax mov edi,eax
@ -97,9 +98,9 @@ new_start_application_floppy:
rep stosd ;clean extended information about process rep stosd ;clean extended information about process
;set new process name ;set new process name
xor eax,eax
mov [appl_path_size],eax mov [appl_path_size],eax
mov eax,[esp] ;+8] pop eax
push eax
.find_last_byte: .find_last_byte:
cmp byte [eax],0 cmp byte [eax],0
jz .find_last_byte_end jz .find_last_byte_end
@ -126,19 +127,22 @@ new_start_application_floppy:
; cli ; cli
call floppy_fileread ;read file from FD call floppy_fileread ;read file from FD
; sti ; sti
cmp eax,0 mov ecx, eax
jne .cleanfailed neg ecx
;check MENUET signature jnz .cleanfailed
;check MENUET signature
mov ecx, -0x1F ; not Menuet/Kolibri executable
cmp [0x90000],dword 'MENU' cmp [0x90000],dword 'MENU'
jnz .cleanfailed jnz .cleanfailed
cmp [0x90004],word 'ET' cmp [0x90004],word 'ET'
jnz .cleanfailed jnz .cleanfailed
call get_app_params ;parse header fields call get_app_params ;parse header fields
cmp esi,0 test esi, esi
jz .cleanfailed jz .cleanfailed
mov eax,[new_process_place] mov eax,[new_process_place]
inc ecx ; -0x1E = no memory
call create_app_cr3_table ;create page directory for new process call create_app_cr3_table ;create page directory for new process
test eax,eax test eax,eax
jz .cleanfailed_mem jz .cleanfailed_mem
@ -152,6 +156,7 @@ new_start_application_floppy:
mov edx,eax mov edx,eax
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
test eax,eax test eax,eax
mov ecx, -0x1E
jz .cleanfailed_mem1 jz .cleanfailed_mem1
mov eax,[edx+(std_application_base_address shr 20)] mov eax,[edx+(std_application_base_address shr 20)]
@ -209,6 +214,7 @@ new_start_application_floppy:
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
push ecx ; save error code
;can't read file, clean process name. ;can't read file, clean process name.
;this avoid problems with panel application. ;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
@ -218,13 +224,14 @@ new_start_application_floppy:
mov eax,' ' mov eax,' '
cld cld
rep stosb rep stosb
pop eax
.failed: .failed:
;no more slots ;no more slots
add esp,8+4 add esp,8+4
mov [application_table_status],0 mov [application_table_status],0
mov [esp+1Ch], eax
popad popad
sti sti
mov eax,-1
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -258,6 +265,7 @@ new_start_application_fl:
call find_new_process_place ;find empty process slot call find_new_process_place ;find empty process slot
call safe_sti call safe_sti
test eax,eax test eax,eax
mov ecx, -0x20 ; too many processes
jz .failed jz .failed
mov edi,eax mov edi,eax
@ -284,20 +292,23 @@ new_start_application_fl:
cli cli
call fileread ;read file from RD call fileread ;read file from RD
call safe_sti call safe_sti
cmp eax,0 mov ecx, eax
jne .cleanfailed neg ecx
;check MENUET signature jnz .cleanfailed
;check MENUET signature
mov ecx, -0x1F ; not Menuet/Kolibri executable
cmp [0x90000],dword 'MENU' cmp [0x90000],dword 'MENU'
jnz .cleanfailed jnz .cleanfailed
cmp [0x90004],word 'ET' cmp [0x90004],word 'ET'
jnz .cleanfailed jnz .cleanfailed
call get_app_params ;parse header fields call get_app_params ;parse header fields
cmp esi,0 test esi,esi
jz .cleanfailed jz .cleanfailed
mov eax,[new_process_place] mov eax,[new_process_place]
call create_app_cr3_table ;create page directory for new process call create_app_cr3_table ;create page directory for new process
inc ecx ; -0x1E = no memory
test eax,eax test eax,eax
jz .cleanfailed_mem jz .cleanfailed_mem
@ -310,6 +321,7 @@ new_start_application_fl:
mov edx,eax mov edx,eax
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
test eax,eax test eax,eax
mov ecx, -0x1E
jz .cleanfailed_mem1 jz .cleanfailed_mem1
mov eax,[edx+(std_application_base_address shr 20)] mov eax,[edx+(std_application_base_address shr 20)]
@ -366,6 +378,7 @@ new_start_application_fl:
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
push ecx ; save error code
;can't read file, clean process name. ;can't read file, clean process name.
;this avoid problems with panel application. ;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
@ -375,13 +388,14 @@ new_start_application_fl:
mov eax,' ' mov eax,' '
cld cld
rep stosb rep stosb
pop eax
.failed: .failed:
;no more slots ;no more slots
add esp,8 add esp,8
mov [application_table_status],0 mov [application_table_status],0
mov [esp+1Ch], eax
popad popad
call safe_sti call safe_sti
mov eax,-1
ret ret
.add_app_parameters: .add_app_parameters:
@ -1203,6 +1217,7 @@ new_start_application_hd:
call find_new_process_place ;find new process slot call find_new_process_place ;find new process slot
sti sti
test eax,eax test eax,eax
mov ecx, -0x20 ; too many processes
jz .failed jz .failed
;write application name ;write application name
@ -1231,11 +1246,14 @@ new_start_application_hd:
mov ecx,1 ;read from first block mov ecx,1 ;read from first block
mov edx,1 ;read 1 block mov edx,1 ;read 1 block
call read_hd_file call read_hd_file
test eax,eax mov ecx, eax
jnz .cleanfailed neg ecx
jnz .cleanfailed
mov esi,[esp] pop esi
;check menuet signature push esi
;check menuet signature
mov ecx, -0x1F ; not Menuet/Kolibri executable
cmp [esi+1024+0],dword 'MENU' ;read_hd_file function write file to +1024 offset cmp [esi+1024+0],dword 'MENU' ;read_hd_file function write file to +1024 offset
jnz .cleanfailed jnz .cleanfailed
cmp [esi+1024+4],word 'ET' cmp [esi+1024+4],word 'ET'
@ -1246,12 +1264,14 @@ new_start_application_hd:
cld cld
rep movsd ;copy first block to 0x90000 address for get_app_params function rep movsd ;copy first block to 0x90000 address for get_app_params function
call get_app_params call get_app_params
mov ecx, -0x1F ; not Menuet/Kolibri executable
test esi,esi test esi,esi
jz .cleanfailed jz .cleanfailed
mov eax,[new_process_place] mov eax,[new_process_place]
call create_app_cr3_table ;create page directory call create_app_cr3_table ;create page directory
test eax,eax test eax,eax
inc ecx ; -0x1E = no memory
jz .cleanfailed_mem jz .cleanfailed_mem
call MEM_Get_Linear_Address call MEM_Get_Linear_Address
@ -1262,6 +1282,7 @@ new_start_application_hd:
shr ecx,12 shr ecx,12
mov edx,eax ;edx - linear address of page directory mov edx,eax ;edx - linear address of page directory
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
mov ecx, -0x1E ; no memory
test eax,eax test eax,eax
jz .cleanfailed_mem1 jz .cleanfailed_mem1
@ -1350,6 +1371,7 @@ new_start_application_hd:
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
push ecx
;can't read file, clean process name. ;can't read file, clean process name.
;this avoid problems with panel application. ;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
@ -1358,12 +1380,13 @@ new_start_application_hd:
mov ecx,11 mov ecx,11
mov eax,' ' mov eax,' '
cld cld
rep stosb rep stosb
pop eax
.failed: .failed:
;no more slots ;no more slots
add esp,16 add esp,16
popad mov [esp+1Ch], eax
mov eax,-1 popad
mov [application_table_status],0 mov [application_table_status],0
sti sti
ret ret

View File

@ -48,7 +48,7 @@ file_system:
; OUT: ; OUT:
; ;
; eax = 0 : read ok ; eax = 0 : read ok
; eax = 1 : no fd base and/or partition defined ; eax = 1 : no hd base and/or partition defined
; eax = 2 : yet unsupported FS ; eax = 2 : yet unsupported FS
; eax = 3 : unknown FS ; eax = 3 : unknown FS
; eax = 4 : partition not defined at hd ; eax = 4 : partition not defined at hd
@ -61,10 +61,31 @@ file_system:
; ;
; ebx = size ; ebx = size
; Extract parameters ; \begin{diamond}[18.03.2006]
; for subfunction 16 (start application) error codes must be negative
; because positive values are valid PIDs
; so possible return values are:
; eax > 0 : process created, eax=PID
mov edi,[0x3010] ; -0x10 <= eax < 0 : -eax is filesystem error code:
add eax,[edi+0x10] ; abs start of info block ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined
; eax = -3 = 0xFFFFFFFD : unknown FS
; eax = -5 = 0xFFFFFFFB : file not found
; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file)
; eax = -9 = 0xFFFFFFF7 : fat table corrupted
; eax = -10 = 0xFFFFFFF6 : access denied
; -0x20 <= eax < -0x10: eax is process creation error code:
; eax = -0x20 = 0xFFFFFFE0 : too many processes
; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable
; eax = -0x1E = 0xFFFFFFE2 : no memory
; ebx is not changed
; \end{diamond}[18.03.2006]
; Extract parameters
add eax, std_application_base_address ; abs start of info block
cmp dword [eax+0],12 ; Get file size cmp dword [eax+0],12 ; Get file size
je fs_read je fs_read
@ -85,9 +106,6 @@ file_system:
cmp dword [0x3000],1 ; no memory checks for kernel requests cmp dword [0x3000],1 ; no memory checks for kernel requests
jz no_checks_for_kernel jz no_checks_for_kernel
;iglobal
; buffer_failed db 'Buffer check failed',13,10,0
;endg
mov edx,eax mov edx,eax
cmp dword [eax+0],1 cmp dword [eax+0],1
jz .check_for_write_op jz .check_for_write_op
@ -104,11 +122,11 @@ file_system:
.error_output: .error_output:
mov esi,buffer_failed mov esi,buffer_failed
call sys_msg_board_str call sys_msg_board_str
mov eax,7 ; mov eax,7
mov dword [esp+36],7 mov dword [esp+36],7
ret ret
iglobal iglobal
buffer_failed db 'Buffer check failed',13,10,0 buffer_failed db 'K : Buffer check failed',13,10,0
endg endg
.usual_check: .usual_check:
cmp dword [eax+0],0 cmp dword [eax+0],0
@ -122,22 +140,6 @@ endg
call check_region call check_region
test eax,eax test eax,eax
jz .error_output jz .error_output
jmp area_in_app_mem
; mov ebx,[0x3000] ; pointer in application memory ?
; shl ebx,8
; mov ebx,[ebx+0x80000+0x8c]
; mov ebp,ebx ; save for checking at stack save
; sub ebp,[eax+12]
; shr ebp,9
; sub ebx,512 ; need atleast one block
; cmp ebx,[eax+12]
; ja area_in_app_mem
; mov eax,7
; mov dword [esp+36],7
; ret
area_in_app_mem: area_in_app_mem:
mov eax,edx mov eax,edx
no_checks_for_kernel: no_checks_for_kernel:
@ -147,7 +149,7 @@ endg
je fs_read je fs_read
cmp dword [eax+8],0 ; read or write 0 blocks/bytes ? cmp dword [eax+8],0 ; read or write 0 blocks/bytes ?
jne fs_read jne fs_read
mov dword [esp+36],0 and dword [esp+36],0
ret ret
fs_read: fs_read:
@ -157,26 +159,39 @@ endg
test bh,bh test bh,bh
jne fs_noroot jne fs_noroot
fs_getroot: fs_getroot:
mov edx,[edi+0x10] ; \begin{diamond}[18.03.2006]
; root - only read is allowed
; other operations return "access denied", eax=10
; (execute operation returns eax=-10)
cmp dword [eax], 0
jz .read_root
mov ecx, 10
cmp dword [eax], 16
jnz @f
neg ecx
@@: mov [esp+36], ecx
ret
.read_root:
; \end{diamond}[18.03.2006]
mov esi,dir0 mov esi,dir0
mov edi,[eax+12] mov edi,[eax+12]
add edi,edx add edi,std_application_base_address
mov ecx,11 mov ecx,11
cld push ecx
; cld ; already is
rep movsb rep movsb
mov eax,0x10 mov al,0x10
stosb stosb
add edi,32-11-1 add edi,32-11-1
mov ecx,11 pop ecx
rep movsb rep movsb
stosb stosb
mov dword [esp+36],0 ; ok read and dword [esp+36],0 ; ok read
mov dword [esp+24],32*2 ; size of root mov dword [esp+24],32*2 ; size of root
ret ret
fs_info: ;start of code - Mihasik fs_info: ;start of code - Mihasik
mov edi,eax push eax
push edi
cmp [eax+21],byte 'h' cmp [eax+21],byte 'h'
je fs_info_h je fs_info_h
cmp [eax+21],byte 'H' cmp [eax+21],byte 'H'
@ -210,38 +225,26 @@ endg
fs_noroot: fs_noroot:
mov ebx,[eax+0] push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run
push ebx ; read/write/delete/.../makedir/rename/lba/run push dword [eax+4] ; 512 block number to read
mov ebx,[eax+4] push dword [eax+8] ; bytes to write/append or 512 blocks to read
push ebx ; 512 block number to read
mov ebx,[eax+8]
; cmp dword [eax+0],0 ; if read, check that the data stays at
; jne ret_size_fine ; application memory
; cmp ebx,ebp
; jbe ret_size_fine
; mov ebx,ebp
; ret_size_fine:
push ebx ; bytes to write/append or 512 blocks to read
mov ebx,[eax+12] mov ebx,[eax+12]
add ebx,[edi+0x10] add ebx,std_application_base_address
push ebx ; abs start of return/save area push ebx ; abs start of return/save area
lea esi,[eax+20] ; abs start of dir + filename lea esi,[eax+20] ; abs start of dir + filename
mov edi,[edi+0x10] ; abs start of work area mov edi,[eax+16]
add edi,[eax+16] add edi,std_application_base_address ; abs start of work area
call expand_pathz call expand_pathz
push edi ; dir start push edi ; dir start
push ebx ; name of file start push ebx ; name of file start
mov ebx,[dir0+11] ; /RAMDISK
mov eax,[edi+1] mov eax,[edi+1]
cmp eax,'RD ' cmp eax,'RD '
je fs_yesramdisk je fs_yesramdisk
cmp eax,ebx cmp eax,'RAMD'
jne fs_noramdisk jne fs_noramdisk
fs_yesramdisk: fs_yesramdisk:
@ -249,11 +252,10 @@ endg
cmp byte [edi+1+11],0 cmp byte [edi+1+11],0
je fs_give_dir1 je fs_give_dir1
mov ebx,[dir1] ; /FIRST
mov eax,[edi+1+12] mov eax,[edi+1+12]
cmp eax,'1 ' cmp eax,'1 '
je fs_yesramdisk_first je fs_yesramdisk_first
cmp eax,ebx cmp eax,'FIRS'
jne fs_noramdisk jne fs_noramdisk
fs_yesramdisk_first: fs_yesramdisk_first:
@ -312,17 +314,16 @@ endg
add eax,2*12+1 add eax,2*12+1
xor ebx,ebx ; parameters to pass xor ebx,ebx ; parameters to pass
cmp dword [esp+12],0 cmp dword [esp+12],ebx;0
je no_fl_start_param je no_fl_start_param
mov ebx,[0x3010] mov ebx, [esp+12]
mov ebx,[ebx+0x10] add ebx, std_application_base_address
add ebx,[esp+12]
no_fl_start_param: no_fl_start_param:
mov edx,[esp+16] ; flags mov edx,[esp+16] ; flags
call start_application_fl call start_application_fl
jmp file_system_return jmp file_system_startapp_return
fs_noramdisk_start_application: ;there's new code - Mihasik fs_noramdisk_start_application: ;there's new code - Mihasik
cmp dword [esp+20],2 ;DELETE cmp dword [esp+20],2 ;DELETE
@ -350,11 +351,10 @@ endg
fs_noramdisk: fs_noramdisk:
;******************************************************************** ;********************************************************************
mov ebx,[dir0+22] ; /FLOPPYDISK
mov eax,[edi+1] mov eax,[edi+1]
cmp eax,'FD ' cmp eax,'FD '
je fs_yesflpdisk je fs_yesflpdisk
cmp eax,ebx cmp eax,'FLOP'
jne fs_noflpdisk jne fs_noflpdisk
fs_yesflpdisk: fs_yesflpdisk:
@ -363,16 +363,14 @@ endg
cmp byte [edi+1+11],0 cmp byte [edi+1+11],0
je fs_give_dir1 je fs_give_dir1
mov ebx,[dir1] ; /FIRST
mov eax,[edi+1+12] mov eax,[edi+1+12]
cmp eax,'1 ' cmp eax,'1 '
je fs_yesflpdisk_first je fs_yesflpdisk_first
cmp eax,ebx cmp eax,'FIRS'
je fs_yesflpdisk_first je fs_yesflpdisk_first
mov ebx,[dir1+11] ; /SECOND
cmp eax,'2 ' cmp eax,'2 '
je fs_yesflpdisk_second je fs_yesflpdisk_second
cmp eax,ebx cmp eax,'SECO'
jne fs_noflpdisk jne fs_noflpdisk
jmp fs_yesflpdisk_second jmp fs_yesflpdisk_second
@ -434,7 +432,7 @@ endg
add eax,2*12+1 add eax,2*12+1
xor ebx,ebx ; parameters to pass xor ebx,ebx ; parameters to pass
cmp dword [esp+12],0 cmp dword [esp+12],ebx;0
je no_flp_start_param je no_flp_start_param
mov ebx,[0x3010] mov ebx,[0x3010]
mov ebx,[ebx+0x10] mov ebx,[ebx+0x10]
@ -445,6 +443,8 @@ endg
call start_application_floppy call start_application_floppy
file_system_startapp_return:
mov ebx, [esp+24+24] ; do not modify ebx in application
jmp file_system_return jmp file_system_return
fs_noflpdisk_start_application: fs_noflpdisk_start_application:
@ -495,9 +495,9 @@ choice_necessity_partition:
call StringToNumber call StringToNumber
mov [fat32part],eax mov [fat32part],eax
choice_necessity_partition_1: choice_necessity_partition_1:
mov [0xfe10],dword 0 ; entries in hd cache
mov ecx,[hdpos] mov ecx,[hdpos]
xor eax,eax xor eax,eax
mov [0xfe10], eax ; entries in hd cache
mov edx,0x40002 mov edx,0x40002
search_partition_array: search_partition_array:
mov bl,[edx] mov bl,[edx]
@ -516,11 +516,10 @@ choice_necessity_partition_1:
ret ret
old_path_harddisk: old_path_harddisk:
mov ebx,[dir0] ; /HARDDISK
mov eax,[edi+1] mov eax,[edi+1]
cmp eax,'HD ' cmp eax,'HD '
je fs_yesharddisk je fs_yesharddisk
cmp eax,ebx cmp eax,'HARD'
jne fs_noharddisk jne fs_noharddisk
fs_yesharddisk: fs_yesharddisk:
@ -543,6 +542,10 @@ choice_necessity_partition_1:
fs_yesharddisk_all: fs_yesharddisk_all:
mov eax,1 mov eax,1
cmp dword [esp+20], 16
jnz @f
neg eax
@@: mov ebx, [esp+24+24]
cmp [hdpos],0 ; is hd base set? cmp [hdpos],0 ; is hd base set?
jz file_system_return ; no jz file_system_return ; no
cmp [fat32part],0 ; is partition set? cmp [fat32part],0 ; is partition set?
@ -661,19 +664,17 @@ choice_necessity_partition_1:
add edi,12+1 ; continue after name add edi,12+1 ; continue after name
call expand_pathz ; convert destination name call expand_pathz ; convert destination name
mov edx,[dir0] ; /HARDDISK
mov eax,[edi+1] mov eax,[edi+1]
cmp eax,'HD ' cmp eax,'HD '
je fs_rename_test1 je fs_rename_test1
cmp eax,edx cmp eax,'HARD'
jne fs_rename_error jne fs_rename_error
fs_rename_test1: fs_rename_test1:
mov edx,[dir1] ; /FIRST
mov eax,[edi+1+12] mov eax,[edi+1+12]
cmp eax,'1 ' cmp eax,'1 '
je fs_rename_start je fs_rename_start
cmp eax,edx cmp eax,'FIRS'
jne fs_rename_error jne fs_rename_error
fs_rename_start: fs_rename_start:
@ -774,21 +775,28 @@ choice_necessity_partition_1:
add ecx,512 add ecx,512
xor ebp,ebp ; parameters to pass xor ebp,ebp ; parameters to pass
cmp dword [esp+12],0 cmp dword [esp+12],ebp;0
je no_hd_start_param je no_hd_start_param
mov ebp,[0x3010] mov ebp, [esp+12]
mov ebp,[ebp+0x10] add ebp, std_application_base_address
add ebp,[esp+12]
no_hd_start_param: no_hd_start_param:
mov edx,[esp+16] ; flags mov edx,[esp+16] ; flags
call start_application_hd call start_application_hd
jmp file_system_return jmp file_system_startapp_return
fs_noharddisk_start_application: fs_noharddisk_start_application:
fs_noharddisk: fs_noharddisk:
; \begin{diamond}[18.03.2006]
mov eax, 5 ; file not found
; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè?
cmp dword [esp+20], 16
jnz @f
neg eax
@@: mov ebx, [esp+24+24] ; do not change ebx in application
; \end{diamond}[18.03.2006]
file_system_return: file_system_return:
@ -801,13 +809,29 @@ choice_necessity_partition_1:
fs_give_dir1: fs_give_dir1:
mov eax,0x10 ; \begin{diamond}[18.03.2006]
; /RD,/FD,/HD - only read is allowed
; other operations return "access denied", eax=10
; (execute operation returns eax=-10)
cmp dword [esp+20], 0
jz .read
add esp, 20
pop ecx
mov eax, 10
cmp ecx, 16
jnz @f
neg eax
@@: mov [esp+36], eax
ret
.read:
; \end{diamond}[18.03.2006]
mov al,0x10
mov ebx,1 mov ebx,1
mov edi,[esp+8] mov edi,[esp+8]
mov esi,dir1 mov esi,dir1
fs_d1_new: fs_d1_new:
mov ecx,11 mov ecx,11
cld ; cld
rep movsb rep movsb
stosb stosb
add edi,32-11-1 add edi,32-11-1
@ -816,7 +840,7 @@ choice_necessity_partition_1:
add esp,24 add esp,24
mov dword [esp+36],0 ; ok read and dword [esp+36],0 ; ok read
mov dword [esp+24],32*1 ; dir/data size mov dword [esp+24],32*1 ; dir/data size
ret ret
@ -851,7 +875,7 @@ LBA_read_ramdisk:
shl esi,9 shl esi,9
add esi,0x100000 add esi,0x100000
mov ecx,512/4 mov ecx,512/4
cld ; cld
rep movsd rep movsd
popad popad

View File

@ -72,7 +72,7 @@ drawbar dd __sys_drawbar
putpixel dd __sys_putpixel putpixel dd __sys_putpixel
; } mike.dld ; } mike.dld
version db 'Kolibri OS version 0.5.2.9 ',13,10,13,10,0 version db 'Kolibri OS version 0.5.3.0 ',13,10,13,10,0
;dd endofcode-0x10000 ;dd endofcode-0x10000
;db 'Boot02' ;db 'Boot02'
@ -2274,7 +2274,7 @@ endg
iglobal iglobal
version_inf: version_inf:
db 0,5,2,9 ; version 0.5.2.9 db 0,5,3,0 ; version 0.5.2.9
db UID_KOLIBRI db UID_KOLIBRI
db 'Kolibri',0 db 'Kolibri',0
version_end: version_end: