acpi:rework mutexes

git-svn-id: svn://kolibrios.org@2143 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-02 06:58:48 +00:00
parent 3c8db1907e
commit 1edac8b45a
6 changed files with 50 additions and 74 deletions

View File

@ -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 ?

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -196,9 +196,8 @@ end virtual
struc MUTEX
{
.wait LHEAD
.count rd 1
.next rd 1
.prev rd 1
}
virtual at 0

View File

@ -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
}