fixed kernel heap

git-svn-id: svn://kolibrios.org@369 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-22 06:41:46 +00:00
parent cdfbfc7683
commit d7c8e47442

View File

@ -146,20 +146,25 @@ proc init_kernel_heap
ret ret
endp endp
align 4 ; param
proc get_block stdcall, index:dword ; eax= required size
;
; retval
; edi= memory block descriptor
; ebx= descriptor index
mov eax, 63 align 4
mov ecx, [index] get_block:
cmp ecx, eax
jna @f
;cmova ecx, eax
mov ecx, eax mov ecx, eax
@@: shr ecx, 12
xor esi, esi dec ecx
cmp ecx, 63
jle .get_index
mov ecx, 63
.get_index:
lea esi, [mem_block_mask]
xor ebx, ebx xor ebx, ebx
xor edx, edx or edx, -1
not edx
cmp ecx, 32 cmp ecx, 32
jb .bit_test jb .bit_test
@ -167,35 +172,34 @@ proc get_block stdcall, index:dword
sub ecx, 32 sub ecx, 32
add ebx, 32 add ebx, 32
add esi, 4 add esi, 4
.bit_test: .bit_test:
shl edx, cl shl edx, cl
and edx, [mem_block_mask+esi] and edx, [esi]
.find:
bsf edi, edx
jz .high_mask jz .high_mask
bsf eax, edx add ebx, edi
add ebx, eax mov edi, [mem_block_list+ebx*4]
mov eax, [mem_block_list+ebx*4] .check_size:
cmp eax, [edi+block_size]
ja .next
ret ret
.high_mask: .high_mask:
add esi, 4 add esi, 4
cmp esi, mem_block_mask+8
jae .err
add ebx, 32 add ebx, 32
test esi, 0xFFFFFFF8 mov edx, [esi]
jnz .big_error jmp .find
mov edx, [mem_block_mask+esi] .next:
and edx, edx mov edi, [edi+list_fd]
jz .high_mask test edi, edi
bsf eax, edx jnz .check_size
add ebx, eax .err:
mov eax, [mem_block_list+ebx*4] xor edi, edi
ret ret
.big_error:
xor eax, eax
ret
endp
align 4 align 4
proc alloc_mem_block proc alloc_mem_block
@ -266,17 +270,10 @@ proc alloc_kernel_space stdcall, size:dword
cmp eax, [heap_free] cmp eax, [heap_free]
ja .error ja .error
shr eax, 12 call get_block ; eax
sub eax, 1 test edi, edi
mov [block_ind], eax
stdcall get_block, eax
test eax, eax
jz .error jz .error
mov edi, eax ;edi - pBlock
cmp [edi+block_flags], FREE_BLOCK cmp [edi+block_flags], FREE_BLOCK
jne .error jne .error