Ignore:
File:
1 edited

Legend:

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

    r2b698d8 rd99c1d2  
    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>
     
    4948function virtual_timer_fnc = NULL;
    5049static irq_t timer_irq;
    51 static irq_t dorder_irq;
    52 
    53 // TODO: This is SMP unsafe!!!
    54 
    55 uint32_t count_hi = 0;
    56 static unsigned long nextcount;
    57 static unsigned long lastcount;
    5850
    5951/** Disable interrupts.
     
    9789}
    9890
    99 /** Check interrupts state.
    100  *
    101  * @return True if interrupts are disabled.
    102  *
    103  */
    104 bool interrupts_disabled(void)
    105 {
    106         return !(cp0_status_read() & cp0_status_ie_enabled_bit);
    107 }
     91/* TODO: This is SMP unsafe!!! */
     92uint32_t count_hi = 0;
     93static unsigned long nextcount;
     94static unsigned long lastcount;
    10895
    109 /** Start hardware clock
    110  *
    111  */
     96/** Start hardware clock */
    11297static void timer_start(void)
    11398{
     
    124109static void timer_irq_handler(irq_t *irq)
    125110{
     111        unsigned long drift;
     112       
    126113        if (cp0_count_read() < lastcount)
    127114                /* Count overflow detected */
    128115                count_hi++;
    129        
    130116        lastcount = cp0_count_read();
    131117       
    132         unsigned long drift = cp0_count_read() - nextcount;
     118        drift = cp0_count_read() - nextcount;
    133119        while (drift > cp0_compare_value) {
    134120                drift -= cp0_compare_value;
    135121                CPU->missed_clock_ticks++;
    136122        }
    137        
    138123        nextcount = cp0_count_read() + cp0_compare_value - drift;
    139124        cp0_compare_write(nextcount);
     
    143128         * Release the lock, call clock() and reacquire the lock again.
    144129         */
    145         irq_spinlock_unlock(&irq->lock, false);
     130        spinlock_unlock(&irq->lock);
    146131        clock();
    147         irq_spinlock_lock(&irq->lock, false);
     132        spinlock_lock(&irq->lock);
    148133       
    149134        if (virtual_timer_fnc != NULL)
    150135                virtual_timer_fnc();
    151 }
    152 
    153 static irq_ownership_t dorder_claim(irq_t *irq)
    154 {
    155         return IRQ_ACCEPT;
    156 }
    157 
    158 static void dorder_irq_handler(irq_t *irq)
    159 {
    160         dorder_ipi_ack(1 << dorder_cpuid());
    161136}
    162137
     
    175150        timer_start();
    176151        cp0_unmask_int(TIMER_IRQ);
    177        
    178         irq_initialize(&dorder_irq);
    179         dorder_irq.devno = device_assign_devno();
    180         dorder_irq.inr = DORDER_IRQ;
    181         dorder_irq.claim = dorder_claim;
    182         dorder_irq.handler = dorder_irq_handler;
    183         irq_register(&dorder_irq);
    184        
    185         cp0_unmask_int(DORDER_IRQ);
    186152}
    187153
Note: See TracChangeset for help on using the changeset viewer.