diff --git a/kernel/branches/Kolibri-acpi/const.inc b/kernel/branches/Kolibri-acpi/const.inc index 05cd449b1e..885bf688e2 100644 --- a/kernel/branches/Kolibri-acpi/const.inc +++ b/kernel/branches/Kolibri-acpi/const.inc @@ -593,20 +593,6 @@ virtual at 0 display_t display_t end virtual -struc HEAP_DATA -{ - .mutex rd 1 - .refcount rd 1 - .heap_base rd 1 - .heap_top rd 1 - .app_mem rd 1 -} - -HEAP_DATA_SIZE equ 20 -virtual at 0 - HEAP_DATA HEAP_DATA -end virtual - struc BOOT_DATA { .bpp dd ? .scanline dd ? diff --git a/kernel/branches/Kolibri-acpi/core/heap.inc b/kernel/branches/Kolibri-acpi/core/heap.inc index f26d1504cd..1f6841398a 100644 --- a/kernel/branches/Kolibri-acpi/core/heap.inc +++ b/kernel/branches/Kolibri-acpi/core/heap.inc @@ -7,33 +7,6 @@ $Revision$ -macro __list_add new, prev, next -{ - mov [next+LHEAD.prev], new - mov [new+LHEAD.next], next - mov [new+LHEAD.prev], prev - mov [prev+LHEAD.next], new -} - -macro list_add new, head -{ - mov eax, [head+LHEAD.next] - __list_add new, head, eax -} - -macro list_add_tail new, head -{ - mov eax, [head+LHEAD.prev] - __list_add new, eax, head -} - -macro list_del entry -{ - mov edx, [entry+list_fd] - mov ecx, [entry+list_bk] - mov [edx+list_bk], ecx - mov [ecx+list_fd], edx -} struc MEM_BLOCK { @@ -85,9 +58,9 @@ macro remove_from_used op ;Initial heap state ; -;+heap_size terminator USED_BLOCK +;+heap_size terminator USED_BLOCK ;+4096*MEM_BLOCK_SIZE free space FREE_BLOCK -;HEAP_BASE heap_descriptors USED_BLOCK +;HEAP_BASE heap_descriptors USED_BLOCK ; align 4 @@ -312,7 +285,7 @@ proc alloc_kernel_space stdcall, size:dword cmp [edi+block_flags], FREE_BLOCK jne .error_unlock - mov [block_ind], ebx ;index of allocated block + mov [block_ind], ebx ;index of allocated block mov eax, [edi+block_size] cmp eax, [size] diff --git a/kernel/branches/Kolibri-acpi/core/sched.inc b/kernel/branches/Kolibri-acpi/core/sched.inc index dc6f5f7eae..c5e6ad6f17 100644 --- a/kernel/branches/Kolibri-acpi/core/sched.inc +++ b/kernel/branches/Kolibri-acpi/core/sched.inc @@ -221,8 +221,7 @@ do_change_task: struc MUTEX_WAITER { - .next rd 1 - .prev rd 1 + .list LHEAD .task rd 1 .sizeof: }; @@ -235,10 +234,9 @@ end virtual align 4 mutex_init: - lea eax, [ecx+MUTEX.next] + mov [ecx+MUTEX.wait.next], ecx + mov [ecx+MUTEX.wait.prev], ecx mov [ecx+MUTEX.count],1 - mov [ecx+MUTEX.next], eax - mov [ecx+MUTEX.prev], eax ret @@ -253,16 +251,9 @@ mutex_lock: pushfd cli - push esi sub esp, MUTEX_WAITER.sizeof - mov eax, [ecx+MUTEX.prev] - lea esi, [ecx+MUTEX.next] - - mov [ecx+MUTEX.prev], esp - mov [esp+MUTEX_WAITER.next], esi - mov [esp+MUTEX_WAITER.prev], eax - mov [eax], esp + list_add_tail esp, ecx ;esp= new waiter, ecx= list head mov edx, [TASK_BASE] mov [esp+MUTEX_WAITER.task], edx @@ -278,19 +269,18 @@ mutex_lock: call change_task jmp .forever @@: - mov edx, [esp+MUTEX_WAITER.next] - mov eax, [esp+MUTEX_WAITER.prev] + mov edx, [esp+MUTEX_WAITER.list.next] + mov eax, [esp+MUTEX_WAITER.list.prev] - mov [eax+MUTEX_WAITER.next], edx - cmp [ecx+MUTEX.next], esi - mov [edx+MUTEX_WAITER.prev], eax + mov [eax+MUTEX_WAITER.list.next], edx + mov [edx+MUTEX_WAITER.list.prev], eax + cmp [ecx+MUTEX.wait.next], ecx jne @F mov [ecx+MUTEX.count], 0 @@: add esp, MUTEX_WAITER.sizeof - pop esi popfd .done: ret @@ -303,8 +293,8 @@ mutex_unlock: pushfd cli - lea eax, [ecx+MUTEX.next] - cmp eax, [ecx+MUTEX.next] + mov eax, [ecx+MUTEX.wait.next] + cmp eax, [ecx] mov [ecx+MUTEX.count], 1 je @F diff --git a/kernel/branches/Kolibri-acpi/data32.inc b/kernel/branches/Kolibri-acpi/data32.inc index 4f4c9ee5b3..97cdd13213 100644 --- a/kernel/branches/Kolibri-acpi/data32.inc +++ b/kernel/branches/Kolibri-acpi/data32.inc @@ -292,15 +292,12 @@ endofcode: gdte: align 16 -cur_saved_data rb 4096 -fpu_data: rb 512 +cur_saved_data rb 4096 +fpu_data: rb 512 mem_block_map rb 512 -mem_block_list rd 64*2 -mem_block_mask rd 2 -large_block_mask rd 1 - -mem_hash_cnt rd 64 +mem_block_list rd 64*2 +mem_block_mask rd 2 mem_used.fd rd 1 mem_used.bk rd 1 @@ -309,6 +306,8 @@ mem_block_arr rd 1 mem_block_start rd 1 mem_block_end rd 1 +mem_hash_cnt rd 64 + heap_mutex MUTEX heap_size rd 1 heap_free rd 1 diff --git a/kernel/branches/Kolibri-acpi/kernel32.inc b/kernel/branches/Kolibri-acpi/kernel32.inc index 56930f556e..c6cc0b5d89 100644 --- a/kernel/branches/Kolibri-acpi/kernel32.inc +++ b/kernel/branches/Kolibri-acpi/kernel32.inc @@ -196,9 +196,8 @@ end virtual struc MUTEX { + .wait LHEAD .count rd 1 - .next rd 1 - .prev rd 1 } virtual at 0 diff --git a/kernel/branches/Kolibri-acpi/macros.inc b/kernel/branches/Kolibri-acpi/macros.inc index 1a90f44f6c..30bbf66cf4 100644 --- a/kernel/branches/Kolibri-acpi/macros.inc +++ b/kernel/branches/Kolibri-acpi/macros.inc @@ -107,3 +107,32 @@ macro Mov op1,op2,op3 ; op1 = op2 = op3 mov op2,op3 mov op1,op2 } + +macro __list_add new, prev, next +{ + mov [next+LHEAD.prev], new + mov [new+LHEAD.next], next + mov [new+LHEAD.prev], prev + mov [prev+LHEAD.next], new +} + +macro list_add new, head +{ + mov eax, [head+LHEAD.next] + __list_add new, head, eax +} + +macro list_add_tail new, head +{ + mov eax, [head+LHEAD.prev] + __list_add new, eax, head +} + +macro list_del entry +{ + mov edx, [entry+list_fd] + mov ecx, [entry+list_bk] + mov [edx+list_bk], ecx + mov [ecx+list_fd], edx +} +