Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2632 → Rev 2633

/trunk/kernel/arch/mips32/src/interrupt.c
89,10 → 89,14
}
 
/* TODO: This is SMP unsafe!!! */
uint32_t count_hi = 0;
static unsigned long nextcount;
static unsigned long lastcount;
 
/** Start hardware clock */
static void timer_start(void)
{
lastcount = cp0_count_read();
nextcount = cp0_compare_value + cp0_count_read();
cp0_compare_write(nextcount);
}
105,7 → 109,13
static void timer_irq_handler(irq_t *irq, void *arg, ...)
{
unsigned long drift;
 
if (cp0_count_read() < lastcount) {
/* Count overflow detection */
count_hi++;
lastcount = cp0_count_read();
}
drift = cp0_count_read() - nextcount;
while (drift > cp0_compare_value) {
drift -= cp0_compare_value;
113,7 → 123,7
}
nextcount = cp0_count_read() + cp0_compare_value - drift;
cp0_compare_write(nextcount);
 
/*
* We are holding a lock which prevents preemption.
* Release the lock, call clock() and reacquire the lock again.