What might be the cause of the problem?
I have already tried using the volatile keyword but it didn't help for some reason.
And yes, the clock interrupt handler does get called when I don't call timer_wait().
My timer.c:
Code: Select all
#include <irq.h>
#include <system.h>
#include <trace.h>
#define TIMER_TICKS_PER_SEC 100
/* This will keep track of how many ticks that the system
* has been running for */
static volatile int timer_ticks=0;
static volatile int seconds=0;
void timer_handler(struct regs *r)
{
timer_ticks++;/*TRACE;*/
puts("time: ");putnum(timer_ticks);putch('\n');
if (timer_ticks%TIMER_TICKS_PER_SEC==0)
{
seconds++;
}
}
void timer_install()
{
int divisor=1193180/TIMER_TICKS_PER_SEC; /* Calculate our divisor */
outportb(0x43,0x36); /* Set our command byte 0x36 */
outportb(0x40,divisor&0xFF); /* Set low byte of divisor */
outportb(0x40,divisor>>8); /* Set high byte of divisor */
puts("\tFrequency: ");
putnum(TIMER_TICKS_PER_SEC);
puts(" hz\n");
irq_install_handler(0, timer_handler);
}
void timer_wait(int ticks)
{
unsigned long eticks;
eticks = timer_ticks + ticks/(1000/TIMER_TICKS_PER_SEC);
while(timer_ticks <= eticks)
{
puts("time: ");putnum(timer_ticks);puts(" eticks: ");putnum(eticks);putch('\n');
}
}
int timer_get_ticks()
{
return timer_ticks*(1000/TIMER_TICKS_PER_SEC);
}
Code: Select all
global irq0
global irq1
global irq2
global irq3
global irq4
global irq5
global irq6
global irq7
global irq8
global irq9
global irq10
global irq11
global irq12
global irq13
global irq14
global irq15
; 32: IRQ0
irq0:
cli
push byte 0
push byte 32
jmp irq_common_stub
; 33: IRQ1
irq1:
cli
push byte 0
push byte 33
jmp irq_common_stub
--snip--
; 47: IRQ15
irq15:
cli
push byte 0
push byte 47
jmp irq_common_stub
extern irq_handler
irq_common_stub:
pusha
push ds
push es
push fs
push gs
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, irq_handler
call eax
pop eax
pop gs
pop fs
pop es
pop ds
popa
add esp, 8
iret