Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1433 → Rev 1434

/drivers/ddk/core.S
22,6 → 22,10
 
.global _MapIoMem
 
.global _MutexInit
.global _MutexLock
.global _MutexUnlock
 
.global _PciApi
.global _PciRead16
.global _PciRead32
32,6 → 36,7
 
.global _RegService
 
.global _SetMouseData
.global _SetScreen
.global _SysMsgBoardStr
 
55,6 → 60,10
 
.def _MapIoMem; .scl 2; .type 32; .endef
 
.def _MutexInit; .scl 2; .type 32; .endef
.def _MutexLock; .scl 2; .type 32; .endef
.def _MutexUnlock; .scl 2; .type 32; .endef
 
.def _PciApi; .scl 2; .type 32; .endef
.def _PciRead16; .scl 2; .type 32; .endef
.def _PciRead32; .scl 2; .type 32; .endef
66,6 → 75,7
.def _RegService; .scl 2; .type 32; .endef
 
.def _SetScreen; .scl 2; .type 32; .endef
.def _SetMouseData; .scl 2; .type 32; .endef
.def _SysMsgBoardStr; .scl 2; .type 32; .endef
 
 
89,6 → 99,10
 
_MapIoMem:
 
_MutexInit:
_MutexLock:
_MutexUnlock:
 
_PciApi:
_PciRead16:
_PciRead32:
99,6 → 113,7
 
_RegService:
 
_SetMouseData:
_SetScreen:
_SysMsgBoardStr:
ret
125,6 → 140,10
 
.ascii " -export:MapIoMem" # stdcall
 
.ascii " -export:MutexInit" # fastcall
.ascii " -export:MutexLock" # fastcall
.ascii " -export:MutexUnlock" # fastcall
 
.ascii " -export:PciApi" #
.ascii " -export:PciRead16" # stdcall
.ascii " -export:PciRead32" # stdcall
135,6 → 154,7
 
.ascii " -export:RegService" # stdcall
 
.ascii " -export:SetMouseData" # stdcall
.ascii " -export:SetScreen" # stdcall
.ascii " -export:SysMsgBoardStr" # stdcall
 
/drivers/include/syscall.h
26,6 → 26,8
///////////////////////////////////////////////////////////////////////////////
 
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport))
#define FASTCALL __attribute__ ((fastcall)) __attribute__ ((dllimport))
 
#define IMPORT __attribute__ ((dllimport))
 
///////////////////////////////////////////////////////////////////////////////
61,6 → 63,9
 
int STDCALL AttachIntHandler(int irq, void *handler, u32_t access) __asm__("AttachIntHandler");
 
void FASTCALL MutexInit(struct mutex*)__asm__("MutexInit");
void FASTCALL MutexLock(struct mutex*)__asm__("MutexLock");
void FASTCALL MutexUnlock(struct mutex*)__asm__("MutexUnlock");
 
///////////////////////////////////////////////////////////////////////////////
 
/kernel/trunk/core/peload.inc
294,6 → 294,10
map_io_mem, 'MapIoMem', \ ; stdcall
get_pg_addr, 'GetPgAddr', \ ; eax
\
mutex_init, 'MutexInit', \ ; gcc fastcall
mutex_lock, 'MutexLock', \ ; gcc fastcall
mutex_unlock, 'MutexUnlock', \ ; gcc fastcall
\
get_display, 'GetDisplay', \
set_screen, 'SetScreen', \
pci_api, 'PciApi', \
/kernel/trunk/core/sched.inc
217,7 → 217,108
@@: ret
;end.
 
 
 
struc MUTEX_WAITER
{
.next rd 1
.prev rd 1
.task rd 1
.sizeof:
};
 
virtual at 0
MUTEX_WAITER MUTEX_WAITER
end virtual
 
;void __fastcall mutex_init(struct mutex *lock)
 
align 4
mutex_init:
lea eax, [ecx+MUTEX.next]
mov [ecx+MUTEX.count],1
mov [ecx+MUTEX.next], eax
mov [ecx+MUTEX.prev], eax
ret
 
 
;void __fastcall mutex_lock(struct mutex *lock)
 
align 4
mutex_lock:
 
dec [ecx+MUTEX.count]
jns .done
 
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
 
mov edx, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], edx
 
.forever:
 
mov eax, -1
xchg eax, [ecx+MUTEX.count]
dec eax
jz @F
 
mov [edx+TASKDATA.state], 1
call change_task
jmp .forever
@@:
mov edx, [esp+MUTEX_WAITER.next]
mov eax, [esp+MUTEX_WAITER.prev]
 
mov [eax+MUTEX_WAITER.next], edx
cmp [ecx+MUTEX.next], esi
mov [edx+MUTEX_WAITER.prev], eax
jne @F
 
mov [ecx+MUTEX.count], 0
@@:
add esp, MUTEX_WAITER.sizeof
 
pop esi
popfd
.done:
ret
 
;void __fastcall mutex_unlock(struct mutex *lock)
 
align 4
mutex_unlock:
 
pushfd
cli
 
lea eax, [ecx+MUTEX.next]
cmp eax, [ecx+MUTEX.next]
mov [ecx+MUTEX.count], 1
je @F
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], 0
@@:
popfd
ret
 
 
purge MUTEX_WAITER
 
if 0
 
struc TIMER
{
.next dd ?
/kernel/trunk/kernel32.inc
194,7 → 194,18
 
;// mike.dld, 2006-29-01 ]
 
struc MUTEX
{
.count rd 1
.next rd 1
.prev rd 1
}
 
virtual at 0
MUTEX MUTEX
end virtual
 
 
; Core functions
include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management