Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2433 → Rev 2434

/kernel/branches/Kolibri-acpi/core/conf_lib.inc
13,7 → 13,8
$Revision$
 
iglobal
conf_path_sect: db 'path',0
conf_path_sect:
db 'path',0
 
conf_fname db '/sys/sys.conf',0
endg
/kernel/branches/Kolibri-acpi/core/debug.inc
13,7 → 13,8
cmp ebx, 9
ja @f
jmp dword [sys_debug_services_table+ebx*4]
@@: ret
@@:
ret
iglobal
align 4
sys_debug_services_table:
93,7 → 94,8
cmp cl, 5
jnz .ret
mov cl, 2
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.2:
mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret:
sti
ret
108,9 → 110,12
cmp cl, 2
jnz .ret
mov cl, 5
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret: ret
.1: dec ecx
.2:
mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret:
ret
.1:
dec ecx
jmp .2
 
debug_resume:
122,7 → 127,8
shl eax, 5
jz .ret
call do_resume
.ret: sti
.ret:
sti
ret
 
debug_getcontext:
/kernel/branches/Kolibri-acpi/core/dll.inc
139,7 → 139,7
cmp [edi+SRV.magic], ' SRV'
jne .fail
 
cmp [edi+SRV.size], SRV.sizeof
cmp [edi+SRV.size], sizeof.SRV
jne .fail
 
stdcall [edi+SRV.srv_proc], esi
171,7 → 171,7
cmp [eax+SRV.magic], ' SRV'
jne .fail
 
cmp [eax+SRV.size], SRV.sizeof
cmp [eax+SRV.size], sizeof.SRV
jne .fail
 
stdcall [eax+SRV.srv_proc], ecx
196,7 → 196,7
@@:
mov edx, [srv.fd]
@@:
cmp edx, srv.fd-SRV_FD_OFFSET
cmp edx, srv.fd-SRV.fd
je .not_load
 
stdcall strncmp, edx, [sz_name], 16
226,7 → 226,7
cmp [handler], eax
je .fail
 
mov eax, SRV.sizeof
mov eax, sizeof.SRV
call malloc
test eax, eax
jz .fail
243,9 → 243,9
pop esi
 
mov [eax+SRV.magic], ' SRV'
mov [eax+SRV.size], SRV.sizeof
mov [eax+SRV.size], sizeof.SRV
 
mov ebx, srv.fd-SRV_FD_OFFSET
mov ebx, srv.fd-SRV.fd
mov edx, [ebx+SRV.fd]
mov [eax+SRV.fd], edx
mov [eax+SRV.bk], ebx
514,10 → 514,10
mov edi, [symbols]
mov [retval], 1
.fix:
movzx ebx, [edi+CSYM.SectionNumber]
movzx ebx, [edi+COFF_SYM.SectionNumber]
test ebx, ebx
jnz .internal
mov eax, dword [edi+CSYM.Name]
mov eax, dword [edi+COFF_SYM.Name]
test eax, eax
jnz @F
 
542,7 → 542,7
mov [retval],0
@@:
mov edi, [symbols]
mov [edi+CSYM.Value], eax
mov [edi+COFF_SYM.Value], eax
jmp .next
.internal:
cmp bx, -1
555,10 → 555,10
lea ebx, [ebx+ebx*4]
add ebx, [sec]
 
mov eax, [ebx+CFS.VirtualAddress]
add [edi+CSYM.Value], eax
mov eax, [ebx+COFF_SECTION.VirtualAddress]
add [edi+COFF_SYM.Value], eax
.next:
add edi, CSYM_SIZE
add edi, sizeof.COFF_SYM
mov [symbols], edi
dec [sym_count]
jnz .fix
574,38 → 574,38
endl
 
mov eax, [coff]
movzx ebx, [eax+CFH.nSections]
movzx ebx, [eax+COFF_HEADER.nSections]
mov [n_sec], ebx
lea esi, [eax+20]
.fix_sec:
mov edi, [esi+CFS.PtrReloc]
mov edi, [esi+COFF_SECTION.PtrReloc]
add edi, [coff]
 
movzx ecx, [esi+CFS.NumReloc]
movzx ecx, [esi+COFF_SECTION.NumReloc]
test ecx, ecx
jz .next
.reloc_loop:
mov ebx, [edi+CRELOC.SymIndex]
mov ebx, [edi+COFF_RELOC.SymIndex]
add ebx,ebx
lea ebx,[ebx+ebx*8]
add ebx, [sym]
 
mov edx, [ebx+CSYM.Value]
mov edx, [ebx+COFF_SYM.Value]
 
cmp [edi+CRELOC.Type], 6
cmp [edi+COFF_RELOC.Type], 6
je .dir_32
 
cmp [edi+CRELOC.Type], 20
cmp [edi+COFF_RELOC.Type], 20
jne .next_reloc
.rel_32:
mov eax, [edi+CRELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress]
mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+COFF_SECTION.VirtualAddress]
sub edx, eax
sub edx, 4
jmp .fix
.dir_32:
mov eax, [edi+CRELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress]
mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+COFF_SECTION.VirtualAddress]
.fix:
add eax, [delta]
add [eax], edx
614,7 → 614,7
dec ecx
jnz .reloc_loop
.next:
add esi, COFF_SECTION_SIZE
add esi, sizeof.COFF_SECTION
dec [n_sec]
jnz .fix_sec
.exit:
629,23 → 629,23
endl
 
mov eax, [coff]
movzx ebx, [eax+CFH.nSections]
movzx ebx, [eax+COFF_HEADER.nSections]
mov [n_sec], ebx
lea esi, [eax+20]
mov edx, [delta]
.fix_sec:
mov edi, [esi+CFS.PtrReloc]
mov edi, [esi+COFF_SECTION.PtrReloc]
add edi, [coff]
 
movzx ecx, [esi+CFS.NumReloc]
movzx ecx, [esi+COFF_SECTION.NumReloc]
test ecx, ecx
jz .next
.reloc_loop:
cmp [edi+CRELOC.Type], 6
cmp [edi+COFF_RELOC.Type], 6
jne .next_reloc
.dir_32:
mov eax, [edi+CRELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress]
mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+COFF_SECTION.VirtualAddress]
add [eax+edx], edx
.next_reloc:
add edi, 10
652,7 → 652,7
dec ecx
jnz .reloc_loop
.next:
add esi, COFF_SECTION_SIZE
add esi, sizeof.COFF_SECTION
dec [n_sec]
jnz .fix_sec
.exit:
700,15 → 700,15
 
mov [coff], eax
 
movzx ecx, [eax+CFH.nSections]
movzx ecx, [eax+COFF_HEADER.nSections]
xor ebx, ebx
 
lea edx, [eax+20]
@@:
add ebx, [edx+CFS.SizeOfRawData]
add ebx, [edx+COFF_SECTION.SizeOfRawData]
add ebx, 15
and ebx, not 15
add edx, COFF_SECTION_SIZE
add edx, sizeof.COFF_SECTION
dec ecx
jnz @B
mov [img_size], ebx
728,32 → 728,32
rep stosd
 
mov edx, [coff]
movzx ebx, [edx+CFH.nSections]
movzx ebx, [edx+COFF_HEADER.nSections]
mov edi, [img_base]
lea eax, [edx+20]
@@:
mov [eax+CFS.VirtualAddress], edi
mov esi, [eax+CFS.PtrRawData]
mov [eax+COFF_SECTION.VirtualAddress], edi
mov esi, [eax+COFF_SECTION.PtrRawData]
test esi, esi
jnz .copy
add edi, [eax+CFS.SizeOfRawData]
add edi, [eax+COFF_SECTION.SizeOfRawData]
jmp .next
.copy:
add esi, edx
mov ecx, [eax+CFS.SizeOfRawData]
mov ecx, [eax+COFF_SECTION.SizeOfRawData]
cld
rep movsb
.next:
add edi, 15
and edi, not 15
add eax, COFF_SECTION_SIZE
add eax, sizeof.COFF_SECTION
dec ebx
jnz @B
 
mov ebx, [edx+CFH.pSymTable]
mov ebx, [edx+COFF_HEADER.pSymTable]
add ebx, edx
mov [sym], ebx
mov ecx, [edx+CFH.nSymbols]
mov ecx, [edx+COFF_HEADER.nSymbols]
add ecx,ecx
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE
add ecx, [sym]
764,7 → 764,7
mov dword [ebx+4], 0
lea eax, [edx+20]
 
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\
stdcall fix_coff_symbols, eax, [sym], [edx+COFF_HEADER.nSymbols], \
[strings], ebx
test eax, eax
jz .link_fail
772,7 → 772,7
mov ebx, [coff]
stdcall fix_coff_relocs, ebx, [sym], 0
 
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion
stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szVersion
test eax, eax
jz .link_fail
 
785,7 → 785,7
ja .ver_fail
 
mov ebx, [coff]
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART
stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szSTART
mov [start], eax
 
stdcall kernel_free, [coff]
851,7 → 851,7
; - if alignment is given and is no more than 4K, use it;
; - if alignment is more than 4K, revert to 4K.
push ecx
mov cl, byte [edx+CFS.Characteristics+2]
mov cl, byte [edx+COFF_SECTION.Characteristics+2]
mov eax, 1
shr cl, 4
dec cl
955,7 → 955,7
xor eax, eax
repnz scasb
not ecx
lea eax, [ecx+DLLDESCR.sizeof]
lea eax, [ecx+sizeof.DLLDESCR]
push ecx
call malloc
pop ecx
979,7 → 979,7
 
; calculate size of loaded DLL
mov edx, [coff]
movzx ecx, [edx+CFH.nSections]
movzx ecx, [edx+COFF_HEADER.nSections]
xor ebx, ebx
 
add edx, 20
988,8 → 988,8
add ebx, eax
not eax
and ebx, eax
add ebx, [edx+CFS.SizeOfRawData]
add edx, COFF_SECTION_SIZE
add ebx, [edx+COFF_SECTION.SizeOfRawData]
add edx, sizeof.COFF_SECTION
dec ecx
jnz @B
; it must be nonzero and not too big
1019,7 → 1019,7
; copy sections and set correct values for VirtualAddress'es in headers
push esi
mov edx, [coff]
movzx ebx, [edx+CFH.nSections]
movzx ebx, [edx+COFF_HEADER.nSections]
mov edi, eax
add edx, 20
cld
1030,11 → 1030,11
not eax
and ecx, eax
and edi, eax
mov [edx+CFS.VirtualAddress], ecx
add ecx, [edx+CFS.SizeOfRawData]
mov esi, [edx+CFS.PtrRawData]
mov [edx+COFF_SECTION.VirtualAddress], ecx
add ecx, [edx+COFF_SECTION.SizeOfRawData]
mov esi, [edx+COFF_SECTION.PtrRawData]
push ecx
mov ecx, [edx+CFS.SizeOfRawData]
mov ecx, [edx+COFF_SECTION.SizeOfRawData]
test esi, esi
jnz .copy
xor eax, eax
1045,7 → 1045,7
rep movsb
.next:
pop ecx
add edx, COFF_SECTION_SIZE
add edx, sizeof.COFF_SECTION
dec ebx
jnz @B
pop esi
1054,21 → 1054,21
; later we will use COFF header, headers for sections and symbol table
; and also relocations table for all sections
mov edx, [coff]
mov ebx, [edx+CFH.pSymTable]
mov ebx, [edx+COFF_HEADER.pSymTable]
mov edi, dword [fileinfo+32]
sub edi, ebx
jc .fail_and_free_data
mov [esi+DLLDESCR.symbols_lim], edi
add ebx, edx
movzx ecx, [edx+CFH.nSections]
movzx ecx, [edx+COFF_HEADER.nSections]
lea ecx, [ecx*5]
lea edi, [edi+ecx*8+20]
add edx, 20
@@:
movzx eax, [edx+CFS.NumReloc]
movzx eax, [edx+COFF_SECTION.NumReloc]
lea eax, [eax*5]
lea edi, [edi+eax*2]
add edx, COFF_SECTION_SIZE
add edx, sizeof.COFF_SECTION
sub ecx, 5
jnz @b
stdcall kernel_alloc, edi
1075,7 → 1075,7
test eax, eax
jz .fail_and_free_data
mov edx, [coff]
movzx ecx, [edx+CFH.nSections]
movzx ecx, [edx+COFF_HEADER.nSections]
lea ecx, [ecx*5]
lea ecx, [ecx*2+5]
mov [esi+DLLDESCR.coff_hdr], eax
1086,7 → 1086,7
pop esi
mov [esi+DLLDESCR.symbols_ptr], edi
push esi
mov ecx, [edx+CFH.nSymbols]
mov ecx, [edx+COFF_HEADER.nSymbols]
mov [esi+DLLDESCR.symbols_num], ecx
mov ecx, [esi+DLLDESCR.symbols_lim]
mov esi, ebx
1094,20 → 1094,20
pop esi
mov ebx, [esi+DLLDESCR.coff_hdr]
push esi
movzx eax, [edx+CFH.nSections]
movzx eax, [edx+COFF_HEADER.nSections]
lea edx, [ebx+20]
@@:
movzx ecx, [edx+CFS.NumReloc]
movzx ecx, [edx+COFF_SECTION.NumReloc]
lea ecx, [ecx*5]
mov esi, [edx+CFS.PtrReloc]
mov [edx+CFS.PtrReloc], edi
sub [edx+CFS.PtrReloc], ebx
mov esi, [edx+COFF_SECTION.PtrReloc]
mov [edx+COFF_SECTION.PtrReloc], edi
sub [edx+COFF_SECTION.PtrReloc], ebx
add esi, [coff]
shr ecx, 1
rep movsd
adc ecx, ecx
rep movsw
add edx, COFF_SECTION_SIZE
add edx, sizeof.COFF_SECTION
dec eax
jnz @b
pop esi
1114,7 → 1114,7
 
; fixup symbols
mov edx, ebx
mov eax, [ebx+CFH.nSymbols]
mov eax, [ebx+COFF_HEADER.nSymbols]
add edx, 20
mov ecx, [esi+DLLDESCR.symbols_num]
lea ecx, [ecx*9]
1128,11 → 1128,11
;
;@@:
 
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],szEXPORTS
stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], szEXPORTS
test eax, eax
jnz @F
 
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],sz_EXPORTS
stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], sz_EXPORTS
@@:
mov [esi+DLLDESCR.exports], eax
 
1160,7 → 1160,7
jz .fail_and_dereference
@@:
mov [img_base], eax
mov eax, HDLL.sizeof
mov eax, sizeof.HDLL
call malloc
test eax, eax
jz .fail_and_free_user
1369,11 → 1369,11
push ebp
mov edx, [srv.fd]
.next:
cmp edx, srv.fd-SRV_FD_OFFSET
cmp edx, srv.fd-SRV.fd
je .done
cmp [edx+SRV.magic], ' SRV'
jne .next
cmp [edx+SRV.size], SRV.sizeof
cmp [edx+SRV.size], sizeof.SRV
jne .next
 
mov ebx, [edx+SRV.entry]
/kernel/branches/Kolibri-acpi/core/export.inc
28,7 → 28,8
local name
dd (name-OS_BASE)
common
ordinal: count = 0
ordinal:
count = 0
forward
dw count
count = count+1
/kernel/branches/Kolibri-acpi/core/ext_lib.inc
158,7 → 158,8
 
proc dll.Load, import_table:dword
mov esi,[import_table]
.next_lib: mov edx,[esi]
.next_lib:
mov edx, [esi]
or edx,edx
jz .exit
push esi
168,7 → 169,8
mov al, '/'
stosb
mov esi,sysdir_path
@@: lodsb
@@:
lodsb
stosb
or al,al
jnz @b
179,7 → 181,8
pop esi
push esi
mov esi,[esi+4]
@@: lodsb
@@:
lodsb
stosb
or al,al
jnz @b
195,9 → 198,11
pop esi
add esi,8
jmp .next_lib
.exit: xor eax,eax
.exit:
xor eax, eax
ret
.fail: add esp,4
.fail:
add esp, 4
xor eax,eax
inc eax
ret
208,7 → 213,8
mov esi,[imp]
test esi,esi
jz .done
.next: lodsd
.next:
lodsd
test eax,eax
jz .done
stdcall dll.GetProcAddress,[exp],eax
216,8 → 222,10
jz @f
mov [esi-4],eax
jmp .next
@@: mov dword[esp],0
.done: pop eax
@@:
mov dword[esp], 0
.done:
pop eax
ret
endp
 
234,7 → 242,8
 
proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx,[exp]
.next: test edx,edx
.next:
test edx, edx
jz .end
stdcall strncmp,[edx],[sz_name], dword -1
test eax,eax
241,8 → 250,10
jz .ok
add edx,8
jmp .next
.ok: mov eax,[edx+4]
.end: ret
.ok:
mov eax, [edx+4]
.end:
ret
endp
 
;-----------------------------------------------------------------------------
276,7 → 287,8
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: mov eax,ebx
@@:
mov eax, ebx
call mem.Alloc
xchg eax,[esp]
or eax,eax
288,7 → 300,8
cmp ecx,[edi-4]
jbe @f
mov ecx,[edi-4]
@@: add ecx,3
@@:
add ecx, 3
shr ecx,2
cld
rep movsd
/kernel/branches/Kolibri-acpi/core/heap.inc
8,27 → 8,21
$Revision$
 
 
struc MEM_BLOCK
{
.list LHEAD
.next_block dd ? ;+8
.prev_block dd ? ;+4
.base dd ? ;+16
.size dd ? ;+20
.flags dd ? ;+24
.handle dd ? ;+28
.sizeof:
}
struct MEM_BLOCK
list LHEAD
next_block dd ? ;+8
prev_block dd ? ;+4
base dd ? ;+16
size dd ? ;+20
flags dd ? ;+24
handle dd ? ;+28
ends
 
FREE_BLOCK equ 4
USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h
 
virtual at 0
MEM_BLOCK MEM_BLOCK
end virtual
 
 
block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list.next
146,8 → 140,8
jnz .l1
 
mov edi, HEAP_BASE ;descriptors
mov ebx, HEAP_BASE+MEM_BLOCK.sizeof ;free space
mov ecx, HEAP_BASE+MEM_BLOCK.sizeof*2 ;terminator
mov ebx, HEAP_BASE+sizeof.MEM_BLOCK ;free space
mov ecx, HEAP_BASE+sizeof.MEM_BLOCK*2 ;terminator
 
xor eax, eax
mov [edi+block_next], ebx
155,7 → 149,7
mov [edi+list_fd], eax
mov [edi+list_bk], eax
mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*MEM_BLOCK.sizeof
mov [edi+block_size], 4096*sizeof.MEM_BLOCK
mov [edi+block_flags], USED_BLOCK
 
mov [ecx+block_next], eax
168,11 → 162,11
 
mov [ebx+block_next], ecx
mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK.sizeof
mov [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK
 
mov ecx, [pg_data.kernel_pages]
shl ecx, 12
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof
sub ecx, HEAP_BASE-OS_BASE+4096*sizeof.MEM_BLOCK
mov [heap_size], ecx
mov [heap_free], ecx
mov [ebx+block_size], ecx
185,15 → 179,15
list_add ebx, ecx
 
mov ecx, 4096-3-1
mov eax, HEAP_BASE+MEM_BLOCK.sizeof*4
mov eax, HEAP_BASE+sizeof.MEM_BLOCK*4
 
mov [next_memblock], HEAP_BASE+MEM_BLOCK.sizeof*3
mov [next_memblock], HEAP_BASE+sizeof.MEM_BLOCK *3
@@:
mov [eax-MEM_BLOCK.sizeof], eax
add eax, MEM_BLOCK.sizeof
mov [eax-sizeof.MEM_BLOCK], eax
add eax, sizeof.MEM_BLOCK
loop @B
 
mov [eax-MEM_BLOCK.sizeof], dword 0
mov [eax-sizeof.MEM_BLOCK], dword 0
 
mov ecx, heap_mutex
call mutex_init
584,7 → 578,7
 
;;;;;;;;;;;;;; USER ;;;;;;;;;;;;;;;;;
 
HEAP_TOP equ 0x5FC00000
HEAP_TOP equ 0x80000000
 
align 4
proc init_heap
854,6 → 848,71
ret
endp
 
 
align 4
proc user_unmap stdcall, base:dword, offset:dword, size:dword
 
push ebx
 
mov ebx, [base] ; must be valid pointer
test ebx, ebx
jz .error
 
mov edx, [offset] ; check offset
add edx, ebx ; must be below 2Gb app limit
js .error
 
shr ebx, 12 ; chek block attributes
lea ebx, [page_tabs+ebx*4]
mov eax, [ebx-4] ; block attributes
test al, USED_BLOCK
jz .error
test al, DONT_FREE_BLOCK
jnz .error
 
shr edx, 12
lea edx, [page_tabs+edx*4] ; unmap offset
 
mov ecx, [size]
add ecx, 4095
shr ecx, 12 ; unmap size in pages
 
shr eax, 12 ; block size + 1 page
lea ebx, [ebx+eax*4-4] ; block end ptr
lea eax, [edx+ecx*4] ; unmap end ptr
 
cmp eax, ebx ; check for overflow
ja .error
 
mov ebx, [offset]
and ebx, not 4095 ; is it required ?
 
.unmap:
mov eax, [edx] ; get page addres
test al, 1 ; page mapped ?
jz @F
test eax, PG_SHARED ; page shared ?
jnz @F
mov [page_tabs+edx*4], dword 2
; mark page as reserved
invlpg [ebx] ; when we start using
call free_page ; empty c-o-w page instead this ?
@@:
add ebx, 4096
add edx, 4
dec ecx
jnz .unmap
 
pop ebx
or al, 1 ; return non zero on success
ret
.error:
pop ebx
xor eax, eax ; something wrong
ret
endp
 
align 4
user_normalize:
; in: esi=heap_base, edi=heap_top
; out: eax=0 <=> OK
1292,7 → 1351,7
and ecx, -4096
mov [size], ecx
 
mov eax, SMEM.sizeof
mov eax, sizeof.SMEM
call malloc
test eax, eax
mov esi, eax
1354,7 → 1413,7
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4]
mov eax, SMAP.sizeof
mov eax, sizeof.SMAP
 
call create_kernel_object
test eax, eax
/kernel/branches/Kolibri-acpi/core/irq.inc
12,9 → 12,9
uglobal
 
align 16
irqh_tab rd LHEAD.sizeof * IRQ_RESERVED / 4
irqh_tab rd sizeof.LHEAD * IRQ_RESERVED / 4
 
irqh_pool rd IRQH.sizeof * IRQ_POOL_SIZE /4
irqh_pool rd sizeof.IRQH * IRQ_POOL_SIZE /4
next_irqh rd 1
 
irq_active_set rd 1
34,14 → 34,14
loop @B
 
mov ecx, IRQ_POOL_SIZE-1
mov eax, irqh_pool+IRQH.sizeof
mov eax, irqh_pool+sizeof.IRQH
mov [next_irqh], irqh_pool
@@:
mov [eax-IRQH.sizeof], eax
add eax, IRQH.sizeof
mov [eax-sizeof.IRQH], eax
add eax, sizeof.IRQH
loop @B
 
mov [eax-IRQH.sizeof], dword 0
mov [eax-sizeof.IRQH], dword 0
ret
 
 
/kernel/branches/Kolibri-acpi/core/memory.inc
166,6 → 166,7
ret
endp
 
align 4
proc map_io_mem stdcall, base:dword, size:dword, flags:dword
 
push ebx
358,7 → 359,9
cmp dword [LFBAddress], -1
jne @f
mov [BOOT_VAR+0x901c],byte 2
stdcall alloc_pages, (0x280000 / 4096)
; max VGA=640*480*4=1228800 bytes
; + 32*640*4=81920 bytes for mouse pointer
stdcall alloc_pages, ((1228800+81920)/4096)
 
push eax
call alloc_page
366,7 → 369,9
pop eax
or eax, PG_UW
mov ebx, LFB_BASE
mov ecx, 0x280000 / 4096
; max VGA=640*480*4=1228800 bytes
; + 32*640*4=81920 bytes for mouse pointer
mov ecx, (1228800+81920)/4096
call commit_pages
mov [LFBAddress], dword LFB_BASE
ret
470,7 → 475,8
pop eax
call free_page
 
.next: add edi, 1
.next:
add edi, 1
cmp edi, esi
jb @B
 
797,7 → 803,8
; and eax, 0xFFFFF000
; stdcall map_page, edi, eax
 
@@: mov edi, [lin_addr]
@@:
mov edi, [lin_addr]
and edi, 0xFFFFF000
mov ecx, [buf_size]
add ecx, 4095
857,7 → 864,8
jz .exit
stdcall map_page,edi,eax,PG_UW
 
@@: mov edi, [lin_addr]
@@:
mov edi, [lin_addr]
and edi, 0xFFFFF000
mov ecx, [buf_size]
add ecx, 4095
988,7 → 996,8
add edx, 4095
and edx, not 4095
 
.touch: mov eax, [ecx]
.touch:
mov eax, [ecx]
add ecx, 0x1000
cmp ecx, edx
jb .touch
1299,6 → 1308,11
@@:
ret
 
.26:
stdcall user_unmap, ecx, edx, esi
mov [esp+32], eax
ret
 
.fail:
xor eax, eax
mov [esp+32], eax
1321,8 → 1335,9
dd f68.21 ; load_driver
dd f68.22 ; shmem_open
dd f68.23 ; shmem_close
dd f68.24
dd f68.25
dd f68.24 ; set exception handler
dd f68.25 ; unmask exception
dd f68.26 ; user_unmap
 
 
align 4
/kernel/branches/Kolibri-acpi/core/peload.inc
285,6 → 285,7
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
\
create_event, 'CreateEvent', \ ; ecx, esi
destroy_event, 'DestroyEvent', \ ;
raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi
wait_event, 'WaitEvent', \ ; eax, ebx
get_event_ex, 'GetEvent', \ ; edi
293,6 → 294,7
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
free_page, 'FreePage', \ ; eax
kernel_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \
306,6 → 308,7
\
get_display, 'GetDisplay', \
set_screen, 'SetScreen', \
window._.get_rect, 'GetWindowRect', \ ; gcc fastcall
pci_api_drv, 'PciApi', \
pci_read8, 'PciRead8', \ ; stdcall
pci_read16, 'PciRead16', \ ; stdcall
326,7 → 329,8
get_stack_base, 'GetStackBase', \
delay_hs, 'Delay', \ ; ebx
set_mouse_data, 'SetMouseData', \ ;
set_keyboard_data, 'SetKeyboardData' ; gcc fastcall
set_keyboard_data, 'SetKeyboardData', \ ; gcc fastcall
timer_hs, 'TimerHs' ; stdcall
 
 
 
/kernel/branches/Kolibri-acpi/core/sched.inc
60,7 → 60,8
end if
call find_next_task
jz .return ; the same task -> skip switch
@@: mov byte[DONT_SWITCH], 1
@@:
mov byte[DONT_SWITCH], 1
call do_change_task
.return:
popad
121,7 → 122,8
jb @f
xor bh, bh
mov edi,CURRENT_TASK
@@: inc bh ; ebx += APPDATA.size
@@:
inc bh ; ebx += APPDATA.size
add edi,0x20 ; edi += TASKDATA.size
mov al, [edi+TASKDATA.state]
test al, al
140,7 → 142,8
sub ecx, [ebx+APPDATA.wait_begin]
cmp ecx, [ebx+APPDATA.wait_timeout]
jb .loop
@@: mov [ebx+APPDATA.wait_param], eax ; retval for wait
@@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], 0
.found:
mov [CURRENT_TASK],bh
214,28 → 217,23
mov reg,eax
} lodsReg dr0, dr1, dr2, dr3, dr7
purge lodsReg
@@: ret
@@:
ret
;end.
 
 
 
struc MUTEX_WAITER
{
.list LHEAD
.task rd 1
.sizeof:
};
struct MUTEX_WAITER
list LHEAD
task dd ?
ends
 
virtual at 0
MUTEX_WAITER MUTEX_WAITER
end virtual
 
;void __fastcall mutex_init(struct mutex *lock)
 
align 4
mutex_init:
mov [ecx+MUTEX.wait.next], ecx
mov [ecx+MUTEX.wait.prev], ecx
mov [ecx+MUTEX.lhead.next], ecx
mov [ecx+MUTEX.lhead.prev], ecx
mov [ecx+MUTEX.count],1
ret
 
251,7 → 249,7
pushfd
cli
 
sub esp, MUTEX_WAITER.sizeof
sub esp, sizeof.MUTEX_WAITER
 
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
 
274,12 → 272,12
 
mov [eax+MUTEX_WAITER.list.next], edx
mov [edx+MUTEX_WAITER.list.prev], eax
cmp [ecx+MUTEX.wait.next], ecx
cmp [ecx+MUTEX.lhead.next], ecx
jne @F
 
mov [ecx+MUTEX.count], 0
@@:
add esp, MUTEX_WAITER.sizeof
add esp, sizeof.MUTEX_WAITER
 
popfd
.done:
293,7 → 291,7
pushfd
cli
 
mov eax, [ecx+MUTEX.wait.next]
mov eax, [ecx+MUTEX.lhead.next]
cmp eax, ecx
mov [ecx+MUTEX.count], 1
je @F
/kernel/branches/Kolibri-acpi/core/sys32.inc
20,7 → 20,8
mov esi, sys_int
mov ecx, 0x40
mov eax, (10001110b shl 24) + os_code
@@: movsw ;low word of code-entry
@@:
movsw ;low word of code-entry
stosd ;interrupt gate type : os_code selector
movsw ;high word of code-entry
loop @b
138,13 → 139,15
cmp bl,14 ; #PF
jne @f
call page_fault_handler ; SEE: core/memory.inc
@@: mov esi, [current_slot]
@@:
mov esi, [current_slot]
btr [esi+APPDATA.except_mask], ebx
jnc @f
mov eax,[esi+APPDATA.exc_handler]
test eax, eax
jnz IRetToUserHook
@@: cli
@@:
cli
mov eax, [esi+APPDATA.debugger_slot]
test eax, eax
jnz .debug
165,10 → 168,12
mov dr6, edx
mov edx, dr7
mov cl, not 8
.l1: shl dl,2
.l1:
shl dl, 2
jc @f
and bl, cl
@@: sar cl,1
@@:
sar cl, 1
jc .l1
mov cl, 3 ; debug_message code=debug_exception
.notify:
213,8 → 218,10
jb .l0
cmp bl, 0x0e
jbe .l1
.l0: mov bl, 0x09
.l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4]
.l0:
mov bl, 0x09
.l1:
mov eax, [msg_fault_sel+ebx*4 - 0x08*4]
DEBUGF 1, "K : %s\n", eax
mov eax, [reg_cs3+4]
mov edi, msg_sel_app
223,7 → 230,8
je @f
mov edi, msg_sel_ker
mov ebx, [reg_esp0+4]
@@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4]
@@:
DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4]
DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4]
DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx
DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi
/kernel/branches/Kolibri-acpi/core/syscall.inc
194,6 → 194,9
dd syscall_window_settings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message
dd blit_32 ; 73-blitter;
dd undefined_syscall ; 74-reserved for new stack
dd undefined_syscall ; 75-reserved for new stack
dd undefined_syscall ; 76-reserved for new stack
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
dd sys_end ; -1-end application
 
/kernel/branches/Kolibri-acpi/core/taskman.inc
10,34 → 10,34
 
GREEDY_KERNEL equ 0
 
struc APP_HEADER_00
{ .banner dq ?
.version dd ? ;+8
.start dd ? ;+12
.i_end dd ? ;+16
.mem_size dd ? ;+20
.i_param dd ? ;+24
}
struct APP_HEADER_00_
banner dq ?
version dd ? ;+8
start dd ? ;+12
i_end dd ? ;+16
mem_size dd ? ;+20
i_param dd ? ;+24
ends
 
struc APP_HEADER_01
{ .banner dq ?
.version dd ? ;+8
.start dd ? ;+12
.i_end dd ? ;+16
.mem_size dd ? ;+20
.stack_top dd ? ;+24
.i_param dd ? ;+28
.i_icon dd ? ;+32
}
struct APP_HEADER_01_
banner dq ?
version dd ? ;+8
start dd ? ;+12
i_end dd ? ;+16
mem_size dd ? ;+20
stack_top dd ? ;+24
i_param dd ? ;+28
i_icon dd ? ;+32
ends
 
 
struc APP_PARAMS
{ .app_cmdline ;0x00
.app_path ;0x04
.app_eip ;0x08
.app_esp ;0x0C
.app_mem ;0x10
}
struct APP_PARAMS
app_cmdline dd ? ;0x00
app_path dd ? ;0x04
app_eip dd ? ;0x08
app_esp dd ? ;0x0C
app_mem dd ? ;0x10
ends
 
macro _clear_ op
{ mov ecx, op/4
254,10 → 254,10
align 4
test_app_header:
virtual at eax
APP_HEADER_00 APP_HEADER_00
APP_HEADER_00 APP_HEADER_00_
end virtual
virtual at eax
APP_HEADER_01 APP_HEADER_01
APP_HEADER_01 APP_HEADER_01_
end virtual
 
cmp dword [eax], 'MENU'
/kernel/branches/Kolibri-acpi/core/timers.inc
5,7 → 5,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
$Revision: 2122 $
$Revision: 2381 $
 
; Simple implementation of timers. All timers are organized in a double-linked
; list, and the OS loop after every timer tick processes the list.
12,16 → 12,16
 
; This structure describes a timer for the kernel.
struct TIMER
.Next dd ?
.Prev dd ?
Next dd ?
Prev dd ?
; These fields organize a double-linked list of all timers.
.TimerFunc dd ?
TimerFunc dd ?
; Function to be called when the timer is activated.
.UserData dd ?
UserData dd ?
; The value that is passed as is to .TimerFunc.
.Time dd ?
Time dd ?
; Time at which the timer should be activated.
.Interval dd ?
Interval dd ?
; Interval between activations of the timer, in 0.01s.
ends
 
/kernel/branches/Kolibri-acpi/core/v86.inc
12,21 → 12,16
 
DEBUG_SHOW_IO = 0
 
struc V86_machine
{
struct V86_machine
; page directory
.pagedir dd ?
pagedir dd ?
; translation table: V86 address -> flat linear address
.pages dd ?
pages dd ?
; mutex to protect all data from writing by multiple threads at one time
.mutex dd ?
mutex dd ?
; i/o permission map
.iopm dd ?
.size = $
}
virtual at 0
V86_machine V86_machine
end virtual
iopm dd ?
ends
 
; Create V86 machine
; in: nothing
35,7 → 30,7
; destroys: ebx, ecx, edx (due to malloc)
v86_create:
; allocate V86_machine structure
mov eax, V86_machine.size
mov eax, sizeof.V86_machine
call malloc
test eax, eax
jz .fail
245,31 → 240,26
.ret:
ret
 
struc v86_regs
{
struct v86_regs
; don't change the order, it is important
.edi dd ?
.esi dd ?
.ebp dd ?
edi dd ?
esi dd ?
ebp dd ?
dd ? ; ignored
.ebx dd ?
.edx dd ?
.ecx dd ?
.eax dd ?
.eip dd ?
.cs dd ?
.eflags dd ? ; VM flag must be set!
.esp dd ?
.ss dd ?
.es dd ?
.ds dd ?
.fs dd ?
.gs dd ?
.size = $
}
virtual at 0
v86_regs v86_regs
end virtual
ebx dd ?
edx dd ?
ecx dd ?
eax dd ?
eip dd ?
cs dd ?
eflags dd ? ; VM flag must be set!
esp dd ?
ss dd ?
es dd ?
ds dd ?
fs dd ?
gs dd ?
ends
 
; Run V86 machine
; in: ebx -> registers for V86 (two structures: in and out)
319,10 → 309,10
; sti
 
mov eax, esi
sub esp, v86_regs.size
sub esp, sizeof.v86_regs
mov esi, ebx
mov edi, esp
mov ecx, v86_regs.size/4
mov ecx, sizeof.v86_regs/4
rep movsd
 
cmp edx, -1
371,7 → 361,8
jne @f
xor eax, eax
mov dr6, eax
@@: mov eax, [esp+v86_regs.size+10h+18h]
@@:
mov eax, [esp+sizeof.v86_regs+10h+18h]
cmp word [esp+v86_regs.eip], ax
jnz @f
shr eax, 16
443,7 → 434,7
sub eax, 6
add edx, eax
mov eax, edx
mov esi, [esp+4+v86_regs.size+10h+4]
mov esi, [esp+4+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
491,7 → 482,7
movzx eax, word [esp+v86_regs.esp]
add edx, eax
mov eax, edx
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
527,7 → 518,7
movzx eax, ax
add edx, eax
mov eax, edx
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
559,7 → 550,7
sub eax, 4
add edx, eax
mov eax, edx
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
590,7 → 581,7
movzx eax, word [esp+v86_regs.esp]
add edx, eax
mov eax, edx
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
621,7 → 612,7
movzx eax, word [esp+v86_regs.esp]
add edx, eax
mov eax, edx
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr
cmp eax, 0x1000
jae @f
747,7 → 738,7
shl edx, 4
add edx, [esp+32]
@@:
mov esi, [esp+v86_regs.size+10h+4]
mov esi, [esp+sizeof.v86_regs+10h+4]
mov eax, edx
call v86_get_lin_addr
cmp eax, 0x1000
772,10 → 763,10
xor eax, eax
 
.exit:
mov [esp+v86_regs.size+10h+1Ch], eax
mov [esp+v86_regs.size+10h+18h], ebx
mov [esp+sizeof.v86_regs+10h+1Ch], eax
mov [esp+sizeof.v86_regs+10h+18h], ebx
 
mov edx, [esp+v86_regs.size+10h+14h]
mov edx, [esp+sizeof.v86_regs+10h+14h]
cmp edx, -1
jz @f
dec [v86_irqhooks+edx*8+4]
784,9 → 775,9
@@:
 
mov esi, esp
mov edi, [esi+v86_regs.size+10h+10h]
add edi, v86_regs.size
mov ecx, v86_regs.size/4
mov edi, [esi+sizeof.v86_regs+10h+10h]
add edi, sizeof.v86_regs
mov ecx, sizeof.v86_regs/4
rep movsd
mov esp, esi
 
873,12 → 864,12
jnz .cont
push ecx
mov ecx, [ebx+APPDATA.saved_esp0]
cmp word [ecx-v86_regs.size+v86_regs.esp], 6
cmp word [ecx-sizeof.v86_regs+v86_regs.esp], 6
jb .cont2
movzx edx, word [ecx-v86_regs.size+v86_regs.ss]
movzx edx, word [ecx-sizeof.v86_regs+v86_regs.ss]
shl edx, 4
push eax
movzx eax, word [ecx-v86_regs.size+v86_regs.esp]
movzx eax, word [ecx-sizeof.v86_regs+v86_regs.esp]
sub eax, 6
add edx, eax
mov eax, edx
904,12 → 895,12
iretd
.found:
mov cr3, eax
sub word [esi-v86_regs.size+v86_regs.esp], 6
mov ecx, [esi-v86_regs.size+v86_regs.eip]
sub word [esi-sizeof.v86_regs+v86_regs.esp], 6
mov ecx, [esi-sizeof.v86_regs+v86_regs.eip]
mov word [edx], cx
mov ecx, [esi-v86_regs.size+v86_regs.cs]
mov ecx, [esi-sizeof.v86_regs+v86_regs.cs]
mov word [edx+2], cx
mov ecx, [esi-v86_regs.size+v86_regs.eflags]
mov ecx, [esi-sizeof.v86_regs+v86_regs.eflags]
mov word [edx+4], cx
lea eax, [edi+8]
cmp al, 10h
917,10 → 908,10
add al, 60h
@@:
mov cx, [eax*4]
mov word [esi-v86_regs.size+v86_regs.eip], cx
mov word [esi-sizeof.v86_regs+v86_regs.eip], cx
mov cx, [eax*4+2]
mov word [esi-v86_regs.size+v86_regs.cs], cx
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
mov word [esi-sizeof.v86_regs+v86_regs.cs], cx
and byte [esi-sizeof.v86_regs+v86_regs.eflags+1], not 3
call update_counters
lea edi, [ebx + 0x100000000 - SLOT_BASE]
shr edi, 3