Files
kolibrios/drivers/vboxguest/core/timer.inc
2026-03-04 21:16:17 +03:00

58 lines
1.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
; =============================================================================
; Модуль : Timer
; Назначение : Периодический вызов fn_on_tick сервисов
; Файл : core/timer.inc
; =============================================================================
align 4
vbox_timer_handle dd 0
TIMER_DELAY_START equ 10 ; 100ms до первого вызова
TIMER_INTERVAL equ 10 ; 100ms между вызовами
; timer_init — Запуск таймера
proc timer_init
DEBUGF 2, "[VBoxGuest] [Timer] Initializing...\n"
mov eax, [vbox_timer_handle]
test eax, eax
jnz .ok
invoke TimerHS, TIMER_DELAY_START, TIMER_INTERVAL, timer_cb, 0
test eax, eax
jz .err
mov [vbox_timer_handle], eax
DEBUGF 2, "[VBoxGuest] [Timer] Started, handle=0x%x, interval=%dms\n", \
eax, TIMER_INTERVAL * 10
.ok:
xor eax, eax
ret
.err:
DEBUGF 2, "[VBoxGuest] [Timer] ERROR: Failed to start\n"
mov eax, VERR_INTERNAL_ERROR
ret
endp
; timer_stop — Остановка таймера
proc timer_stop
mov eax, [vbox_timer_handle]
test eax, eax
jz .done
invoke CancelTimerHS, eax
mov dword [vbox_timer_handle], 0
DEBUGF 2, "[VBoxGuest] [Timer] Stopped\n"
.done:
ret
endp
; Callback таймера — вызывает fn_on_tick у всех включенных сервисов
proc timer_cb stdcall, userdata:dword
stdcall dispatcher_tick_all
ret
endp