Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2128 → Rev 2129

/kernel/trunk/core/heap.inc
151,7 → 151,8
 
mov [mem_block_list+63*4], ebx
mov byte [mem_block_map], 0xFC
and [heap_mutex], 0
mov ecx, heap_mutex
call mutex_init
mov [heap_blocks], 4095
mov [free_blocks], 4094
ret
272,14 → 273,14
push esi
push edi
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [size]
add eax, 4095
and eax, not 4095
mov [size], eax
 
mov ebx, heap_mutex
call wait_mutex ;ebx
 
cmp eax, [heap_free]
ja .error
 
355,10 → 356,11
mov [edx+list_bk], esi
 
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
mov ecx, heap_mutex
call mutex_unlock
mov eax, [esi+block_base]
pop edi
pop esi
pop ebx
378,17 → 380,19
mov [edx+list_bk], edi
 
mov [edi+block_flags], USED_BLOCK
mov eax, [edi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
mov ecx, heap_mutex
call mutex_unlock
mov eax, [edi+block_base]
pop edi
pop esi
pop ebx
ret
.error:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
400,9 → 404,10
push ebx
push esi
push edi
mov ebx, heap_mutex
call wait_mutex ;ebx
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [base]
mov esi, [mem_used.fd]
@@:
491,9 → 496,10
@@:
bts [mem_block_mask], eax
.m_eq:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
dec eax
not eax
pop edi
pop esi
pop ebx
513,16 → 519,18
@@:
bts [mem_block_mask], eax
mov [esi+block_flags],FREE_BLOCK
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
dec eax
not eax
pop edi
pop esi
pop ebx
ret
.fail:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
607,8 → 615,8
proc kernel_free stdcall, base:dword
push ebx esi
 
mov ebx, heap_mutex
call wait_mutex ;ebx
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [base]
mov esi, [mem_used.fd]
624,19 → 632,17
cmp [esi+block_flags], USED_BLOCK
jne .fail
 
and [heap_mutex], 0
call mutex_unlock
 
push ecx
mov ecx, [esi+block_size];
shr ecx, 12
call release_pages ;eax, ecx
pop ecx
stdcall free_kernel_space, [base]
pop esi ebx
ret
.fail:
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop esi ebx
ret
endp
/kernel/trunk/core/irq.inc
72,8 → 72,6
.irqh dd ?
endl
 
xchg bx, bx
 
and [.irqh], 0
 
push ebx
100,9 → 98,10
 
mov eax, [ecx]
mov [next_irqh], eax
 
mov [.irqh], ecx
 
mov [irq_failed+ebx*4], 0 ;clear counter
 
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
109,9 → 108,8
 
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
stdcall enable_irq, ebx
 
stdcall enable_irq, [irq]
 
.fail:
popfd
.err:
/kernel/trunk/core/malloc.inc
20,7 → 20,7
; esi= nb
; ebx= idx
;
align 16
align 4
malloc:
push esi
 
31,8 → 31,8
and esi, -8
add esi, 8
 
mov ebx, mst.mutex
call wait_mutex ;ebx
mov ecx, mst.mutex
call mutex_lock
 
cmp esi, 256
jae .large
92,9 → 92,13
pop edi
pop ebp
.done:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi
mov [mst.mutex], 0
ret
 
.split:
lea ebx, [edx+8] ;ebx=mem
 
133,10 → 137,10
mov [edx+12], eax ; F->bk = r;
mov [eax+8], edx ; r->fd = F;
mov [eax+12], ecx ; r->bk = B;
 
mov eax, ebx
pop esi
mov [mst.mutex], 0
ret
jmp .done
 
.small:
 
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
150,9 → 154,8
call malloc_small
test eax, eax
jz .from_top
pop esi
and [mst.mutex], 0
ret
jmp .done
 
.large:
 
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
189,18 → 192,15
mov [edx+4], eax
mov [ecx+4], esi
lea eax, [ecx+8]
pop esi
and [mst.mutex], 0
ret
jmp .done
 
.fail:
xor eax, eax
pop esi
and [mst.mutex], 0
ret
jmp .done
 
; param
; eax= mem
 
align 4
free:
push edi
mov edi, eax
211,8 → 211,8
test byte [edi+4], 2
je .fail
 
mov ebx, mst.mutex
call wait_mutex ;ebx
mov ecx, mst.mutex
call mutex_lock
 
; psize = p->head & (~3);
 
289,7 → 289,10
mov [mst.top], edi
mov [edi+4], eax
.fail2:
and [mst.mutex], 0
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi
.fail:
pop edi
410,13 → 413,15
mov [esi+8], edx ;P->fd = F
mov [esi+12], eax ;P->bk = B
pop esi
and [mst.mutex], 0
mov ecx, mst.mutex
call mutex_unlock
ret
.large:
mov ebx, eax
call insert_large_chunk
pop esi
and [mst.mutex], 0
mov ecx, mst.mutex
call mutex_unlock
ret
 
 
1025,5 → 1030,8
cmp eax, mst.smallbins+512
jb @B
 
mov ecx, mst.mutex
call mutex_init
 
ret
 
/kernel/trunk/core/memory.inc
214,30 → 214,32
 
align 4
commit_pages:
push edi
test ecx, ecx
jz .fail
 
push edi
push eax
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
pop eax
 
mov edi, ebx
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
shr edi, 12
lea edi, [page_tabs+edi*4]
@@:
stosd
invlpg [ebx]
add eax, 0x1000
add ebx, 0x1000
loop @B
 
mov edx, 0x1000
mov ebx, edi
shr ebx, 12
@@:
mov [page_tabs+ebx*4], eax
; push eax
invlpg [edi]
; pop eax
add edi, edx
add eax, edx
inc ebx
dec ecx
jnz @B
mov [pg_data.pg_mutex],ecx
pop edi
 
mov ecx, pg_data.mutex
call mutex_unlock
.fail:
pop edi
ret
 
 
248,16 → 250,22
align 4
release_pages:
 
pushad
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
push ebp
push esi
push edi
push ebx
 
mov esi, eax
mov edi, eax
 
shr esi, 10
add esi, page_tabs
shr esi, 12
lea esi, [page_tabs+esi*4]
 
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
 
mov ebp, [pg_data.pages_free]
mov ebx, [page_start]
mov edx, sys_pgmap
264,9 → 272,7
@@:
xor eax, eax
xchg eax, [esi]
push eax
invlpg [edi]
pop eax
 
test eax, 1
jz .next
285,11 → 291,16
.next:
add edi, 0x1000
add esi, 4
dec ecx
jnz @B
loop @B
 
mov [pg_data.pages_free], ebp
and [pg_data.pg_mutex],0
popad
mov ecx, pg_data.mutex
call mutex_unlock
 
pop ebx
pop edi
pop esi
pop ebp
ret
 
; param
423,8 → 434,8
align 4
proc new_mem_resize stdcall, new_size:dword
 
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
mov ecx, pg_data.mutex
call mutex_lock
 
mov edi, [new_size]
add edi,4095
464,8 → 475,10
mov ebx, [new_size]
call update_mem_size
 
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
dec [pg_data.pg_mutex]
ret
.expand:
 
539,9 → 552,11
pop edi
pop esi
.exit:
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
inc eax
dec [pg_data.pg_mutex]
ret
endp
 
/kernel/trunk/core/taskman.inc
360,8 → 360,8
app_tabs dd ?
endl
 
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
mov ecx, pg_data.mutex
call mutex_lock
 
xor eax, eax
mov [dir_addr], eax
480,11 → 480,13
.done:
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP
 
dec [pg_data.pg_mutex]
mov ecx, pg_data.mutex
call mutex_unlock
mov eax, [dir_addr]
ret
.fail:
dec [pg_data.pg_mutex]
mov ecx, pg_data.mutex
call mutex_unlock
cmp [dir_addr], 0
je @f
stdcall destroy_app_space, [dir_addr], 0
554,10 → 556,10
jg .ret
;if there isn't threads then clear memory.
mov esi, [dlls_list]
call destroy_all_hdlls
call destroy_all_hdlls ;ecx=APPDATA
 
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
mov ecx, pg_data.mutex
call mutex_lock
 
mov eax, [pg_dir]
and eax, not 0xFFF
583,7 → 585,8
.exit:
stdcall map_page,[tmp_task_ptab],0,PG_UNMAP
stdcall map_page,[tmp_task_pdir],0,PG_UNMAP
dec [pg_data.pg_mutex]
mov ecx, pg_data.mutex
call mutex_unlock
.ret:
ret
endp
956,25 → 959,7
ret
endp
 
; param
; ebx=mutex
 
align 4
wait_mutex:
;;Maxis use atomic bts for mutex 4.4.2009
push eax
push ebx
.do_wait:
bts dword [ebx],0
jnc .locked
call change_task
jmp .do_wait
.locked:
pop ebx
pop eax
ret
 
align 4
tls_app_entry:
 
call init_heap