Ignore:
File:
1 edited

Legend:

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

    rc5429fe rf4bb404  
    3838#include <arch.h>
    3939#include <arch/cp0.h>
    40 #include <arch/smp/dorder.h>
    4140#include <time/clock.h>
    4241#include <ipc/sysipc.h>
    43 
    44 #define IRQ_COUNT   8
    45 #define TIMER_IRQ   7
    46 
    47 #ifdef MACHINE_msim
    48 #define DORDER_IRQ  5
    49 #endif
    50 
    51 function virtual_timer_fnc = NULL;
    52 static irq_t timer_irq;
    53 
    54 #ifdef MACHINE_msim
    55 static irq_t dorder_irq;
    56 #endif
    5742
    5843// TODO: This is SMP unsafe!!!
     
    6146static unsigned long nextcount;
    6247static unsigned long lastcount;
     48
     49/** Table of interrupt handlers. */
     50int_handler_t int_handler[MIPS_INTERRUPTS] = { };
    6351
    6452/** Disable interrupts.
     
    122110}
    123111
    124 static irq_ownership_t timer_claim(irq_t *irq)
    125 {
    126         return IRQ_ACCEPT;
    127 }
    128 
    129 static void timer_irq_handler(irq_t *irq)
     112static void timer_interrupt_handler(unsigned int intr)
    130113{
    131114        if (cp0_count_read() < lastcount)
     
    144127        cp0_compare_write(nextcount);
    145128
    146         /*
    147          * We are holding a lock which prevents preemption.
    148          * Release the lock, call clock() and reacquire the lock again.
    149          */
    150         irq_spinlock_unlock(&irq->lock, false);
    151129        clock();
    152         irq_spinlock_lock(&irq->lock, false);
    153 
    154         if (virtual_timer_fnc != NULL)
    155                 virtual_timer_fnc();
    156130}
    157 
    158 #ifdef MACHINE_msim
    159 static irq_ownership_t dorder_claim(irq_t *irq)
    160 {
    161         return IRQ_ACCEPT;
    162 }
    163 
    164 static void dorder_irq_handler(irq_t *irq)
    165 {
    166         dorder_ipi_ack(1 << dorder_cpuid());
    167 }
    168 #endif
    169131
    170132/* Initialize basic tables for exception dispatching */
    171133void interrupt_init(void)
    172134{
    173         irq_init(IRQ_COUNT, IRQ_COUNT);
    174 
    175         irq_initialize(&timer_irq);
    176         timer_irq.inr = TIMER_IRQ;
    177         timer_irq.claim = timer_claim;
    178         timer_irq.handler = timer_irq_handler;
    179         irq_register(&timer_irq);
     135        int_handler[INT_TIMER] = timer_interrupt_handler;
    180136
    181137        timer_start();
    182         cp0_unmask_int(TIMER_IRQ);
    183 
    184 #ifdef MACHINE_msim
    185         irq_initialize(&dorder_irq);
    186         dorder_irq.inr = DORDER_IRQ;
    187         dorder_irq.claim = dorder_claim;
    188         dorder_irq.handler = dorder_irq_handler;
    189         irq_register(&dorder_irq);
    190 
    191         cp0_unmask_int(DORDER_IRQ);
    192 #endif
     138        cp0_unmask_int(INT_TIMER);
    193139}
    194140
Note: See TracChangeset for help on using the changeset viewer.