fix stack error in fs_exec

git-svn-id: svn://kolibrios.org@247 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2006-12-24 07:50:24 +00:00
parent 08a4dc7f2d
commit 88e9e4be91
4 changed files with 145 additions and 73 deletions

View File

@ -102,7 +102,7 @@ ramdisk_free_space:
rdfs2: rdfs2:
shl ebx,9 ;free clusters*512 shl ebx,9 ;free clusters*512
mov edi,ebx mov edi,ebx
pop ecx ebx eax pop ecx ebx eax
ret ret
@ -193,7 +193,7 @@ fileread:
mov edi,edx mov edi,edx
dec ebx dec ebx
push edx push edx
mov edx,ecx mov edx,ecx
add edx,ebx add edx,ebx
cmp edx,15 ;ebx+ecx=14+1 cmp edx,15 ;ebx+ecx=14+1
pushf pushf
@ -308,7 +308,7 @@ filedelete:
call expand_filename call expand_filename
push eax ebx ecx edx esi edi push eax ebx ecx edx esi edi
call rd_findfile call rd_findfile
je fifoundd je fifoundd
pop edi esi edx ecx ebx eax ;file not found pop edi esi edx ecx ebx eax ;file not found
@ -338,7 +338,7 @@ filedelete:
xor eax,eax ; file found xor eax,eax ; file found
ret ret
filesave: filesave:
;---------------------------------------------------------- ;----------------------------------------------------------
@ -471,9 +471,9 @@ mov [edi+22],ax ; time
jb rd_newsearch jb rd_newsearch
mov eax,5 ;if file not found - eax=5 mov eax,5 ;if file not found - eax=5
xor ebx,ebx xor ebx,ebx
dec ebx ;ebx=0xffffffff and zf=0 dec ebx ;ebx=0xffffffff and zf=0
rd_ff: rd_ff:
ret ret
; \begin{diamond} ; \begin{diamond}
@ -599,45 +599,42 @@ fat_get_name:
cmp byte [edi+11], 0xF cmp byte [edi+11], 0xF
jz .longname jz .longname
push ecx push ecx
mov ecx, 8 push edi ebp
push edi ebp ecx
test byte [ebp-4], 1 test byte [ebp-4], 1
jnz .unicode_short jnz .unicode_short
mov eax, [edi]
mov ecx, [edi+4]
mov [ebp], eax
mov [ebp+4], ecx
mov ecx, 8
@@: @@:
mov al, [edi] cmp byte [ebp+ecx-1], ' '
inc edi loope @b
mov [ebp], al
inc ebp mov eax, [edi+8]
loop @b cmp al, ' '
pop ecx je .done
@@: shl eax, 8
cmp byte [ebp-1], ' ' mov al, '.'
jnz @f
dec ebp lea ebp, [ebp+ecx+1]
loop @b mov [ebp], eax
@@:
mov byte [ebp], '.'
inc ebp
mov ecx, 3 mov ecx, 3
push ecx
@@: @@:
mov al, [edi] rol eax, 8
inc edi cmp al, ' '
mov [ebp], al jne .done
inc ebp loop @b
loop @b dec ebp
pop ecx .done:
@@: and byte [ebp+ecx+1], 0 ; CF=0
cmp byte [ebp-1], ' '
jnz @f
dec ebp
loop @b
dec ebp
@@:
and byte [ebp], 0 ; CF=0
pop ebp edi ecx pop ebp edi ecx
ret ret
.unicode_short: .unicode_short:
mov ecx, 8
push ecx
@@: @@:
mov al, [edi] mov al, [edi]
inc edi inc edi

View File

@ -89,25 +89,24 @@ proc fs_exec_EX stdcall file_name:dword, cmd_line:dword, flags:dword
stdcall load_file,[file_name] stdcall load_file,[file_name]
mov ecx, -ERROR_FILE_NOT_FOUND mov ecx, -ERROR_FILE_NOT_FOUND
test eax, eax test eax, eax
jz .err ;fail jz .err_file
mov [file_base], eax mov [file_base], eax
mov [file_size], ebx mov [file_size], ebx
pushfd
cli
lea ebx, [app_cmdline] lea ebx, [app_cmdline]
call test_app_header call test_app_header
mov ecx, -0x1F mov ecx, -0x1F
test eax, eax test eax, eax
jz .err ;fail jz .err_hdr
mov esi, new_process_loading mov esi, new_process_loading
call sys_msg_board_str ; write message to message board call sys_msg_board_str ; write message to message board
pushfd
cli
.wait_lock: .wait_lock:
cmp [application_table_status],0 cmp [application_table_status],0
je .get_lock je .get_lock
@ -125,7 +124,7 @@ proc fs_exec_EX stdcall file_name:dword, cmd_line:dword, flags:dword
call get_new_process_place call get_new_process_place
test eax, eax test eax, eax
mov ecx, -0x20 ; too many processes mov ecx, -0x20 ; too many processes
jz .err jz .err_hdr
mov [slot], eax mov [slot], eax
shl eax, 8 shl eax, 8
@ -172,13 +171,17 @@ proc fs_exec_EX stdcall file_name:dword, cmd_line:dword, flags:dword
mov [ebx+APPDATA.mem_size],eax mov [ebx+APPDATA.mem_size],eax
mov ecx, [file_size] mov ecx, [file_size]
add ecx, 3 mov eax, ecx
shr ecx, 2 shr ecx, 2
mov esi, [file_base] mov esi, [file_base]
mov edi, new_app_base mov edi, new_app_base
cld cld
rep movsd rep movsd
and eax, 3
jz @F
mov ecx, eax
rep movsb
@@:
stdcall kernel_free, [file_base] stdcall kernel_free, [file_base]
lea eax, [app_cmdline] lea eax, [app_cmdline]
stdcall set_app_params ,[slot],eax,[cmd_line],\ stdcall set_app_params ,[slot],eax,[cmd_line],\
@ -187,16 +190,18 @@ proc fs_exec_EX stdcall file_name:dword, cmd_line:dword, flags:dword
mov eax, [save_cr3] mov eax, [save_cr3]
call set_cr3 call set_cr3
xor eax, eax
mov [application_table_status],eax ;unlock application_table_status mutex
popfd popfd
mov eax,[process_number] ;set result xor ebx, ebx
mov [application_table_status],ebx ;unlock application_table_status mutex
mov eax,[process_number] ;set result
ret ret
.failed: .failed:
mov eax, [save_cr3] mov eax, [save_cr3]
call set_cr3 call set_cr3
.err: .err_hdr:
stdcall kernel_free,[file_base]
popfd popfd
.err_file:
xor eax, eax xor eax, eax
mov [application_table_status],eax mov [application_table_status],eax
ret ret

View File

@ -693,8 +693,23 @@ proc init_codec
counter dd ? counter dd ?
endl endl
mov esi, msgControl
call SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
mov edx, CTRL_STAT mov edx, CTRL_STAT
call [ctrl.ctrl_read32] call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
test eax, CTRL_ST_CREADY test eax, CTRL_ST_CREADY
jnz .ready jnz .ready
@ -1107,11 +1122,26 @@ proc ctrl_io_w32
ret ret
endp endp
align 4
dword2str:
mov esi, hex_buff
mov ecx, -8
@@:
rol eax, 4
mov ebx, eax
and ebx, 0x0F
mov bl, [ebx+hexletters]
mov [8+esi+ecx], bl
inc ecx
jnz @B
ret
include "codec.inc" include "codec.inc"
align 4 align 4
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
dd 0 dd 0
version dd 0x00010001 version dd 0x00010001
@ -1136,6 +1166,12 @@ msgWarm db 'warm reset',13,10,0
msgWRFail db 'warm reset failed',13,10,0 msgWRFail db 'warm reset failed',13,10,0
msgCRFail db 'cold reset failed',13,10,0 msgCRFail db 'cold reset failed',13,10,0
msgCFail db 'codec not ready',13,10,0 msgCFail db 'codec not ready',13,10,0
msgStatus db 'global status ',0
msgControl db 'global control ',0
hexletters db '0123456789ABCDEF'
hex_buff db 8 dup(0),13,10,0
section '.data' data readable writable align 16 section '.data' data readable writable align 16

View File

@ -109,16 +109,16 @@ CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset
CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26 CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26 CODEC_REG_ST equ 0x26
DEV_PLAY equ 1 DEV_PLAY equ 1
DEV_STOP equ 2 DEV_STOP equ 2
DEV_CALLBACK equ 3 DEV_CALLBACK equ 3
DEV_SET_BUFF equ 4 DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5 DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6 DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7 DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8 DEV_GET_INFO equ 8
struc AC_CNTRL ;AC controller base class struc AC_CNTRL ;AC controller base class
{ .bus dd ? { .bus dd ?
@ -243,15 +243,15 @@ struc CODEC ;Audio Chip base class
} }
struc CTRL_INFO struc CTRL_INFO
{ .pci_cmd dd ? { .pci_cmd dd ?
.irq dd ? .irq dd ?
.glob_cntrl dd ? .glob_cntrl dd ?
.glob_sta dd ? .glob_sta dd ?
.codec_io_base dd ? .codec_io_base dd ?
.ctrl_io_base dd ? .ctrl_io_base dd ?
.codec_mem_base dd ? .codec_mem_base dd ?
.ctrl_mem_base dd ? .ctrl_mem_base dd ?
.codec_id dd ? .codec_id dd ?
} }
struc IOCTL struc IOCTL
@ -267,10 +267,10 @@ virtual at 0
IOCTL IOCTL IOCTL IOCTL
end virtual end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; 0x80400000 OS_BASE equ 0;
new_app_base equ 0x60400000; 0x01000000 new_app_base equ 0x60400000
PROC_BASE equ OS_BASE+0x0080000 PROC_BASE equ OS_BASE+0x0080000
public START public START
@ -830,8 +830,23 @@ proc init_codec
counter dd ? counter dd ?
endl endl
mov esi, msgControl
call SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
mov edx, CTRL_STAT mov edx, CTRL_STAT
call [ctrl.ctrl_read32] call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
test eax, CTRL_ST_CREADY test eax, CTRL_ST_CREADY
jnz .ready jnz .ready
@ -1307,6 +1322,23 @@ proc ctrl_mem_w32
ret ret
endp endp
align 4
dword2str:
mov esi, hex_buff
mov ecx, -8
@@:
rol eax, 4
mov ebx, eax
and ebx, 0x0F
mov bl, [ebx+hexletters]
mov [8+esi+ecx], bl
inc ecx
jnz @B
ret
hexletters db '0123456789ABCDEF'
hex_buff db 8 dup(0),13,10,0
include "codec.inc" include "codec.inc"
@ -1364,18 +1396,20 @@ msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0
msgPlay db 'start play', 13,10,0 msgPlay db 'start play', 13,10,0
msgStop db 'stop play', 13,10,0 msgStop db 'stop play', 13,10,0
msgNotify db 'call notify',13,10,0 msgNotify db 'call notify',13,10,0
msgIRQ db 'AC97 IRQ', 13,10,0 msgIRQ db 'AC97 IRQ', 13,10,0
msgInitCtrl db 'init controller',13,10,0 msgInitCtrl db 'init controller',13,10,0
msgInitCodec db 'init codec',13,10,0 msgInitCodec db 'init codec',13,10,0
msgPrimBuff db 'create primary buffer',13,10,0 msgPrimBuff db 'create primary buffer',13,10,0
msgReg db 'set service handler',13,10,0 msgReg db 'set service handler',13,10,0
msgOk db 'service installed',13,10,0 msgOk db 'service installed',13,10,0
msgCold db 'cold reset',13,10,0 msgCold db 'cold reset',13,10,0
msgWarm db 'warm reset',13,10,0 msgWarm db 'warm reset',13,10,0
msgWRFail db 'warm reset failed',13,10,0 msgWRFail db 'warm reset failed',13,10,0
msgCRFail db 'cold reset failed',13,10,0 msgCRFail db 'cold reset failed',13,10,0
msgCFail db 'codec not ready',13,10,0 msgCFail db 'codec not ready',13,10,0
msgResetOk db 'reset complete',13,10,0 msgResetOk db 'reset complete',13,10,0
msgStatus db 'global status ',0
msgControl db 'global control ',0
section '.data' data readable writable align 16 section '.data' data readable writable align 16