From c752107a02e1cba08f4f1c5428553c6f643b4d67 Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Sat, 25 Jul 2009 13:12:11 +0000 Subject: [PATCH] fixed kernel heap manager broken in rev. 1090 git-svn-id: svn://kolibrios.org@1130 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/heap.inc | 8 +++----- kernel/trunk/init.inc | 11 ++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 8319e1726c..19089d8150 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -91,7 +91,7 @@ macro remove_from_used op align 4 proc init_kernel_heap - mov ecx, 64/4 + mov ecx, 64 mov edi, mem_block_list xor eax, eax cld @@ -140,9 +140,7 @@ proc init_kernel_heap mov ecx, [pg_data.kernel_pages] shl ecx, 12 - neg ecx - add ecx, [MEM_AMOUNT] - sub ecx, 4096*MEM_BLOCK_SIZE + sub ecx, HEAP_BASE+4096*MEM_BLOCK_SIZE mov [heap_size], ecx mov [heap_free], ecx mov [ebx+block_size], ecx @@ -155,7 +153,7 @@ proc init_kernel_heap mov byte [mem_block_map], 0xFC and [heap_mutex], 0 mov [heap_blocks], 4095 - mov [free_blocks], 4095 + mov [free_blocks], 4094 ret endp diff --git a/kernel/trunk/init.inc b/kernel/trunk/init.inc index 0056e53405..94f64fde5c 100644 --- a/kernel/trunk/init.inc +++ b/kernel/trunk/init.inc @@ -107,7 +107,16 @@ proc init_mem and edx, not 4095 mov [tmp_page_tabs], edx - mov edx, (((sys_pgmap-OS_BASE) + 0xFFFFFF) and not 0xFFFFFF) shr 12 + mov edx, esi + cmp edx, (OS_BASE/4096) + jbe @F + mov edx, (OS_BASE/4096) + jmp .set +@@: + cmp edx, (HEAP_BASE+HEAP_MIN_SIZE)/4096 + jae .set + mov edx, (HEAP_BASE+HEAP_MIN_SIZE)/4096 +.set: mov [pg_data.kernel_pages-OS_BASE], edx shr edx, 10 mov [pg_data.kernel_tables-OS_BASE], edx