Ignore:
File:
1 edited

Legend:

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

    rd99c1d2 rda1bafb  
    4949static irq_t timer_irq;
    5050
     51// TODO: This is SMP unsafe!!!
     52
     53uint32_t count_hi = 0;
     54static unsigned long nextcount;
     55static unsigned long lastcount;
     56
    5157/** Disable interrupts.
    5258 *
     
    8995}
    9096
    91 /* TODO: This is SMP unsafe!!! */
    92 uint32_t count_hi = 0;
    93 static unsigned long nextcount;
    94 static unsigned long lastcount;
     97/** Check interrupts state.
     98 *
     99 * @return True if interrupts are disabled.
     100 *
     101 */
     102bool interrupts_disabled(void)
     103{
     104        return !(cp0_status_read() & cp0_status_ie_enabled_bit);
     105}
    95106
    96 /** Start hardware clock */
     107/** Start hardware clock
     108 *
     109 */
    97110static void timer_start(void)
    98111{
     
    109122static void timer_irq_handler(irq_t *irq)
    110123{
    111         unsigned long drift;
    112        
    113124        if (cp0_count_read() < lastcount)
    114125                /* Count overflow detected */
    115126                count_hi++;
     127       
    116128        lastcount = cp0_count_read();
    117129       
    118         drift = cp0_count_read() - nextcount;
     130        unsigned long drift = cp0_count_read() - nextcount;
    119131        while (drift > cp0_compare_value) {
    120132                drift -= cp0_compare_value;
    121133                CPU->missed_clock_ticks++;
    122134        }
     135       
    123136        nextcount = cp0_count_read() + cp0_compare_value - drift;
    124137        cp0_compare_write(nextcount);
     
    128141         * Release the lock, call clock() and reacquire the lock again.
    129142         */
    130         spinlock_unlock(&irq->lock);
     143        irq_spinlock_unlock(&irq->lock, false);
    131144        clock();
    132         spinlock_lock(&irq->lock);
     145        irq_spinlock_lock(&irq->lock, false);
    133146       
    134147        if (virtual_timer_fnc != NULL)
Note: See TracChangeset for help on using the changeset viewer.