Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/interrupt.c

    rf4bb404 rf5dd4a1  
    4141#include <ipc/sysipc.h>
    4242
     43#define IRQ_COUNT   8
     44#define TIMER_IRQ   7
     45
     46function virtual_timer_fnc = NULL;
     47static irq_t timer_irq;
     48
    4349// TODO: This is SMP unsafe!!!
    4450
     
    4652static unsigned long nextcount;
    4753static unsigned long lastcount;
    48 
    49 /** Table of interrupt handlers. */
    50 int_handler_t int_handler[MIPS_INTERRUPTS] = { };
    5154
    5255/** Disable interrupts.
     
    110113}
    111114
    112 static void timer_interrupt_handler(unsigned int intr)
     115static irq_ownership_t timer_claim(irq_t *irq)
     116{
     117        return IRQ_ACCEPT;
     118}
     119
     120static void timer_irq_handler(irq_t *irq)
    113121{
    114122        if (cp0_count_read() < lastcount)
     
    127135        cp0_compare_write(nextcount);
    128136
     137        /*
     138         * We are holding a lock which prevents preemption.
     139         * Release the lock, call clock() and reacquire the lock again.
     140         */
     141        irq_spinlock_unlock(&irq->lock, false);
    129142        clock();
     143        irq_spinlock_lock(&irq->lock, false);
     144
     145        if (virtual_timer_fnc != NULL)
     146                virtual_timer_fnc();
    130147}
    131148
     
    133150void interrupt_init(void)
    134151{
    135         int_handler[INT_TIMER] = timer_interrupt_handler;
     152        irq_init(IRQ_COUNT, IRQ_COUNT);
     153
     154        irq_initialize(&timer_irq);
     155        timer_irq.inr = TIMER_IRQ;
     156        timer_irq.claim = timer_claim;
     157        timer_irq.handler = timer_irq_handler;
     158        irq_register(&timer_irq);
    136159
    137160        timer_start();
    138         cp0_unmask_int(INT_TIMER);
     161        cp0_unmask_int(TIMER_IRQ);
    139162}
    140163
Note: See TracChangeset for help on using the changeset viewer.