LAUNCHER changes:

1) Reducing the consumption of RAM, 4 KB instead of 32 KB.
2) Output to BOARD information about running applications.
3) Cleaning of the source code.
notice:
Only 2 KB of memory for AUTORUN.DAT - be careful!

git-svn-id: svn://kolibrios.org@4602 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2014-03-02 17:47:45 +00:00
parent 2fa4df3549
commit 31a1418c99
3 changed files with 264 additions and 227 deletions

View File

@ -1,5 +1,6 @@
@erase lang.inc @erase lang.inc
@echo lang fix en >lang.inc @echo lang fix en >lang.inc
@fasm launcher.asm launcher @fasm launcher.asm launcher
@kpack launcher
@erase lang.inc @erase lang.inc
@pause @pause

View File

@ -1,5 +1,6 @@
@erase lang.inc @erase lang.inc
@echo lang fix ru >lang.inc @echo lang fix ru >lang.inc
@fasm launcher.asm launcher @fasm launcher.asm launcher
@kpack launcher
@erase lang.inc @erase lang.inc
@pause @pause

View File

@ -1,45 +1,45 @@
;-----------------------------------------------------------------------------
; ;
; LAUNCHER - €Ž‡€<E280A1>Š <20><>Žƒ<C5BD>€ŒŒ ; LAUNCHER - startup of programs
; Š®¤ ¯à®£à ¬¬ë ᮢᥬ ­¥ ®¯â¨¬¨§¨à®¢ ­, ­® ®ç¥­ì ¯à®áâ ¤«ï ¯®­¨¬ ­¨ï.
; <20>â®â « ã­ç¥à £à㧨⠨­ä®à¬ æ¨î ® ¯à®£à ¬¬ å ¤«ï § ¯ã᪠ ¨§ ä ©« 
; AUTORUN.DAT. ”®à¬ â ®ç¥­ì ¯à®áâ ¨ ¢ ª®¬¬¥­â à¨ïå ­¥ ­ã¦¤ ¥âáï.
; ;
; Š®¬¯¨«¨àã©â¥ á ¯®¬®éìî FASM 1.52 ¨ ¢ëè¥ ; Compile with FASM 1.52 or newer
; ;
include "../../../macros.inc" ;-----------------------------------------------------------------------------
; last update: 02/03/2014
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: Reducing the consumption of RAM, 4 KB instead of 32 KB.
; Output to BOARD information about running applications.
; Cleaning of the source code.
; notice: Only 2 KB of memory for AUTORUN.DAT - be careful!
;-----------------------------------------------------------------------------
use32 use32
org 0x0 org 0x0
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
dd 0x01 ; header version dd 0x01 ; header version
dd START ; start of code dd START ; start of code
dd I_END ; size of image dd IM_END ; size of image
dd 0x8000 ; memory for app dd I_END ; memory for app
dd 0x8000 ; esp dd stack_top ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 ; I_Param
dd 0x0 ; I_Icon
;include "DEBUG.INC" ;-----------------------------------------------------------------------------
include "../../../macros.inc"
define __DEBUG__ 1
define __DEBUG_LEVEL__ 1
include "../../../debug-fdo.inc"
;-----------------------------------------------------------------------------
START: ; start of execution START: ; start of execution
mcall 70,autorun_dat_info ; load AUTORUN.DAT
; mov eax, 5
; mov ebx, 10
; mcall
; mcall 18,15
mov eax, 70 ; load AUTORUN.DAT
mov ebx, autorun_dat_info
mcall
add ebx,file_data add ebx,file_data
mov [fileend],ebx mov [fileend],ebx
;-----------------------------------------------------------------------------
; this cycle does not contain an obvious exit condition, ; this cycle does not contain an obvious exit condition,
; but auxiliary procedures (like "get_string") will exit ; but auxiliary procedures (like "get_string") will exit
; at EOF ; at EOF
start_program: start_program:
call skip_spaces call skip_spaces
cmp al,'#' cmp al,byte '#'
jz skip_this_string jz skip_this_string
call clear_strings call clear_strings
mov edi,program mov edi,program
@ -47,30 +47,29 @@ START: ; start of execution
mov edi,parameters mov edi,parameters
call get_string call get_string
call get_number call get_number
;dps <"STARTING A PROGRAM",13,10>
call run_program call run_program
;--------------------------------------
skip_this_string: skip_this_string:
call next_line call next_line
jmp start_program jmp start_program
;-----------------------------------------------------------------------------
exit: exit:
or eax,-1 or eax,-1
mcall mcall
;-----------------------------------------------------------------------------
run_program: ; time to delay in eax run_program: ; time to delay in eax
DEBUGF 1, "Launch: %s Parameter: %s\n",program,parameters
push eax push eax
mcall 70,start_info mcall 70,start_info
pop ebx pop ebx
; if delay is negative, wait for termination ; if delay is negative, wait for termination
; of the spawned process ; of the spawned process
test ebx,ebx test ebx,ebx
js must_wait_for_termination js must_wait_for_termination
; otherwise, simply wait ; otherwise, simply wait
mov eax, 5 mcall 5
mcall
ret ret
;-----------------------------------------------------------------------------
must_wait_for_termination: must_wait_for_termination:
mov esi,eax ; save slot for the future mov esi,eax ; save slot for the future
; get process slot ; get process slot
@ -79,181 +78,217 @@ START: ; start of execution
; if an error has occured, exit ; if an error has occured, exit
test eax,eax test eax,eax
jz child_exited jz child_exited
mov ecx,eax mov ecx,eax
; wait ;--------------------------------------
wait_for_termination: wait_for_termination:
mcall 5,1 mcall 5,1
mov ebx, processinfo mov ebx, processinfo
mcall 9 mcall 9
cmp word [ebx+50], 9 ; the slot was freed? cmp [ebx+50],word 9 ; the slot was freed?
jz child_exited jz child_exited
cmp dword [ebx+30], esi ; the slot is still occupied by our child?
cmp [ebx+30],dword esi ; the slot is still occupied by our child?
jz wait_for_termination jz wait_for_termination
;--------------------------------------
child_exited: child_exited:
ret ret
;-----------------------------------------------------------------------------
clear_strings: ; clears buffers clear_strings: ; clears buffers
pushad pushad
mov ecx,60+1
mov ecx, 60
mov edi,program mov edi,program
xor al, al ;mov al, ' ' xor al,al
rep stosb rep stosb
mov ecx,60+1
mov ecx, 60
mov edi,parameters mov edi,parameters
rep stosb rep stosb
popad popad
ret ret
;-----------------------------------------------------------------------------
get_string: ; pointer to destination buffer in edi get_string: ; pointer to destination buffer in edi
pushad pushad
call skip_spaces call skip_spaces
mov esi,[position] mov esi,[position]
;dpd esi
;dps <13,10>
add esi,file_data add esi,file_data
cmp byte [esi], '"' cmp [esi],byte '"'
jz .quoted jz .quoted
;--------------------------------------
.start: .start:
cmp esi,[fileend] cmp esi,[fileend]
jae exit jae exit
lodsb lodsb
cmp al, ' ' cmp al,byte ' '
jbe .finish jbe .finish
stosb stosb
inc [position] inc dword [position]
jmp .start jmp .start
;--------------------------------------
.finish: .finish:
popad popad
ret ret
;--------------------------------------
.quoted: .quoted:
inc esi inc esi
inc [position] inc dword [position]
;--------------------------------------
.quoted.start: .quoted.start:
cmp esi,[fileend] cmp esi,[fileend]
jae exit jae exit
lodsb lodsb
inc [position] inc dword [position]
cmp al, '"' cmp al,byte '"'
je .finish je .finish
stosb stosb
jmp .quoted.start jmp .quoted.start
;-----------------------------------------------------------------------------
get_number: get_number:
push ebx esi push ebx esi
call skip_spaces call skip_spaces
mov esi,[position] mov esi,[position]
add esi,file_data add esi,file_data
xor eax,eax xor eax,eax
cmp byte [esi], '-' cmp [esi],byte '-'
jnz @f jnz @f
inc eax inc eax
inc esi inc esi
inc [position] inc dword [position]
;--------------------------------------
@@: @@:
push eax push eax
xor eax,eax xor eax,eax
xor ebx,ebx xor ebx,ebx
;--------------------------------------
.start: .start:
cmp esi,[fileend] cmp esi,[fileend]
jae .finish jae .finish
lodsb lodsb
sub al, '0' sub al,byte '0'
cmp al,9 cmp al,9
ja .finish ja .finish
lea ebx,[ebx*4+ebx] lea ebx,[ebx*4+ebx]
lea ebx,[ebx*2+eax] lea ebx,[ebx*2+eax]
inc [position] inc dword [position]
jmp .start jmp .start
;--------------------------------------
.finish: .finish:
pop eax pop eax
dec eax dec eax
jnz @f jnz @f
neg ebx neg ebx
;--------------------------------------
@@: @@:
mov eax,ebx mov eax,ebx
pop esi ebx pop esi ebx
ret ret
;-----------------------------------------------------------------------------
skip_spaces: skip_spaces:
push esi push esi
xor eax,eax xor eax,eax
mov esi,[position] mov esi,[position]
add esi,file_data add esi,file_data
;--------------------------------------
.start: .start:
cmp esi,[fileend] cmp esi,[fileend]
jae .finish jae .finish
lodsb lodsb
cmp al, ' ' cmp al,byte ' '
ja .finish ja .finish
inc [position]
inc dword [position]
jmp .start jmp .start
;--------------------------------------
.finish: .finish:
;dps "NOW AL = "
;mov [tmp],al
;mov edx, tmp
;call debug_outstr
;dps <13,10>
pop esi pop esi
ret ret
;-----------------------------------------------------------------------------
next_line: next_line:
mov esi,[position] mov esi,[position]
add esi,file_data add esi,file_data
;--------------------------------------
.start: .start:
cmp esi,[fileend] cmp esi,[fileend]
jae exit jae exit
lodsb lodsb
cmp al,13 cmp al,13
je .finish je .finish
cmp al,10 cmp al,10
je .finish je .finish
inc [position]
inc dword [position]
jmp .start jmp .start
;--------------------------------------
.finish: .finish:
inc [position] inc dword [position]
cmp esi,[fileend] cmp esi,[fileend]
jae exit jae exit
lodsb lodsb
cmp al,13 cmp al,13
je .finish je .finish
cmp al,10 cmp al,10
je .finish je .finish
ret ret
;-----------------------------------------------------------------------------
; DATA: ; DATA:
position dd 0 ; position in file ;-----------------------------------------------------------------------------
include_debug_strings
;-----------------------------------------------------------------------------
autorun_dat_info: ; AUTORUN.DAT autorun_dat_info: ; AUTORUN.DAT
.mode dd 0 ; read file .mode dd 0 ; read file
.start_block dd 0 ; block to read .start_block dd 0 ; block to read
dd 0 dd 0
.blocks dd 16*512 ; 16*512 bytes max .blocks dd 4*512 ; 2 Kb max for AUTORUN.DAT
.address dd file_data .address dd file_data
db "/SYS/SETTINGS/AUTORUN.DAT",0 db "/SYS/SETTINGS/AUTORUN.DAT",0
;-----------------------------------------------------------------------------
start_info: start_info:
.mode dd 7 .mode dd 7
dd 0 dd 0
.params dd parameters .params dd parameters
dd 0 dd 0
dd 0 dd 0
.path: ;       .path:
;-----------------------------------------------------------------------------
IM_END:
;-----------------------------------------------------------------------------
align 4
processinfo:
;-----------------------------------------------------------------------------
program:
rb 61 ; 60 + [0] char
;-----------------------------------------------------------------------------
parameters:
rb 61
;-----------------------------------------------------------------------------
rb 1024-61*2
;-----------------------------------------------------------------------------
position:
rd 1 ; position in file
;-----------------------------------------------------------------------------
fileend:
rd 1
;-----------------------------------------------------------------------------
align 4
file_data:
rb 4*512 ; 2 Kb for AUTORUN.DAT
;-----------------------------------------------------------------------------
align 4
rb 256
stack_top:
;-----------------------------------------------------------------------------
I_END: I_END:
;-----------------------------------------------------------------------------
program rb 61 ; 60 + [0] char
parameters rb 61
processinfo rb 1024
fileend dd ?
file_data rb 16*512