diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/include/core.h | 6 | ||||
-rw-r--r-- | core/pmapi.c | 3 | ||||
-rw-r--r-- | core/timer.inc | 15 |
3 files changed, 21 insertions, 3 deletions
diff --git a/core/include/core.h b/core/include/core.h index eb7bfcdb..7db5dafe 100644 --- a/core/include/core.h +++ b/core/include/core.h @@ -65,10 +65,14 @@ __noreturn _kaboom(void); /* * Basic timer function... */ -extern volatile uint32_t __jiffies; +extern volatile uint32_t __jiffies, __ms_timer; static inline uint32_t jiffies(void) { return __jiffies; } +static inline uint32_t ms_timer(void) +{ + return __ms_timer; +} #endif /* CORE_H */ diff --git a/core/pmapi.c b/core/pmapi.c index ff655330..4b1ccbb1 100644 --- a/core/pmapi.c +++ b/core/pmapi.c @@ -37,4 +37,7 @@ const struct com32_pmapi pm_api_vector = .chdir = chdir, .getcwd = getcwd, + + .jiffies = &__jiffies, + .ms_timer = &__ms_timer, }; diff --git a/core/timer.inc b/core/timer.inc index 728812b1..b01ff917 100644 --- a/core/timer.inc +++ b/core/timer.inc @@ -19,6 +19,9 @@ ;; about the BIOS_timer variable wrapping around at "midnight" and other ;; weird things. ;; +;; This also maintains a timer variable calibrated in milliseconds +;; (wraparound time = 49.7 days!) +;; section .text16 @@ -35,12 +38,20 @@ timer_cleanup: mov [BIOS_timer_hook],eax ret +; +; The specified frequency is 14.31818 MHz/12/65536; this turns out +; to be a period of 54.92542 ms, or 0x36.ece8(187c) hexadecimal. +; timer_irq: inc dword [cs:__jiffies] + add word [cs:__ms_timer_adj],0xece8 + adc dword [cs:__ms_timer],0x36 jmp 0:0 BIOS_timer_next equ $-4 section .data16 alignz 4 - global __jiffies -__jiffies dd 0 ; The actual timer variable + global __jiffies, __ms_timer +__jiffies dd 0 ; Clock tick timer +__ms_timer dd 0 ; Millisecond timer +__ms_timer_adj dw 0 ; Millisecond timer correction factor |