forked from KolibriOS/kolibrios
692d85ec0c
git-svn-id: svn://kolibrios.org@1065 a494cfbc-eb01-0410-851d-a64ba20cac60
332 lines
9.6 KiB
PHP
332 lines
9.6 KiB
PHP
; Copyright (c) 2009, <Lrz>
|
|
; All rights reserved.
|
|
;
|
|
; Redistribution and use in source and binary forms, with or without
|
|
; modification, are permitted provided that the following conditions are met:
|
|
; * Redistributions of source code must retain the above copyright
|
|
; notice, this list of conditions and the following disclaimer.
|
|
; * Redistributions in binary form must reproduce the above copyright
|
|
; notice, this list of conditions and the following disclaimer in the
|
|
; documentation and/or other materials provided with the distribution.
|
|
; * Neither the name of the <organization> nor the
|
|
; names of its contributors may be used to endorse or promote products
|
|
; derived from this software without specific prior written permission.
|
|
;
|
|
; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka <Lrz> ''AS IS'' AND ANY
|
|
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
|
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
;*****************************************************************************
|
|
|
|
;áëîê ìàêðîñîâ ïî îáðàáîòêå ñåêöèè [loader]
|
|
;âõîäíûå äàííûå:
|
|
;es:di - óêàçàòåëü íà ñåêöèþ íà÷èíàþùèþñÿ ñ '[' âñòå÷àþùèþñÿ ïîñëå 0õa
|
|
;cx - ñ÷åò÷èê êîë-âî áàéò äëÿ ïðîâåðêå â êàäðå
|
|
;
|
|
macro use_parse_loader
|
|
{
|
|
.parse_loader:
|
|
;//////////////////
|
|
;/ parse [loader]
|
|
;//////////////////
|
|
mov bx,cx ;cîõðàíèì â ðåãèñòðû çíà÷åíèÿ ñ÷åò÷èêà è óêàçàòåëÿ
|
|
mov ax,di
|
|
|
|
; mov word [bp-4],.start ;is alredy set, see up
|
|
mov si,parse_loader
|
|
mov cx,parse_loader_e - parse_loader
|
|
repe cmpsb
|
|
jnz error.rest_value ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå ò.å. áóäåì ñíîâà èñêàòü))
|
|
|
|
;ñîõðàíèì óêàçàòåëüíà loader, ÷òî áû ïîòîì áîëüøå åãî íå èñêàòü
|
|
mov point_loader,ax
|
|
sub bx,parse_loader_e - parse_loader ;correct cx
|
|
add bx,cx
|
|
mov cx,bx
|
|
|
|
if DEBUG
|
|
pusha
|
|
mov si,lm_l_found
|
|
call printplain
|
|
popa
|
|
end if
|
|
;/////////////////end check [loader]. [loader] is found
|
|
;parsing section [loader]
|
|
;first found end section,let's found '[' -it's start next section
|
|
;in previosly steep bx =cx we are not need save cx, save only di - point
|
|
mov dx,di
|
|
@@:
|
|
call get_firs_sym
|
|
jcxz .loader_f_end ;.end_loader ; end äàæå åñëè ìû íå íàøëè ñåêöèþ ïðåäïîëîæèì ÷òî ñåêöèÿ [loader] ñòîèò â êîíöå
|
|
cmp al,'['
|
|
jnz @b
|
|
|
|
.loader_f_end:
|
|
sub bx,cx ;bx = n byte presend in section [loader]
|
|
mov di,dx ;restore di
|
|
;////////////////parse parametrs in section [loader]
|
|
;//timeout=5
|
|
;//default=main
|
|
; mov di,dx ;set pointer on section [loader] i think it's not need
|
|
mov cx,bx ;set counter for parsing section [loader] cx= êîë-âó ñèìâîëîâ â ñåêöèè [loader]
|
|
mov ret_on_ch,.get_next_str ; return point
|
|
;;;;;;; parse timeout & default
|
|
.get_next_str:
|
|
call get_firs_sym ;get first symbol on new line
|
|
|
|
test cx,cx
|
|
jz .end_loader
|
|
; jcxz .end_loader ;çàâåðøåíèå ïàðñèíãà çíà÷åíèé timeout & default
|
|
cmp al,'t'
|
|
jz .loader_timeout
|
|
cmp al,'d'
|
|
jnz .get_next_str
|
|
;//////[loader].default
|
|
;input di point to data cx=size [loader]
|
|
mov bx,cx
|
|
mov ax,di
|
|
|
|
mov si,parse_l_default
|
|
mov cx,parse_l_default_e - parse_l_default
|
|
repe cmpsb
|
|
|
|
jnz error.rest_value ;is not compare öåïî÷êà íå ñîâïàëà
|
|
|
|
sub bx,parse_l_default_e - parse_l_default ;correct cx
|
|
add bx,cx
|
|
mov cx,bx
|
|
|
|
test status_flag,flag_found_default
|
|
jz .correct_is_not_set
|
|
|
|
mov si,found_equal_default ;ìû íàøëè ÷òî ôëàã óæå óñòàíîâëåí, èíôîðìèðóåì
|
|
call printplain
|
|
jmp .get_next_str
|
|
|
|
.correct_is_not_set:
|
|
mov ax,0x3d20 ;cut al=' ' ah='='
|
|
repe scasb
|
|
test cx,cx
|
|
jz .end_loader
|
|
|
|
cmp ah,byte [es:di-1] ;find '='
|
|
jnz .get_next_str
|
|
|
|
repe scasb ;cut ' '
|
|
inc cx
|
|
dec di
|
|
;ñåé÷àñ es:di óêàçûâàþò íà íàçâàíèå ñåêöèè, èìÿ ñåêöèè ïî äåôîëòó íå äîëæíî áûòü loader ò.å. èíà÷å âîçìîæíî çàöèêëèâàíèå
|
|
;óñòàíîâèì óêàçàòåëü si íà ýòî çíà÷åíèå è ñíà÷àëà ïðîâåðèì
|
|
|
|
;ïîëó÷åíèå äëèííû ñåêöèè
|
|
; cx=bx ñîäåðæèò äëèííó îñòàòêà ñåêöèè
|
|
; di=ax óêàçàòåëü íà òåêóùèþ ñåêöèþ
|
|
mov bx,cx
|
|
mov dx,di
|
|
|
|
@@: mov al,byte [es:di]
|
|
inc di
|
|
dec cx
|
|
test cx,cx
|
|
jz error.error_get_size_d_sect ;ïåðåõîä íà îáðàáîòêó îøèáêè ïî íàõîæäåíèþ äëèíû äåôîëòíîé ñåêöèè
|
|
cmp al,' '
|
|
jz @b
|
|
cmp al,0xd
|
|
jz .found_size_d_sect
|
|
cmp al,0xa
|
|
jnz @b
|
|
.found_size_d_sect:
|
|
;
|
|
inc cx ;correct cx
|
|
mov ax,bx
|
|
sub bx,cx ; â bx äëèíà ñåêöèè êîòîðàÿ îïðåäåëåíà ïî äåôîëòó
|
|
mov save_cx_d,bx
|
|
mov di,dx
|
|
|
|
mov cx,bx ;set size default section
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ïðîâåðêà íà =loader
|
|
;save in reg point and ñ÷åò÷èê
|
|
;check on loader
|
|
mov bx,ax
|
|
mov ax,dx
|
|
|
|
mov si,parse_loader
|
|
inc si ;set only loader and 6 char in counter
|
|
repe cmpsb
|
|
jnz .check_section ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå )) çíà÷èò íå èñêëþ÷åíèå
|
|
|
|
jmp error.default_eq_loader ;error êðèòè÷åñêàÿ îøèáêà ò.å. â äåôîëòå ïðèñóòñòâóåò èìÿ [loader]
|
|
|
|
.check_section: ;ïîèñê ñîîòâåòñòâóþùåé ñåêöèè íàì íóæíî áóäåò óçíàòü àäðåñ ýòîé ñåêöèè
|
|
mov cx,bx
|
|
mov di,ax
|
|
|
|
;/////////////////////////////
|
|
; mov ret_on_ch,.start_d ;set return
|
|
mov si,di ;óñòàíîâèì óêàçàòåëü íà íàøó ñåêöèþ, êîòîðàÿ ïî äåôîëòó
|
|
|
|
push di ;save point di
|
|
|
|
push cx ;save cx
|
|
;óñòàíîâèì óêàçàòåëü es:di íà íà÷àëî ini ôàéëà
|
|
mov cx,save_cx ;it's placed size of ini file
|
|
les di,dword [file_data]
|
|
|
|
|
|
mov al,byte [es:di]
|
|
push word .first_ret_d
|
|
cmp al,' '
|
|
jz .first_sp_1_d
|
|
jmp get_firs_sym.not_space
|
|
.first_sp_1_d:
|
|
jmp get_firs_sym.first_sp
|
|
|
|
.start_d:
|
|
call get_firs_sym ;get first symbol on new line
|
|
.first_ret_d: ;ïåðâûé âîçâðàò
|
|
jcxz .correct_exit ;.end_loader ;found or not found parametrs in section exit in section
|
|
cmp al,'['
|
|
jz .found_sect_d
|
|
jmp .start_d
|
|
;ïðîñìàòðèâàåì ini ôàéë ñ íà÷àëà â ïîèñêàõ ñåêöèè óêàçàíîé êàê default
|
|
;èäåò ïðîâåðêà íà íàëè÷åå çíà÷åíèÿ timeout, äëÿ áîëåå áûñòðîé ðàáîòû, ýòîò ïàðàìåòð äîëæåí áûòü óæå îáðàáîòàí,ò.å. â ýòîì ñëó÷àå ïðè åãî =0 áóäåò ñôîðìèðîâàí óêàçàòåëü òîëüêî íà äåôîëòíóþ ñåêöèþ, èíà÷å èíôîðìàöèÿ áóäåò ñîáðàíà ïî âñåì ñåêöèÿì è ñîñòàâëåíû óêàçàòåëè â áëîêå ïàìÿòè
|
|
.found_sect_d:
|
|
|
|
;check on name section
|
|
mov bx,cx
|
|
mov ax,di
|
|
push si ;save point
|
|
|
|
; mov si,parse_loader
|
|
mov cx,save_cx_d ;load size section
|
|
push es
|
|
pop ds
|
|
|
|
inc di
|
|
repe cmpsb
|
|
push cs
|
|
pop ds
|
|
pop si
|
|
|
|
jnz .not_compare_d_s ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå )) çíà÷èò íå èñêëþ÷åíèå
|
|
cmp byte[es:di],']'
|
|
jnz .not_compare_d_s ;íåò â êîíöå íàøåé ñåêöèè çàâåðøàþùåãî ñèìâîëà :(
|
|
|
|
|
|
|
|
;set flag -we have found default -not enter again in this prosedure
|
|
or status_flag,flag_found_default
|
|
pop cx
|
|
pop di
|
|
mov point_default,ax ;point to [
|
|
|
|
if DEBUG
|
|
pusha
|
|
mov si,lm_lf_default_f
|
|
call printplain
|
|
popa
|
|
end if
|
|
|
|
jmp .get_next_str
|
|
|
|
.not_compare_d_s:
|
|
|
|
mov cx,bx
|
|
mov di,ax
|
|
jmp .start_d
|
|
|
|
.correct_exit:
|
|
pop cx ;âîññòàíîâèì çíà÷åíèå ñ÷åò÷èêà
|
|
pop di
|
|
|
|
|
|
if DEBUG
|
|
pusha
|
|
mov si,lm_lf_default
|
|
call printplain
|
|
popa
|
|
end if
|
|
jmp .get_next_str
|
|
|
|
;//////////[loader].timeout
|
|
.loader_timeout:
|
|
mov bx,cx
|
|
mov ax,di
|
|
|
|
mov si,parse_l_timeout
|
|
mov cx,parse_l_timeout_e - parse_l_timeout
|
|
repe cmpsb
|
|
jnz error.rest_value ;is not compare
|
|
|
|
sub bx,parse_l_timeout_e - parse_l_timeout ;correct cx
|
|
add bx,cx
|
|
mov cx,bx
|
|
|
|
test status_flag,flag_found_timeout
|
|
jz .correct_is_not_set_t
|
|
|
|
mov si,found_equal_timeout ;ìû íàøëè ÷òî ôëàã óæå óñòàíîâëåí, èíôîðìèðóåì
|
|
call printplain
|
|
jmp .get_next_str
|
|
|
|
.correct_is_not_set_t:
|
|
mov ax,0x3d20 ;cut al=' ' ah='='
|
|
repe scasb
|
|
jcxz .timeout_sec_end_d ;not found param timeout
|
|
|
|
cmp ah,byte [es:di-1] ;find '='
|
|
jnz .get_next_str
|
|
|
|
repe scasb ;cut ' '
|
|
inc cx
|
|
dec di
|
|
;get timeout value
|
|
;2 çíàêa ìîæåò áûòü îáðàáîòàíî ò.å. çíà÷åíèå îò 0 äî 99 ñåêóíä
|
|
push cx
|
|
xor bx,bx
|
|
mov cx,2
|
|
@@: mov al,byte [es:di]
|
|
cmp al,'0'
|
|
jb .end_get_val_t
|
|
cmp al,'9'
|
|
ja .end_get_val_t
|
|
imul bx,10
|
|
xor al,0x30
|
|
add bl,al
|
|
.end_get_val_t:
|
|
inc di
|
|
loop @b
|
|
mov word [value_timeout],bx
|
|
; pop cx
|
|
|
|
if DEBUG
|
|
pusha
|
|
mov si,lm_lf_timeout
|
|
call printplain
|
|
popa
|
|
end if
|
|
|
|
jmp @f
|
|
.timeout_sec_end_d:
|
|
mov word [value_timeout],default_timeout_value
|
|
mov si,set_default_timeout_val
|
|
call printplain
|
|
@@: pop cx
|
|
jmp .get_next_str
|
|
|
|
;///////here end block loader
|
|
.end_loader:
|
|
if DEBUG
|
|
pusha
|
|
mov si,lm_l_end
|
|
call printplain
|
|
popa
|
|
end if
|
|
|
|
} |