Changes in kernel/arch/mips32/src/interrupt.c [d99c1d2:2b698d8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/interrupt.c
rd99c1d2 r2b698d8 38 38 #include <arch.h> 39 39 #include <arch/cp0.h> 40 #include <arch/smp/dorder.h> 40 41 #include <time/clock.h> 41 42 #include <ipc/sysipc.h> … … 48 49 function virtual_timer_fnc = NULL; 49 50 static 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; 50 58 51 59 /** Disable interrupts. … … 89 97 } 90 98 91 /* TODO: This is SMP unsafe!!! */ 92 uint32_t count_hi = 0; 93 static unsigned long nextcount; 94 static unsigned long lastcount; 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 } 95 108 96 /** Start hardware clock */ 109 /** Start hardware clock 110 * 111 */ 97 112 static void timer_start(void) 98 113 { … … 109 124 static void timer_irq_handler(irq_t *irq) 110 125 { 111 unsigned long drift;112 113 126 if (cp0_count_read() < lastcount) 114 127 /* Count overflow detected */ 115 128 count_hi++; 129 116 130 lastcount = cp0_count_read(); 117 131 118 drift = cp0_count_read() - nextcount;132 unsigned long drift = cp0_count_read() - nextcount; 119 133 while (drift > cp0_compare_value) { 120 134 drift -= cp0_compare_value; 121 135 CPU->missed_clock_ticks++; 122 136 } 137 123 138 nextcount = cp0_count_read() + cp0_compare_value - drift; 124 139 cp0_compare_write(nextcount); … … 128 143 * Release the lock, call clock() and reacquire the lock again. 129 144 */ 130 spinlock_unlock(&irq->lock);145 irq_spinlock_unlock(&irq->lock, false); 131 146 clock(); 132 spinlock_lock(&irq->lock);147 irq_spinlock_lock(&irq->lock, false); 133 148 134 149 if (virtual_timer_fnc != NULL) 135 150 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()); 136 161 } 137 162 … … 150 175 timer_start(); 151 176 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); 152 186 } 153 187
Note:
See TracChangeset
for help on using the changeset viewer.