loading libs for kernel

loading from HD
inifiles.asm (not completed, using with kernel to load sys.conf)
parse file names
%sys% may be system directory for programs (70 function)

git-svn-id: svn://kolibrios.org@488 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
SPraid (simba) 2007-05-11 19:38:23 +00:00
parent 981a4ac300
commit e1f463adf0
17 changed files with 1249 additions and 43 deletions

View File

@ -116,6 +116,16 @@ start_of_code:
@@:
; \end{diamond}[02.12.2005]
cmp cx,'HA' ; ïî ðåãèñòðàì îïðåäåëÿåòñÿ çàãðóçêà ñ âèíòà
jnz no_hd_load
cmp dx,'RD'
jnz no_hd_load
mov word [bx_from_load], bx ; {SPraid}[13.03.2007]
jmp load_next
no_hd_load:
mov word [bx_from_load], 'r1' ; if work with floppy
load_next:
; set up stack
mov ax, 3000h
mov ss, ax

View File

@ -2,7 +2,7 @@
set languages=en ru ge et
set drivers=sound sis infinity ati2d vmode ps2mouse
set targets=all kernel drivers skins clean
set targets=all kernel drivers skins lib clean
call :Check_Target %1
for %%a in (all kernel) do if %%a==%target% call :Check_Lang %2
@ -60,6 +60,7 @@ goto :eof
call :Target_kernel
call :Target_drivers
call :Target_skins
call :Target_lib
goto :eof
@ -87,6 +88,15 @@ goto :eof
cd ..
goto :eof
:Target_lib
echo *** building libs ...
if not exist bin\lib mkdir bin\lib
cd lib
fasm -m 65536 inifiles.asm ..\bin\lib\inifiles.obj
if not %errorlevel%==0 goto :Error_FasmFailed
cd ..
goto :eof
:Target_clean
echo *** cleaning ...

View File

@ -0,0 +1,20 @@
;-------------------------------------------------------------------------
;
; ” ©« ª®­ä¨£ãà æ¨¨
;
;
; SPraid
;
;-------------------------------------------------------------------------
conf_file_loaded: db 0 ; ä« £ § £à㧪¨ ª®­ä¨£ 
; § £à㧪  ¨­¨ ä ©«  ¢ ¡¨¡«¨®â¥ªã
proc load_conf_file
pushad
invoke ini.load,.fname
mov [conf_file_loaded],byte 1
popad
ret
.fname db '%sys%/sys.conf',0
endp

View File

@ -700,8 +700,8 @@ proc load_driver stdcall, driver_name:dword
endl
lea edx, [file_name]
mov dword [edx], '/rd/'
mov dword [edx+4], '1/dr'
mov dword [edx], '%sys'
mov dword [edx+4], '%/dr'
mov dword [edx+8], 'iver'
mov word [edx+12], 's/'
mov esi, [driver_name]

View File

@ -0,0 +1,326 @@
;============================================================================
;
; Çàãðóçêà âíåøíèõ ôóíêöèé ÿäðà
;
;
;
;
;
;
;============================================================================
macro library [name,fname]
{
forward
dd __#name#_library_table__,__#name#_library_name__
common
dd 0
forward
align 4
__#name#_library_name__ db fname,0
}
macro import lname,[name,sname]
{
common
align 4
__#lname#_library_table__:
forward
name dd __#name#_import_name__
common
dd 0
forward
align 4
__#name#_import_name__ db sname,0
}
macro export [name,sname]
{
forward
dd __#name#_export_name__,name
common
dd 0
forward
align 4
__#name#_export_name__ db sname,0
}
align 4 ; çàãðóçêà áèáëèîòåêè ñ óñëîâèåì, ÷òî áóäèò èñïîëüçûâàòüñÿ èç ÿäðà
proc load_k_library stdcall, file_name:dword
locals
coff dd ?
sym dd ?
strings dd ?
img_size dd ?
img_base dd ?
exports dd ?
endl
cli
stdcall load_file, [file_name]
test eax, eax
jz .fail
mov [coff], eax
movzx ecx, [eax+CFH.nSections]
xor ebx, ebx
lea edx, [eax+20]
@@:
add ebx, [edx+CFS.SizeOfRawData]
add ebx, 15
and ebx, not 15
add edx, COFF_SECTION_SIZE
dec ecx
jnz @B
mov [img_size], ebx
stdcall kernel_alloc, [img_size]
test eax, eax
jz .fail
mov [img_base], eax
mov edx, [coff]
movzx ebx, [edx+CFH.nSections]
mov edi, [img_base]
lea eax, [edx+20]
@@:
mov [eax+CFS.VirtualAddress], edi
mov esi, [eax+CFS.PtrRawData]
test esi, esi
jnz .copy
add edi, [eax+CFS.SizeOfRawData]
jmp .next
.copy:
add esi, edx
mov ecx, [eax+CFS.SizeOfRawData]
cld
rep movsb
.next:
add edi, 15
and edi, not 15
add eax, COFF_SECTION_SIZE
dec ebx
jnz @B
mov ebx, [edx+CFH.pSymTable]
add ebx, edx
mov [sym], ebx
mov ecx, [edx+CFH.nSymbols]
add ecx,ecx
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE
add ecx, [sym]
mov [strings], ecx
lea eax, [edx+20]
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\
[strings], dword 0
test eax, eax
jnz @F
@@:
mov edx, [coff]
movzx ebx, [edx+CFH.nSections]
mov edi, 0
lea eax, [edx+20]
@@:
add [eax+CFS.VirtualAddress], edi ;patch user space offset
add eax, COFF_SECTION_SIZE
dec ebx
jnz @B
add edx, 20
stdcall fix_coff_relocs, [coff], edx, [sym]
mov ebx, [coff]
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS
mov [exports], eax
stdcall kernel_free, [coff]
mov eax, [exports]
ret
.fail:
xor eax, eax
ret
endp
proc dll.Load, import_table:dword
mov esi,[import_table]
.next_lib: mov edx,[esi]
or edx,edx
jz .exit
push esi
mov edi,s_libname
mov esi,sys_path
@@: lodsb
stosb
or al,al
jnz @b
dec edi
mov [edi], dword '/lib'
mov [edi+4],byte '/'
add edi,5
pop esi
push esi
mov esi,[esi+4]
@@: lodsb
stosb
or al,al
jnz @b
pushad
stdcall load_k_library,s_libname
mov [esp+28],eax
popad
or eax,eax
jz .fail
stdcall dll.Link,eax,edx
stdcall dll.Init,[eax+4]
pop esi
add esi,8
jmp .next_lib
.exit: xor eax,eax
ret
.fail: add esp,4
xor eax,eax
inc eax
ret
endp
proc dll.Link, exp:dword,imp:dword
push eax
mov esi,[imp]
test esi,esi
jz .done
.next: lodsd
test eax,eax
jz .done
stdcall dll.GetProcAddress,[exp],eax
or eax,eax
jz @f
mov [esi-4],eax
jmp .next
@@: mov dword[esp],0
.done: pop eax
ret
endp
proc dll.Init, dllentry:dword
pushad
mov eax,mem.Alloc
mov ebx,mem.Free
mov ecx,mem.ReAlloc
mov edx,dll.Load
stdcall [dllentry]
popad
ret
endp
proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx,[exp]
.next: test edx,edx
jz .end
stdcall strcmp,[edx],[sz_name]
test eax,eax
jz .ok
add edx,8
jmp .next
.ok: mov eax,[edx+4]
.end: ret
endp
;-----------------------------------------------------------------------------
proc mem.Alloc size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
; mov eax,[size]
; lea ecx,[eax+4+4095]
; and ecx,not 4095
; stdcall kernel_alloc, ecx
; add ecx,-4
; mov [eax],ecx
; add eax,4
stdcall kernel_alloc, [size]
pop ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx esi edi eax
mov eax,[mptr]
mov ebx,[size]
or eax,eax
jz @f
lea ecx,[ebx+4+4095]
and ecx,not 4095
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: mov eax,ebx
call mem.Alloc
xchg eax,[esp]
or eax,eax
jz .exit
mov esi,eax
xchg eax,[esp]
mov edi,eax
mov ecx,[esi-4]
cmp ecx,[edi-4]
jbe @f
mov ecx,[edi-4]
@@: add ecx,3
shr ecx,2
cld
rep movsd
xchg eax,[esp]
call mem.Free
.exit:
pop eax edi esi ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.Free mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; mov eax,[mptr]
; or eax,eax
; jz @f
; push ebx ecx
; lea ecx,[eax-4]
; stdcall kernel_free, ecx
; pop ecx ebx
; @@: ret
stdcall kernel_free, [mptr]
ret
endp
proc strcmp, str1:dword,str2:dword
push esi edi
mov esi,[str1]
mov edi,[str2]
xor eax,eax
@@: lodsb
scasb
jne .fail
or al,al
jnz @b
jmp .ok
.fail: or eax,-1
.ok: pop edi esi
ret
endp
s_libname db 64 dup (0)

View File

@ -5,6 +5,10 @@ flm db 0
preboot_lfb db 0
preboot_bootlog db 0
bx_from_load: dw 0 ; структура для хранения параметров- откуда гашрузились, берется ниже из bx ; {SPraid}[13.03.2007]
; a,b,c,d - винчестеры, r - рам диск
; # диска... символ, а не байт. '1', а не 1
align 4
old_ints_h:
dw 0x400

View File

@ -82,13 +82,21 @@ szSTART db 'START',0
szEXPORTS db 'EXPORTS',0
szIMPORTS db 'IMPORTS',0
firstapp db '/rd/1/LAUNCHER',0
char db 'FONTS/CHAR.MT',0
char2 db 'FONTS/CHAR2.MT',0
firstapp db '%sys%/LAUNCHER',0
char dd 0,0,0
dd 2560
dd FONT_I
db '%sys%/FONTS/CHAR.MT',0
char2 dd 0,0,0
dd 2560
dd FONT_II
db '%sys%/FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI '
bootpath2 db 0
vmode db 'drivers/VMODE.MDR',0
vrr_m db '/rd/1/VRR_M',0
vrr_m db '%sys%/VRR_M',0
kernel_file db 'KERNEL MNT'
@ -105,6 +113,16 @@ drawbar dd __sys_drawbar.forced
putpixel dd __sys_putpixel
; } mike.dld
; SPraid.simba { 6.05.2007
; êîíñòàíòû äëÿ îáðàùåíèÿ ê èíè ôàéëó äëÿ îïðåäåëåíèÿ óñòðîéñòâ
;
ini_dev_sect: db 'dev',0 ; ñåêöèÿ îá óñòðîéñòâàõ
ini_com1_mouse_detect: db 'com1_mouse',0
ini_com2_mouse_detect: db 'com2_mouse',0
dev_dev_val: db '2',0 ; äàëåå åñëè 2 - òî äåòåêòèðîâàòü
; } SPraid.simba
align 4
keyboard dd 1

View File

@ -6,6 +6,9 @@ $Revision$
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
image_of_eax EQU esp+44 ;36
image_of_ebx EQU esp+32 ;24
; System function 70 - files with long names (LFN)
; diamond, 2006
@ -79,6 +82,12 @@ virtual_root_query:
dd 0
endg
end_of_file_system_lfn:
pop edx
stdcall kernel_free, edx
ret
file_system_lfn:
; in: eax->fileinfo block
; operation codes:
@ -93,6 +102,53 @@ file_system_lfn:
; 8 : delete file
; 9 : create directory
; çàìåíà àäðåñà âîçâðàòà
push eax
stdcall kernel_alloc, 200
mov edx,eax
pop eax
push edx
push end_of_file_system_lfn
mov ebx,edx
mov ecx, [eax]
mov [ebx],ecx
add ebx,4
mov ecx, [eax+4]
mov [ebx],ecx
add ebx,4
mov ecx, [eax+8]
mov [ebx],ecx
add ebx,4
mov ecx, [eax+12]
mov [ebx],ecx
add ebx,4
mov ecx, [eax+16]
mov [ebx],ecx
add ebx,4
push edx ; !!!!!!!!!!!!!!!!!!!
; eax - yíà÷àëî ñòàðîãî ïàêåòà
; edx - íà÷àëî íîâîãî ïàêåòà
; ebx - êóäà ëîæèòü ñòðîêó
add eax,20
mov cl, [eax]
test cl,cl
jnz @f
mov eax,[eax+1]
@@:
stdcall full_file_name,eax,ebx
pop eax
; add eax, std_application_base_address
; parse file name
xchg ebx, eax
@ -115,13 +171,13 @@ file_system_lfn:
; add ebx, new_app_base
.l1:
call fs_execute ; ebp, ebx, edx
mov [esp+36], eax
mov [image_of_eax], eax
ret
@@:
cmp al, '/'
jz @f
.notfound:
mov dword [esp+36], 5 ; file not found
mov dword [image_of_eax], 5 ; file not found
ret
@@:
cmp byte [esi], 0
@ -223,15 +279,15 @@ file_system_lfn:
js @f
mov al, ERROR_END_OF_FILE
@@:
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
; directory /
.rootdir:
cmp dword [ebx], 1 ; read folder?
jz .readroot
.access_denied:
mov dword [esp+36], 10 ; access denied
mov dword [image_of_eax], 10 ; access denied
ret
.readroot:
@ -299,8 +355,8 @@ file_system_lfn:
js @f
mov al, ERROR_END_OF_FILE
@@:
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
.found1:
@ -338,7 +394,7 @@ file_system_lfn:
; in: ecx = partition number
; esi -> relative (for device) name
; ebx -> fileinfo
; out: [esp+36]=image of eax, [esp+24]=image of ebx
; out: [image_of_eax]=image of eax, [image_of_ebx]=image of ebx
fs_OnRamdisk:
cmp ecx, 1
@ -351,11 +407,11 @@ fs_OnRamdisk:
; add edx, std_application_base_address
add ebx, 4
call dword [fs_RamdiskServices + eax*4]
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
.not_impl:
mov dword [esp+36], 2 ; not implemented
mov dword [image_of_eax], 2 ; not implemented
ret
fs_NotImplemented:
@ -389,8 +445,8 @@ fs_OnFloppy:
add ebx, 4
call dword [fs_FloppyServices + eax*4]
and [flp_status], 0
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
fs_FloppyServices:
@ -440,7 +496,7 @@ fs_OnHd:
.nf:
call free_hd_channel
and [hd1_status], 0
mov dword [esp+36], 5 ; not found
mov dword [image_of_eax], 5 ; not found
ret
@@:
mov [fat32part], ecx
@ -457,13 +513,13 @@ fs_OnHd:
call dword [fs_HdServices + eax*4]
call free_hd_channel
and [hd1_status], 0
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
.not_impl:
call free_hd_channel
and [hd1_status], 0
mov dword [esp+36], 2 ; not implemented
mov dword [image_of_eax], 2 ; not implemented
ret
fs_HdServices:
@ -520,7 +576,7 @@ fs_OnCd:
.nf:
call free_cd_channel
and [cd_status], 0
mov dword [esp+36], 5 ; not found
mov dword [image_of_eax], 5 ; not found
ret
@@:
mov ecx, [ebx+12]
@ -533,13 +589,13 @@ fs_OnCd:
call dword [fs_CdServices + eax*4]
call free_cd_channel
and [cd_status], 0
mov [esp+36], eax
mov [esp+24], ebx
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
.not_impl:
call free_cd_channel
and [cd_status], 0
mov dword [esp+36], 2 ; not implemented
mov dword [image_of_eax], 2 ; not implemented
ret
fs_CdServices:

View File

@ -0,0 +1,183 @@
;-------------------------------------------------------------------------
;
; ‡ ¬¥­  ¨¬¥­ ä ©«®¢
;
;
; SPraid
;
;-------------------------------------------------------------------------
; ¯¥à¥¡¨à ¥â ¯® ä ©«ã ¢ à¨ ­âë § ¬¥­
proc full_file_name stdcall,sourc,dest
locals
param rb 60
val rb 60
tmpsrc rb 60 ; ¢à¥¬¥­­®¥ åà ­¥­¨¥ ¯à¥®¡à §®¢ ­¨ï
endl
pushad
mov esi,[sourc]
mov edi,ebp
add edi,tmpsrc-ebp
@@:
lodsb
stosb
or al,al
jnz @b
mov al,[conf_file_loaded] ; âॡã¥âáï ¯à¨ ®¡à é¥­¨¨ ª ¯¥à¢®¬ã ä ©«ã (ª®­ä¨£ã)
or al,al
jnz @use_replace
jmp full_file_name_exit
;--------------------------------
@use_replace:
xor eax,eax
.loop:
push eax
mov ebx,ebp
add ebx,param-ebp
mov ecx,ebp
add ecx,val-ebp
invoke ini.get_par,sect, ebx, ecx, eax
mov bl,[param]
or bl,bl
jz .done
mov eax,ebp
add eax,tmpsrc-ebp
mov ebx,ebp
add ebx,param-ebp
mov ecx,ebp
add ecx,val-ebp
mov edx,[dest]
stdcall full_file_name_parse, eax,edx,ebx,ecx
mov esi,[dest]
mov edi,ebp
add edi,tmpsrc-ebp
@@:
lodsb
stosb
or al,al
jnz @b
pop eax
inc eax
jmp .loop
.done:
pop eax
full_file_name_exit:
mov eax,ebp
add eax,tmpsrc-ebp
stdcall full_file_name_parse , eax , [dest], sysdir_ , sys_path
popad
ret
endp
sect: db 'path',0
;
; <EFBFBD>८¡à §®¢ âì ¨¬ï ¢ ¯®«­®¥. …᫨ ¢ ­ ç «¥ á⮨â
; sourc - áá뫪  ­  áâபã...
; dest - áá뫪  ­  ¡ãä¥à ªã¤  १ã«ìâ â «®¦¨âì
; def - áâப  è ¡«®­ ¤«ï ¯®¨áª 
; dval - ª 祬㠯à¨à ¢­¨¢ âì è ¡«®­
proc full_file_name_parse stdcall,sourc,dest,def,dval
; ¤«ï ®¤­®£®
pushad
mov eax,[sourc]
mov ebx,[def]
@@:
mov dl,[ebx]
mov cl,[eax]
cmp cl,0
je @@bad_s
cmp dl,0
je @@good
or cl,0x20
or dl,0x20
cmp cl,dl
jne @@bad
inc eax
inc ebx
jmp @b
@@bad_s:
cmp dl,0
je @@good
@@bad:
mov edi,[dest]
mov esi,[sourc]
@@:
lodsb
stosb
or al,al
jnz @b
jmp @@ret_ok
@@good:
push eax
mov edi,[dest]
mov esi,[dval]
@@:
lodsb
stosb
or al,al
jnz @b
@@goodl:
pop esi
dec edi
@@:
lodsb
stosb
or al,al
jnz @b
@@ret_ok:
popad
ret
endp
sys_dir_mess: db 'System dir is '
sys_path: db '/HD0/1/KOLIBRI',0,0
sysdir_ db '%sys%',0
; ¡¥à¥â ¯ à ¬¥âàë bx_from_load ¨ ¨áç¨â ä ©« ª®­ä¨£ãà æ¨¨
Parser_params:
pushad
mov ax,[BOOT_VAR+bx_from_load]
cmp al,'r' ; à ¬ ¤¨áª
jnz @f
mov [sys_path],dword '/RD/'
mov [sys_path+4],byte ah
mov [sys_path+5],word 0 ;0x002F
jmp .done
@@:
sub al,49
mov [sys_path],dword '/HDa'
mov [sys_path+3],byte al
mov [sys_path+4],byte '/'
mov [sys_path+5],byte ah
mov [sys_path+6],dword '/KOL'
mov [sys_path+10],dword 'IBRI'
mov [sys_path+14],word 0 ;0x002F
.done:
popad
ret

View File

@ -16,9 +16,25 @@ load_skin_file:
mov ebx,1
or ecx,-1
mov esi,12
call fileread
pushad
push eax
mov [skin_to_load.adr],edx
mov [skin_to_load.stradr],_skin_file_default
mov eax,skin_to_load
call file_system_lfn
pop eax
popad
ret
skin_to_load:
dd 0,0,0
dd 64*1024
.adr dd 0
db 0
.stradr dd 0
struct SKIN_HEADER
.ident dd ?
.version dd ?

View File

@ -11,7 +11,7 @@ $Revision$
;
iglobal
_skin_file_default db 'DEFAULT SKN',0
_skin_file_default db '%sys%/DEFAULT.SKN',0
endg
struct SKIN_DATA

View File

@ -536,19 +536,39 @@ include 'boot/rdload.inc'
include 'vmodeld.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
call Parser_params
mov ax,[BOOT_VAR+bx_from_load]
cmp ax,'r1' ; åñëè ñðàì äèñê - òî íå ãðóçèòü áèáëèîòåêè
je no_lib_load
; LOADING LIBRARES
stdcall dll.Load,@IMPORT ; SPraid - çàãðóçêà ôóíêöèîíàëà (ïîêà ÷òî èíè ôàéë)
call load_conf_file ; prepare configuration file
no_lib_load:
; LOAD FONTS I and II
mov esi,char
xor ebx,ebx
mov ecx,2560
mov edx,FONT_I
call fs_RamdiskRead
; mov esi,char
; xor ebx,ebx
; mov ecx,2560
; mov edx,FONT_I
; call fs_RamdiskRead
; mov esi,char2
; xor ebx,ebx
; mov ecx,2560;26000
; mov edx,FONT_II
; call fs_RamdiskRead
pushad
push eax
mov eax,char
call file_system_lfn
mov eax,char2
call file_system_lfn
pop eax
popad
mov esi,char2
xor ebx,ebx
mov ecx,2560;26000
mov edx,FONT_II
call fs_RamdiskRead
mov esi,boot_fonts
call boot_log
@ -745,22 +765,58 @@ include 'vmodeld.inc'
cmp byte [BOOT_VAR+0x9030],1
jne no_load_vrr_m
mov ebp, vrr_m
; mov ebp, vrr_m
; xor ebx, ebx
; xor edx, edx
; call fs_execute
; cmp eax,2 ; if vrr_m app found (PID=2)
; je first_app_found
stdcall kernel_alloc, 0x100
push eax
mov ebx,eax
stdcall full_file_name,vrr_m,eax
mov ebp, eax
xor ebx, ebx
xor edx, edx
call fs_execute
pop ebx
push eax
stdcall kernel_free, ebx
pop eax
cmp eax,2 ; if vrr_m app found (PID=2)
je first_app_found
no_load_vrr_m:
mov ebp, firstapp
; mov ebp, firstapp
; xor ebx, ebx
; xor edx, edx
; call fs_execute
; cmp eax,2 ; continue if a process has been loaded
; je first_app_found
; mov eax, 0xDEADBEEF ; otherwise halt
; hlt
stdcall kernel_alloc, 0x100
push eax
mov ebx,eax
stdcall full_file_name,firstapp,eax
mov ebp, eax
xor ebx, ebx
xor edx, edx
call fs_execute
pop ebx
push eax
stdcall kernel_free, ebx
pop eax
cmp eax,2 ; continue if a process has been loaded
je first_app_found
mov eax, 0xDEADBEEF ; otherwise halt
hlt
first_app_found:
cli
@ -3372,7 +3428,7 @@ checkpixel:
ret
iglobal
cpustring db '/RD/1/CPU',0
cpustring db '%sys%/CPU',0
endg
uglobal

View File

@ -244,3 +244,15 @@ include "hid/mousedrv.inc"
include "hid/set_dtc.inc"
;% -include
;parser file names
include "fs/parse_fn.inc"
; work with conf lib
include "core/conf_lib.inc"
; load external lib
include "core/ext_lib.inc"
; list of external functions
include "lib_func.inc"

View File

@ -0,0 +1,372 @@
;-----------------------------------------------------------------------------
; Copyright (c) 2007, SPraid
;-----------------------------------------------------------------------------
format MS COFF
public EXPORTS
include '../proc32.inc'
include 'proc.inc'
purge section
section '.flat' code readable align 16
mem.alloc dd ?
mem.free dd ?
mem.realloc dd ?
dll.load dd ?
block_count: dd 0
sect_num: dd 0
data_adr: dd 0
data_adr_last dd 0
filei_len EQU 0x4000
filei dd ?;0x4000 ; áá뫪¨ ­  ¤ ­­ë¥ - ⨯  â ¬ åà ­¨âìáï ¡ã¤¨â... ¢­ ç «¥ â ¬ - ᪮ª  ­ ¤  ¢ë¤¥«¨âì
sec_i_len EQU 0x4000
sec_i dd ?;0x4000
dat_i_len EQU 0x4000
dat_i dd ?;0x4000
;-----------------------------------------------------------------------------
proc lib_init ;////////// ˆ­æ¨«¨§ æ¨ï ¡¨¡«¨®â¥ª¨ ( ¢â®¬ â¨ç¥áª¨© ¢ë§®¢)///////
;-----------------------------------------------------------------------------
mov [mem.alloc],eax
mov [mem.free],ebx
mov [mem.realloc],ecx
mov [dll.load],edx
xor eax,eax
inc eax
ret
endp
; áâàãªâãà  ¡«®ª 
block_adr EQU 0
block_name EQU block_adr + 4
block_i_count EQU block_name + 30
block_len EQU block_i_count + 4
; áâàãªâãà  ¤ ­­ëå
data_name EQU 0
data_prev EQU data_name+200
data_next EQU data_prev+4
data_len EQU data_next+4
; ¢§ïâì á«¥¤ã騩 ¯ àã § ­ç¥­¨ï ª«îç 
proc ini.get_par stdcall, sect:dword, param:dword, val:dword, num:dword
pushad
mov edx,[block_count]
mov edi,[sect]
mov esi,[sec_i]
add esi,block_name
@@: call strcmp
cmp eax,-1
jne .sec_found
dec edx
or edx,edx
jz .sec_not_found
add esi,block_len
jmp @b
.sec_found:
mov eax,esi
sub eax,block_name
add eax, block_i_count
mov eax,[eax]
; eax - count
mov ebx,[num] ; test max count
; ebx - num
cmp eax,ebx
jle .param_not_found
sub esi,4
mov esi,[esi]
; esi - first adr
mov eax,ebx ; eax - num
@@:
or eax,eax
je .param_found
dec eax
add esi,data_next
mov esi,[esi]
jmp @b
.param_found:
mov ebx,esi
mov eax,[param]
mov cl,'='
call copy_s
add ebx,eax
add ebx,1
mov eax,[val]
mov cl,0
call copy_s
jmp .ok
.param_not_found:
.sec_not_found:
; set_default_.... 0
mov eax,[param]
mov [eax],byte 0
mov eax,[val]
mov [eax],byte 0
.ok:
popad
ret
endp
;------------------------------------------------------
proc ini.get_str stdcall, sect:dword, param:dword, buff:dword, default:dword
; sect - ᥪæ¨ï
; param - ¯ à ¬¥âà
; buff - ¡ãä¥à
; default - ¥á«¨ ®âáãâáâ¢ã¥â
pushad
mov edx,[block_count]
mov edi,[sect]
mov esi,[sec_i]
add esi,block_name
@@: call strcmp
cmp eax,-1
jne .sec_found
dec edx
or edx,edx
jz .sec_not_found
add esi,block_len
jmp @b
.sec_found:
mov eax,esi
sub eax,block_name
add eax, block_i_count
mov eax,[eax]
; eax - count
sub esi,4
mov esi,[esi]
; esi - first adr
mov edi,[param]
push eax
@@:
mov cl,'='
mov eax,text
mov ebx,esi
call copy_s
mov edx,eax
push esi
mov esi,text
call strcmp
pop esi
cmp eax,-1
jne .param_found
pop eax
dec eax
or eax,eax
jz .sec_not_found
push eax
add esi,data_next
mov esi,[esi]
jmp @b
.param_found:
mov ebx,esi
add ebx,edx
add ebx,1
pop eax
mov eax,[buff]
mov cl,0
call copy_s
jmp .ok
.param_not_found:
.sec_not_found:
; set_default_text
mov eax,[buff]
mov ebx,[default]
mov cl,0
call copy_s
.ok:
popad
ret
endp
;--------------------------------------------------------------------------------
;-----------------------------------------------------------------------------
proc ini.load stdcall filename ;/(§ £à㧪  ¨­¨ ä ©« )/////////////////////////
locals
reads: dd 0,0,0
fsize dd 0
addr dd filei
nulls db 0
fname dd 0
endl
mov [reads],dword 0
mov [reads+4],dword 0
mov [reads+8],dword 0
mov [nulls],byte 0
stdcall get_filesize, [filename]
mov [fsize],eax
inc eax
mov ebx,eax
invoke mem.alloc,eax
mov [filei],eax
mov [addr],eax
add eax,ebx
mov [eax], byte 0 ;null string
invoke mem.alloc,sec_i_len
mov [sec_i],eax
invoke mem.alloc,dat_i_len
mov [dat_i],eax
mov [data_adr],eax
mov eax,[filename]
mov [fname],eax
mov eax,70
mov ebx , reads-ebp
add ebx,ebp
int 0x40
stdcall readlnf
xor eax,eax
ret
endp
proc readlnf
pushad
mov [.pos],dword 0
.char:
mov eax,[.pos]
inc eax
mov [.pos],eax
sub eax,1
add eax,[filei]
mov al,[eax] ; ᨬ¢®« ®â ¯®§¨æ¨¨
; ⨯ ¯® ¯¥à¢®¬ã ᨬ¢®«ã
cmp al,' '
je .char
cmp al,9
je .char
cmp al,13
je .char
cmp al,10
je .char
cmp al,'['
je .sect
cmp al,0
je .exit
;------------------------------------------------------------------------------------------
; ç⥭¨¥ ¯ à ¬¥â஢
mov eax,[data_adr]
mov ebx,[.pos]
add ebx,[filei]
dec ebx
mov cl,0xD
call copy_s
xchg ebx,eax
mov eax,[.pos]
add eax,ebx
mov [.pos],eax
mov ebx,[data_adr]
mov ecx,[data_adr_last]
mov [ebx+data_prev],ecx
;add ebx,data_next
mov [ecx],ebx
add ebx,data_next
mov [data_adr_last],ebx
add ebx,data_len-data_next
mov [data_adr],ebx
mov eax,[sect_num]
imul eax,eax,block_len
add eax,[sec_i]
add eax, block_i_count
mov ebx,[eax]
inc ebx
mov [eax],ebx
jmp .test_next
;-----------------------------------------------------------------------------------------------------------------
.sect: ; ç⥭¨¥ ᥪ樨
mov eax,[block_count]
imul eax,eax,block_len
; ª®¯¨à㥬 ¨¬ï (¤® ])
add eax,[sec_i]
add eax,block_name ; ªã¦  «®¦¨âì ¨¬ï
mov ebx,[.pos]
add ebx,[filei] ; ®âªã¤ 
mov cl,']'
call copy_s ; «®¦¨¬
mov ebx,[.pos]
add ebx,eax
;sub ebx,filei
add ebx,1
mov [.pos],ebx
mov eax,[block_count] ; ¯à¨¡ ¢¨âì ª®«¨ç¥á⢮ ¡«®ª®¢
mov [sect_num],eax
mov ebx,eax
imul eax,eax,block_len ; íâ® ¡ã¤¨â  ¤à¥á ¯¥à¤ë¤ã饣® ¤«ï ¯¥à¢®£® í«¥¬¥­â 
add eax,[sec_i]
mov [data_adr_last],eax
inc ebx
mov [block_count],ebx
.test_next:
cmp [.pos] ,dword 97
jb .char
.exit:
popad
ret
.pos dd 0
endp
text db 255 dup(?)
align 16
EXPORTS:
export \
lib_init ,'lib_init',\
ini.load ,'ini.load',\
ini.get_str,'ini.get_str',\
ini.get_par,'ini.get_par'

100
kernel/trunk/lib/proc.inc Normal file
View File

@ -0,0 +1,100 @@
macro export [name,sname]
{
forward
dd __#name#_export_name__,name
common
dd 0
forward
align 4
__#name#_export_name__ db sname,0
}
copy_s:
; eax - ªã¤ 
; ebx - ®âªã¤ 
; cl - ¤® 祣®
; ¢ë室 - eax - ᪮«ìª® ᪮¯¨à®¢ ­®
pushad
push eax
@@:
mov ch,[ebx]
cmp ch,cl
je @f
mov [eax],ch
inc ebx
inc eax
jmp @b
@@:
mov [eax], byte 0
pop ebx
sub eax,ebx
mov [esp+0x1c],eax
popad
ret
strcmp:
; esi - áâப  1
; edi - áâப  2
; ¢ë室 - eax=-1 - ­¥à ¢­®
xor eax,eax
pushad
@@: lodsb
scasb
jne .fail
or al,al
jnz @b
jmp .ok
.fail: or eax,-1
mov [esp+0x1c],eax
.ok: popad
ret
proc get_filesize stdcall, file_name:dword
locals
cmd dd ?
offset dd ?
dd ?
count dd ?
buff dd ?
db ?
name dd ?
info dd ?
flags dd ?
cr_time dd ?
cr_date dd ?
acc_time dd ?
acc_date dd ?
mod_time dd ?
mod_date dd ?
file_size dd ?
file dd ?
file2 dd ?
endl
xor eax, eax
mov ebx, [file_name]
mov ecx,info-ebp
add ecx,ebp
mov [cmd], 5
mov [offset], eax
mov [offset+4], eax
mov [count], eax
mov [buff], ecx
mov byte [buff+4], al
mov [name], ebx
mov eax, 70
lea ebx, [cmd]
int 0x40
mov eax,[file_size]
ret
endp

21
kernel/trunk/lib_func.inc Normal file
View File

@ -0,0 +1,21 @@
;============================================================================
;
; Çàãğóçêà ññûëêè íà âíåøíèå ôóíêöèè
;
;
;
;
;
;
;============================================================================
@IMPORT:
library \
libini,'inifiles.obj'
import libini, \
ini.load,'ini.load',\
ini.get_str,'ini.get_str',\
ini.get_par,'ini.get_par'

2
kernel/trunk/sys.conf Normal file
View File

@ -0,0 +1,2 @@
[path]
/rd/1=%sys%