]>
wirehaze git hosting - BOS.git/blob - kernel/init/timer.asm
1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2005. ;
3 ;----------------------------------------------------------;
5 ; Function to set up the timer IRQ. ;
7 ;----------------------------------------------------------;
12 timer_wait dd 0 ; time to wait
13 timer_counter dd 0, 0 ; time since BOS started
14 call_list dd 0, 0, 0, 0, 0 ; functions to call
17 ;---------------------------;
19 ;---------------------------;
21 add dword [timer_counter
], 1 ; it's just a 64-bit
22 adc dword [timer_counter
+4], 0 ; counter since boot.
24 cmp [timer_wait
], 0 ; "delay" countdown.
28 .test1: ; checks for calls to
29 cmp [call_list
], dword 0 ; do before we quit.
31 call dword [call_list
]
33 cmp [call_list
+4], dword 0
35 call dword [call_list
+4]
37 cmp [call_list
+8], dword 0
39 call dword [call_list
+8]
41 cmp [call_list
+12], dword 0
43 call dword [call_list
+12]
45 cmp [call_list
+16], dword 0
47 call dword [call_list
+16]
56 ;------------------------------------------------;
57 ; add function for the timer to call ;
58 ; in: ebx = function address ;
59 ; out: eax = 0 if OK ;
60 ;------------------------------------------------;
70 cmp [call_list
+4], 0 ; since i am so lazy
71 jne .test3
; and a loop can be
72 mov [call_list
+4], ebx ; rather complicated
73 jmp .end ; for this stuff, i
74 .test3: ; check for each one..
75 cmp [call_list
+8], 0 ; after all, it's only 5.
77 mov [call_list
+8], ebx
82 mov [call_list
+12], ebx
87 mov [call_list
+16], ebx
94 ;-------------------------------------------------;
95 ; remove function from the call list ;
96 ; in: ebx = function address ;
97 ; out: eax = 0 if OK ;
98 ;-------------------------------------------------;
102 mov [call_list
], dword 0
108 cmp [call_list
+4], ebx
110 mov [call_list
+4], dword 0
113 cmp [call_list
+8], ebx
115 mov [call_list
+8], dword 0
118 cmp [call_list
+12], ebx
120 mov [call_list
+12], dword 0
123 cmp [call_list
+16], ebx
125 mov [call_list
+16], dword 0
132 ;--------------------------------------------;
134 ; in: ecx = 100/second to wait ;
136 ;--------------------------------------------;
138 mov [timer_wait
], ecx ; mov value to "timer"
146 ;--------------------------------------------;
149 ; gives the caller a pointer to the counter ;
150 ; so that it can check for timeouts etc, ;
152 ; in: ecx = 100/second to wait ;
153 ; out: ecx = pointer to counter ;
154 ;--------------------------------------------;
156 mov [timer_wait
], ecx ; mov value to "timer"
157 mov ecx, timer_wait
; let caller check value
162 ;------------------------------;
164 ;------------------------------;
167 mov al, 0x34 ; set to 100Hz, 0x34 = 00110100b
169 mov al, 0x9B ; lsb 1193180 / 1193