2006-12-02 09:18:48 +01:00
|
|
|
|
|
|
|
align 4
|
|
|
|
init_events:
|
2007-02-16 05:16:52 +01:00
|
|
|
stdcall kernel_alloc, 512*EVENT_SIZE
|
2006-12-02 09:18:48 +01:00
|
|
|
mov [events], eax
|
|
|
|
xor eax, eax
|
2007-02-16 05:16:52 +01:00
|
|
|
mov [event_uid], eax
|
2006-12-02 09:18:48 +01:00
|
|
|
not eax
|
|
|
|
mov edi, event_map
|
|
|
|
mov [event_start], edi
|
2007-02-16 05:16:52 +01:00
|
|
|
mov ecx, 64/4
|
2006-12-02 09:18:48 +01:00
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
mov [event_end], edi
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc alloc_event
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov ebx, [event_start]
|
|
|
|
mov ecx, [event_end]
|
|
|
|
.l1:
|
|
|
|
bsf eax,[ebx]
|
|
|
|
jnz .found
|
|
|
|
add ebx,4
|
|
|
|
cmp ebx, ecx
|
|
|
|
jb .l1
|
|
|
|
popfd
|
|
|
|
xor eax,eax
|
|
|
|
ret
|
|
|
|
.found:
|
|
|
|
btr [ebx], eax
|
|
|
|
mov [event_start],ebx
|
2007-02-16 05:16:52 +01:00
|
|
|
inc [event_uid]
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
sub ebx, event_map
|
2006-12-29 08:12:27 +01:00
|
|
|
lea eax,[eax+ebx*8]
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
lea ebx, [eax+eax*4]
|
2006-12-02 09:18:48 +01:00
|
|
|
shl eax,5
|
2007-02-16 05:16:52 +01:00
|
|
|
lea eax,[eax+ebx*4] ;eax*=52 (EVENT_SIZE)
|
2006-12-02 09:18:48 +01:00
|
|
|
add eax, [events]
|
2007-02-16 05:16:52 +01:00
|
|
|
mov ebx, [event_uid]
|
2006-12-02 09:18:48 +01:00
|
|
|
popfd
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
free_event:
|
|
|
|
sub eax, [events]
|
2007-02-16 05:16:52 +01:00
|
|
|
mov ecx, EVENT_SIZE
|
2006-12-02 09:18:48 +01:00
|
|
|
mov ebx, event_map
|
2007-02-16 05:16:52 +01:00
|
|
|
cdq
|
|
|
|
div ecx
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
2006-12-02 09:18:48 +01:00
|
|
|
bts [ebx], eax
|
|
|
|
shr eax, 3
|
|
|
|
and eax, not 3
|
|
|
|
add eax, ebx
|
|
|
|
cmp [event_start], eax
|
|
|
|
ja @f
|
|
|
|
popfd
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
mov [event_start], eax
|
|
|
|
popfd
|
|
|
|
ret
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
EVENT_WATCHED equ 0x10000000
|
|
|
|
EVENT_SIGNALED equ 0x20000000
|
|
|
|
MANUAL_RESET equ 0x40000000
|
|
|
|
MANUAL_DESTROY equ 0x80000000
|
|
|
|
|
|
|
|
|
|
|
|
; param
|
|
|
|
; eax= event data
|
|
|
|
; ebx= flags
|
|
|
|
;
|
|
|
|
; retval
|
|
|
|
; eax= event
|
|
|
|
; edx= id
|
|
|
|
|
|
|
|
create_event:
|
|
|
|
.flags equ esp+4
|
|
|
|
.data equ esp
|
|
|
|
|
|
|
|
push ebx
|
|
|
|
push eax
|
|
|
|
|
|
|
|
call alloc_event
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
mov [eax+APPOBJ.magic], 'EVNT'
|
2007-02-19 09:22:55 +01:00
|
|
|
mov [eax+APPOBJ.destroy], destroy_event.internal
|
2007-02-16 05:16:52 +01:00
|
|
|
mov [eax+EVENT.id], ebx
|
|
|
|
|
|
|
|
mov ebx, [CURRENT_TASK]
|
|
|
|
shl ebx, 5
|
2007-02-28 09:52:06 +01:00
|
|
|
mov ebx, [CURRENT_TASK+ebx+4]
|
2007-02-16 05:16:52 +01:00
|
|
|
mov [eax+APPOBJ.pid], ebx
|
|
|
|
mov edx, [.flags]
|
|
|
|
mov [eax+EVENT.state], edx
|
|
|
|
|
|
|
|
mov esi, [.data]
|
|
|
|
test esi, esi
|
|
|
|
jz @F
|
|
|
|
lea edi, [eax+EVENT.code]
|
|
|
|
mov ecx, 6
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
@@:
|
|
|
|
mov ecx, [CURRENT_TASK]
|
|
|
|
shl ecx,8
|
2007-02-28 11:51:05 +01:00
|
|
|
add ecx, SLOT_BASE+APP_OBJ_OFFSET
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov edx, [ecx+APPOBJ.fd]
|
|
|
|
mov [eax+APPOBJ.fd], edx
|
|
|
|
mov [eax+APPOBJ.bk], ecx
|
|
|
|
mov [ecx+APPOBJ.fd], eax
|
|
|
|
mov [edx+APPOBJ.bk], eax
|
|
|
|
popfd
|
|
|
|
mov edx, [eax+EVENT.id]
|
|
|
|
.fail:
|
|
|
|
add esp, 8
|
|
|
|
ret
|
|
|
|
|
|
|
|
restore .flags
|
|
|
|
restore .data
|
|
|
|
|
|
|
|
; param
|
|
|
|
; eax= event
|
|
|
|
; ebx= id
|
|
|
|
|
|
|
|
destroy_event:
|
|
|
|
|
|
|
|
cmp [eax+APPOBJ.magic], 'EVNT'
|
|
|
|
jne .fail
|
|
|
|
cmp [eax+EVENT.id], ebx
|
|
|
|
jne .fail
|
2007-02-19 09:22:55 +01:00
|
|
|
.internal:
|
2007-02-16 05:16:52 +01:00
|
|
|
mov ebx, [eax+APPOBJ.fd]
|
|
|
|
mov ecx, [eax+APPOBJ.bk]
|
|
|
|
mov [ebx+APPOBJ.bk], ecx
|
|
|
|
mov [ecx+APPOBJ.fd], ebx
|
2007-02-19 09:22:55 +01:00
|
|
|
.force:
|
2007-02-16 05:16:52 +01:00
|
|
|
xor edx, edx ;clear common header
|
|
|
|
mov [eax], edx
|
|
|
|
mov [eax+4], edx
|
|
|
|
mov [eax+8], edx
|
|
|
|
mov [eax+12], edx
|
|
|
|
mov [eax+16], edx
|
|
|
|
|
|
|
|
call free_event ;release object memory
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
align 4
|
|
|
|
proc send_event stdcall pid:dword, event:dword
|
|
|
|
locals
|
|
|
|
slot dd ?
|
|
|
|
endl
|
|
|
|
|
|
|
|
mov eax, [pid]
|
|
|
|
call pid_to_slot
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
cmp [SLOT_BASE+eax+APPDATA.ev_count], 32
|
2006-12-02 09:18:48 +01:00
|
|
|
ja .fail
|
|
|
|
|
|
|
|
mov [slot], eax
|
2007-02-16 05:16:52 +01:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
call alloc_event
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
lea edi, [eax+EVENT.code]
|
2006-12-02 09:18:48 +01:00
|
|
|
mov ecx, 6
|
|
|
|
mov esi, [event]
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
mov ecx, [slot]
|
2007-02-28 11:51:05 +01:00
|
|
|
add ecx, SLOT_BASE+APP_EV_OFFSET
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
mov [eax+APPOBJ.magic], 'EVNT'
|
|
|
|
mov [eax+APPOBJ.destroy], destroy_event
|
|
|
|
mov ebx, [pid]
|
|
|
|
mov [eax+APPOBJ.pid], ebx
|
|
|
|
mov [eax+EVENT.state], EVENT_SIGNALED
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli ;insert event into
|
|
|
|
mov edx, [ecx+APPOBJ.fd] ;events list
|
|
|
|
mov [eax+APPOBJ.fd], edx ;and set events flag
|
|
|
|
mov [eax+APPOBJ.bk], ecx
|
|
|
|
mov [ecx+APPOBJ.fd], eax
|
|
|
|
mov [edx+APPOBJ.bk], eax
|
|
|
|
inc [ecx+APPDATA.ev_count-APP_EV_OFFSET]
|
|
|
|
or [ecx+APPDATA.event_mask-APP_EV_OFFSET], EVENT_EXTENDED
|
|
|
|
popfd
|
2006-12-02 09:18:48 +01:00
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
; timeout ignored
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
align 4
|
|
|
|
proc get_event_ex stdcall, p_ev:dword, timeout:dword
|
|
|
|
|
|
|
|
.wait:
|
2007-02-16 05:16:52 +01:00
|
|
|
mov edx,[CURRENT_TASK]
|
|
|
|
shl edx,8
|
2007-02-28 11:51:05 +01:00
|
|
|
; cmp [SLOT_BASE+edx+APPDATA.ev_count], 0
|
2007-02-26 13:40:37 +01:00
|
|
|
; je .switch
|
2006-12-02 09:18:48 +01:00
|
|
|
|
2007-02-28 11:51:05 +01:00
|
|
|
add edx, SLOT_BASE+APP_EV_OFFSET
|
2006-12-02 09:18:48 +01:00
|
|
|
|
2007-02-26 13:40:37 +01:00
|
|
|
mov eax, [edx+APPOBJ.fd]
|
2007-02-16 05:16:52 +01:00
|
|
|
cmp eax, edx
|
|
|
|
je .switch
|
|
|
|
|
|
|
|
lea esi, [eax+EVENT.code]
|
|
|
|
mov edi, [p_ev] ;copy event data
|
2006-12-02 09:18:48 +01:00
|
|
|
mov ecx, 6
|
|
|
|
cld
|
|
|
|
rep movsd
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
and dword [edi-24], 0xFF00FFFF ;clear priority field
|
2007-02-26 13:40:37 +01:00
|
|
|
;
|
2007-02-16 05:16:52 +01:00
|
|
|
test [eax+EVENT.state], MANUAL_RESET
|
|
|
|
jnz .done
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli ;remove event from events
|
|
|
|
mov ebx, [eax+APPOBJ.fd] ;list (reset event)
|
|
|
|
mov ecx, [eax+APPOBJ.bk] ;and clear events flag
|
|
|
|
mov [ebx+APPOBJ.bk], ecx ;if no active events
|
|
|
|
mov [ecx+APPOBJ.fd], ebx
|
2007-02-26 13:40:37 +01:00
|
|
|
|
|
|
|
and [eax+EVENT.state], not (EVENT_SIGNALED+EVENT_WATCHED)
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
dec [edx+APPDATA.ev_count-APP_EV_OFFSET]
|
|
|
|
jnz @F
|
|
|
|
and [edx+APPDATA.event_mask-APP_EV_OFFSET], not EVENT_EXTENDED
|
2007-02-26 13:40:37 +01:00
|
|
|
@@:
|
2007-02-16 05:16:52 +01:00
|
|
|
popfd
|
|
|
|
|
|
|
|
test [eax+EVENT.state], MANUAL_DESTROY
|
|
|
|
jz .destroy
|
|
|
|
|
|
|
|
add edx, (APP_OBJ_OFFSET-APP_EV_OFFSET)
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
2007-02-26 13:40:37 +01:00
|
|
|
mov ebx, [edx+APPOBJ.fd] ;insert event into
|
|
|
|
mov [eax+APPOBJ.fd], ebx ;objects list
|
|
|
|
mov [eax+APPOBJ.bk], edx
|
|
|
|
mov [edx+APPOBJ.fd], eax
|
|
|
|
mov [ebx+APPOBJ.bk], eax
|
2007-02-16 05:16:52 +01:00
|
|
|
popfd
|
|
|
|
.done:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.destroy:
|
2007-02-19 09:22:55 +01:00
|
|
|
call destroy_event.force
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
|
|
|
.switch:
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [TASK_BASE]
|
2006-12-02 09:18:48 +01:00
|
|
|
mov [eax+TASKDATA.state], byte 5
|
|
|
|
call change_task
|
|
|
|
jmp .wait
|
|
|
|
endp
|
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
; param
|
|
|
|
; eax= event
|
|
|
|
; ebx= id
|
|
|
|
|
|
|
|
align 4
|
|
|
|
wait_event:
|
|
|
|
.event equ esp
|
|
|
|
push eax
|
|
|
|
.wait:
|
|
|
|
cmp [eax+APPOBJ.magic], 'EVNT'
|
|
|
|
jne .done
|
|
|
|
cmp [eax+EVENT.id], ebx
|
|
|
|
jne .done
|
|
|
|
|
|
|
|
test [eax+EVENT.state], EVENT_SIGNALED
|
|
|
|
jz .switch
|
|
|
|
|
|
|
|
test [eax+EVENT.state], MANUAL_RESET
|
|
|
|
jnz .done
|
|
|
|
|
|
|
|
mov edx,[CURRENT_TASK]
|
|
|
|
shl edx,8
|
2007-02-28 11:51:05 +01:00
|
|
|
add edx, SLOT_BASE
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli ;remove event from events
|
|
|
|
mov ebx, [eax+APPOBJ.fd] ;list (reset event)
|
|
|
|
mov ecx, [eax+APPOBJ.bk] ;and clear events flag
|
|
|
|
mov [ebx+APPOBJ.bk], ecx ;if no active events
|
|
|
|
mov [ecx+APPOBJ.fd], ebx
|
|
|
|
dec [edx+APPDATA.ev_count]
|
|
|
|
jnz @F
|
|
|
|
and [edx+APPDATA.event_mask], not EVENT_EXTENDED
|
|
|
|
@@:
|
|
|
|
and [eax+EVENT.state], not (EVENT_SIGNALED+EVENT_WATCHED)
|
|
|
|
popfd
|
|
|
|
|
|
|
|
test [eax+EVENT.state], MANUAL_DESTROY
|
|
|
|
jz .destroy
|
|
|
|
|
|
|
|
add edx, APP_OBJ_OFFSET
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov ecx, [edx+APPOBJ.fd] ;insert event into
|
|
|
|
mov [eax+APPOBJ.fd], ecx ;objects list
|
|
|
|
mov [eax+APPOBJ.bk], edx
|
|
|
|
mov [edx+APPOBJ.fd], eax
|
|
|
|
mov [ecx+APPOBJ.bk], eax
|
|
|
|
popfd
|
|
|
|
.done:
|
|
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
.destroy:
|
2007-02-19 09:22:55 +01:00
|
|
|
call destroy_event.force
|
2007-02-16 05:16:52 +01:00
|
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
.switch:
|
|
|
|
or [eax+EVENT.state], EVENT_WATCHED
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [TASK_BASE]
|
2007-02-16 05:16:52 +01:00
|
|
|
mov [eax+TASKDATA.state], byte 5
|
|
|
|
call change_task
|
|
|
|
mov eax, [.event]
|
|
|
|
jmp .wait
|
|
|
|
restore .event
|
|
|
|
|
|
|
|
; param
|
|
|
|
; eax= event
|
|
|
|
; ebx= id
|
|
|
|
; ecx= flags
|
2007-02-26 13:40:37 +01:00
|
|
|
; edx= event data
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
raise_event:
|
|
|
|
.event equ esp
|
|
|
|
push eax
|
|
|
|
|
|
|
|
cmp [eax+APPOBJ.magic], 'EVNT'
|
|
|
|
jne .fail
|
|
|
|
cmp [eax+EVENT.id], ebx
|
|
|
|
jne .fail
|
|
|
|
|
|
|
|
mov eax, [eax+APPOBJ.pid]
|
|
|
|
call pid_to_slot
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
2007-02-26 13:40:37 +01:00
|
|
|
mov esi, edx
|
|
|
|
test esi, esi
|
2007-02-16 05:16:52 +01:00
|
|
|
mov edx, [.event]
|
2007-02-26 13:40:37 +01:00
|
|
|
jz @F
|
|
|
|
|
|
|
|
push ecx
|
|
|
|
lea edi, [edx+EVENT.code]
|
|
|
|
mov ecx, 6
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
pop ecx
|
|
|
|
@@:
|
2007-02-16 05:16:52 +01:00
|
|
|
test [edx+EVENT.state], EVENT_SIGNALED
|
|
|
|
jnz .done
|
|
|
|
|
|
|
|
test ecx, EVENT_WATCHED
|
|
|
|
jz @F
|
|
|
|
test [edx+EVENT.state], EVENT_WATCHED
|
|
|
|
jz .done
|
|
|
|
@@:
|
|
|
|
shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
add eax, SLOT_BASE+APP_EV_OFFSET
|
2007-02-16 05:16:52 +01:00
|
|
|
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov ebx, [edx+APPOBJ.fd]
|
|
|
|
mov ecx, [edx+APPOBJ.bk]
|
|
|
|
mov [ebx+APPOBJ.bk], ecx
|
|
|
|
mov [ecx+APPOBJ.fd], ebx
|
|
|
|
|
|
|
|
mov ecx, [eax+APPOBJ.fd]
|
|
|
|
mov [edx+APPOBJ.fd], ecx
|
|
|
|
mov [edx+APPOBJ.bk], eax
|
|
|
|
mov [eax+APPOBJ.fd], edx
|
|
|
|
mov [ecx+APPOBJ.bk], edx
|
|
|
|
or [edx+EVENT.state], EVENT_SIGNALED
|
|
|
|
|
|
|
|
inc [eax+APPDATA.ev_count-APP_EV_OFFSET]
|
|
|
|
or [eax+APPDATA.event_mask-APP_EV_OFFSET], EVENT_EXTENDED
|
|
|
|
popfd
|
|
|
|
.fail:
|
|
|
|
.done:
|
|
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
restore .event
|
|
|
|
|
2007-02-26 13:40:37 +01:00
|
|
|
; param
|
|
|
|
; eax= event
|
|
|
|
; ebx= id
|
|
|
|
align 4
|
|
|
|
clear_event:
|
|
|
|
.event equ esp
|
|
|
|
push eax
|
|
|
|
|
|
|
|
cmp [eax+APPOBJ.magic], 'EVNT'
|
|
|
|
jne .fail
|
|
|
|
cmp [eax+EVENT.id], ebx
|
|
|
|
jne .fail
|
|
|
|
|
|
|
|
mov eax, [eax+APPOBJ.pid]
|
|
|
|
call pid_to_slot
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
add eax, SLOT_BASE+APP_EV_OFFSET
|
2007-02-26 13:40:37 +01:00
|
|
|
mov edx, [.event]
|
|
|
|
pushfd
|
|
|
|
cli ;remove event from events
|
|
|
|
mov ebx, [edx+APPOBJ.fd] ;list (reset event)
|
|
|
|
mov ecx, [edx+APPOBJ.bk] ;and clear events flag
|
|
|
|
mov [ebx+APPOBJ.bk], ecx ;if no active events
|
|
|
|
mov [ecx+APPOBJ.fd], ebx
|
|
|
|
|
|
|
|
and [edx+EVENT.state], not (EVENT_SIGNALED+EVENT_WATCHED)
|
|
|
|
|
|
|
|
dec [eax+APPDATA.ev_count-APP_EV_OFFSET]
|
|
|
|
jnz @F
|
|
|
|
and [eax+APPDATA.event_mask-APP_EV_OFFSET], not EVENT_EXTENDED
|
|
|
|
@@:
|
|
|
|
add eax, (APP_OBJ_OFFSET-APP_EV_OFFSET)
|
|
|
|
|
|
|
|
mov ecx, [eax+APPOBJ.fd] ;insert event into
|
|
|
|
mov [edx+APPOBJ.fd], ecx ;objects list
|
|
|
|
mov [edx+APPOBJ.bk], eax
|
|
|
|
mov [eax+APPOBJ.fd], edx
|
|
|
|
mov [ecx+APPOBJ.bk], edx
|
|
|
|
popfd
|
|
|
|
.fail:
|
|
|
|
.done:
|
|
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
restore .event
|
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
sys_getevent:
|
|
|
|
|
|
|
|
call get_event_for_app
|
|
|
|
mov [esp+36],eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
sys_wait_event_timeout:
|
|
|
|
|
2005-11-07 16:50:30 +01:00
|
|
|
mov ebx,[timer_ticks]
|
2005-10-06 19:56:22 +02:00
|
|
|
add ebx,eax
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp ebx,[timer_ticks]
|
2005-10-06 19:56:22 +02:00
|
|
|
jna .swfet2
|
2006-12-02 09:18:48 +01:00
|
|
|
.swfet1:
|
2005-10-06 19:56:22 +02:00
|
|
|
call get_event_for_app
|
|
|
|
test eax,eax
|
|
|
|
jne .eventoccur_time
|
|
|
|
call change_task
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp ebx,[timer_ticks]
|
2005-10-06 19:56:22 +02:00
|
|
|
jg .swfet1
|
2006-12-02 09:18:48 +01:00
|
|
|
.swfet2:
|
2005-10-06 19:56:22 +02:00
|
|
|
xor eax,eax
|
2006-12-02 09:18:48 +01:00
|
|
|
.eventoccur_time:
|
2005-10-06 19:56:22 +02:00
|
|
|
mov [esp+36],eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
|
|
|
sys_waitforevent:
|
|
|
|
|
|
|
|
call get_event_for_app
|
|
|
|
test eax,eax
|
|
|
|
jne eventoccur
|
|
|
|
newwait:
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [TASK_BASE]
|
2006-08-06 12:29:45 +02:00
|
|
|
mov [eax+TASKDATA.state], byte 5
|
2005-10-06 19:56:22 +02:00
|
|
|
call change_task
|
2005-11-07 16:50:30 +01:00
|
|
|
|
|
|
|
mov eax, [event_sched]
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
eventoccur:
|
|
|
|
mov [esp+36],eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
get_event_for_app:
|
|
|
|
|
|
|
|
pushad
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
mov edi,[TASK_BASE] ; WINDOW REDRAW
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 1
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_eventoccur1
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE]
|
2006-08-06 12:29:45 +02:00
|
|
|
cmp [edi-twdw+WDATA.fl_redraw],byte 0
|
2005-10-06 19:56:22 +02:00
|
|
|
je no_eventoccur1
|
|
|
|
popad
|
|
|
|
mov eax,1
|
|
|
|
ret
|
|
|
|
no_eventoccur1:
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; KEY IN BUFFER
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 2
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_eventoccur2
|
2007-02-28 09:52:06 +01:00
|
|
|
mov ecx, [CURRENT_TASK]
|
2007-02-28 11:51:05 +01:00
|
|
|
movzx edx,word [WIN_STACK+ecx*2]
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [TASK_COUNT]
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp eax,edx
|
2006-06-30 14:23:15 +02:00
|
|
|
jne no_eventoccur2x
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp [0xf400],byte 0
|
2006-06-30 14:23:15 +02:00
|
|
|
je no_eventoccur2x
|
|
|
|
eventoccur2:
|
2005-10-06 19:56:22 +02:00
|
|
|
popad
|
|
|
|
mov eax,2
|
|
|
|
ret
|
2006-06-30 14:23:15 +02:00
|
|
|
no_eventoccur2x:
|
|
|
|
mov eax, hotkey_buffer
|
|
|
|
@@:
|
|
|
|
cmp [eax], ecx
|
|
|
|
jz eventoccur2
|
|
|
|
add eax, 8
|
|
|
|
cmp eax, hotkey_buffer+120*8
|
|
|
|
jb @b
|
2005-10-06 19:56:22 +02:00
|
|
|
no_eventoccur2:
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; BUTTON IN BUFFER
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 4
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_eventoccur3
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp [0xf500],byte 0
|
|
|
|
je no_eventoccur3
|
2007-02-28 09:52:06 +01:00
|
|
|
mov ecx, [CURRENT_TASK]
|
2007-02-28 11:51:05 +01:00
|
|
|
movzx edx, word [WIN_STACK+ecx*2]
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [TASK_COUNT]
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp eax,edx
|
|
|
|
jnz no_eventoccur3
|
|
|
|
popad
|
|
|
|
mov eax,[0xf501]
|
|
|
|
cmp eax,65535
|
|
|
|
je no_event_1
|
|
|
|
mov eax,3
|
|
|
|
ret
|
|
|
|
|
|
|
|
no_event_1:
|
|
|
|
mov [window_minimize],1
|
|
|
|
mov [0xf500],byte 0
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
no_eventoccur3:
|
2006-12-02 09:18:48 +01:00
|
|
|
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; mouse event
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 00100000b
|
2005-11-07 16:50:30 +01:00
|
|
|
jz no_mouse_event
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax,[CURRENT_TASK]
|
2005-11-07 16:50:30 +01:00
|
|
|
shl eax,8
|
2007-02-28 11:51:05 +01:00
|
|
|
test [eax+SLOT_BASE+APPDATA.event_mask],dword 00100000b
|
2005-11-07 16:50:30 +01:00
|
|
|
jz no_mouse_event
|
2007-02-28 11:51:05 +01:00
|
|
|
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-00100000b
|
2005-11-07 16:50:30 +01:00
|
|
|
popad
|
|
|
|
mov eax,6
|
|
|
|
ret
|
|
|
|
no_mouse_event:
|
2006-12-02 09:18:48 +01:00
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 16
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_eventoccur5
|
|
|
|
cmp [0xfff0],byte 2
|
|
|
|
jnz no_eventoccur5
|
|
|
|
popad
|
|
|
|
mov eax,5
|
|
|
|
ret
|
|
|
|
no_eventoccur5:
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; IPC
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 01000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_ipc
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax,[CURRENT_TASK]
|
2005-11-07 16:50:30 +01:00
|
|
|
shl eax,8
|
2007-02-28 11:51:05 +01:00
|
|
|
test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_ipc
|
2007-02-28 11:51:05 +01:00
|
|
|
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
popad
|
|
|
|
mov eax,7
|
|
|
|
ret
|
|
|
|
no_ipc:
|
|
|
|
|
|
|
|
|
2007-02-28 09:52:06 +01:00
|
|
|
;mov edi,[TASK_BASE] ; STACK
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],dword 10000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_stack_event
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax,[CURRENT_TASK]
|
2005-11-07 16:50:30 +01:00
|
|
|
shl eax,8
|
2007-02-28 11:51:05 +01:00
|
|
|
test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_stack_event
|
2007-02-28 11:51:05 +01:00
|
|
|
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b
|
2005-10-06 19:56:22 +02:00
|
|
|
popad
|
2005-11-07 16:50:30 +01:00
|
|
|
mov eax,8
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
|
|
|
no_stack_event:
|
|
|
|
|
2006-08-06 12:29:45 +02:00
|
|
|
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
|
2007-02-16 05:16:52 +01:00
|
|
|
jz .test_IRQ
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax, [CURRENT_TASK]
|
2006-01-25 14:19:21 +01:00
|
|
|
shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1
|
2007-02-16 05:16:52 +01:00
|
|
|
jz .test_IRQ
|
2007-02-28 11:51:05 +01:00
|
|
|
and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1
|
2006-01-25 14:19:21 +01:00
|
|
|
popad
|
|
|
|
mov eax, 9
|
|
|
|
ret
|
2006-12-02 09:18:48 +01:00
|
|
|
|
2007-02-16 05:16:52 +01:00
|
|
|
;.test_ext:
|
2007-02-28 09:52:06 +01:00
|
|
|
; mov eax, [CURRENT_TASK]
|
2007-02-16 05:16:52 +01:00
|
|
|
; shl eax, 8
|
2007-02-28 11:51:05 +01:00
|
|
|
; test dword [eax+SLOT_BASE+APPDATA.event_mask], EVENT_EXTENDED
|
2007-02-16 05:16:52 +01:00
|
|
|
; jz .test_IRQ
|
|
|
|
; popad
|
|
|
|
; mov eax, 10
|
|
|
|
; ret
|
2006-12-02 09:18:48 +01:00
|
|
|
|
|
|
|
.test_IRQ:
|
2006-08-06 12:29:45 +02:00
|
|
|
cmp dword [edi+TASKDATA.event_mask], 0xFFFF
|
2005-11-07 16:50:30 +01:00
|
|
|
jbe no_events
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
mov esi,0x2e0000 ; IRQ'S AND DATA
|
|
|
|
mov ebx,0x00010000
|
|
|
|
xor ecx, ecx
|
|
|
|
irq_event_test:
|
2007-02-28 09:52:06 +01:00
|
|
|
mov edi,[TASK_BASE]
|
2006-08-06 12:29:45 +02:00
|
|
|
test [edi+TASKDATA.event_mask],ebx
|
2005-10-06 19:56:22 +02:00
|
|
|
jz no_irq_event
|
|
|
|
mov edi,ecx
|
|
|
|
shl edi,2
|
|
|
|
add edi,irq_owner
|
|
|
|
mov edx,[edi]
|
2007-02-28 09:52:06 +01:00
|
|
|
mov eax,[TASK_BASE]
|
2006-08-06 12:29:45 +02:00
|
|
|
mov eax,[eax+TASKDATA.pid]
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp edx,eax
|
|
|
|
jne no_irq_event
|
|
|
|
cmp [esi],dword 0
|
|
|
|
jz no_irq_event
|
|
|
|
mov eax,ecx
|
|
|
|
add eax,16
|
|
|
|
mov [esp+28],eax
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
no_irq_event:
|
|
|
|
add esi,0x1000
|
|
|
|
shl ebx,1
|
|
|
|
inc ecx
|
|
|
|
cmp ecx,16
|
|
|
|
jb irq_event_test
|
|
|
|
|
2005-11-07 16:50:30 +01:00
|
|
|
no_events:
|
2005-10-06 19:56:22 +02:00
|
|
|
popad
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
|