Subversion Repositories HelenOS

Rev

Rev 2927 | Rev 4338 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2927 Rev 3674
Line 51... Line 51...
51
#include <proc/scheduler.h>
51
#include <proc/scheduler.h>
52
#include <ipc/sysipc.h>
52
#include <ipc/sysipc.h>
53
#include <ipc/irq.h>
53
#include <ipc/irq.h>
54
#include <ipc/ipc.h>
54
#include <ipc/ipc.h>
55
#include <synch/spinlock.h>
55
#include <synch/spinlock.h>
-
 
56
#include <mm/tlb.h>
56
 
57
 
57
#define VECTORS_64_BUNDLE   20
58
#define VECTORS_64_BUNDLE   20
58
#define VECTORS_16_BUNDLE   48
59
#define VECTORS_16_BUNDLE   48
59
#define VECTORS_16_BUNDLE_START 0x5000
60
#define VECTORS_16_BUNDLE_START 0x5000
60
#define VECTOR_MAX      0x7f00
61
#define VECTOR_MAX      0x7f00
Line 232... Line 233...
232
    dump_interrupted_context(istate);
233
    dump_interrupted_context(istate);
233
    panic("Interruption: %#hx (%s)\n", (uint16_t) vector,
234
    panic("Interruption: %#hx (%s)\n", (uint16_t) vector,
234
        vector_to_string(vector));
235
        vector_to_string(vector));
235
}
236
}
236
 
237
 
-
 
238
static void end_of_local_irq(void)
-
 
239
{
-
 
240
    asm volatile ("mov cr.eoi=r0;;");
-
 
241
}
-
 
242
 
-
 
243
 
237
void external_interrupt(uint64_t vector, istate_t *istate)
244
void external_interrupt(uint64_t vector, istate_t *istate)
238
{
245
{
239
    irq_t *irq;
-
 
240
    cr_ivr_t ivr;
246
    cr_ivr_t ivr;
241
   
247
   
242
    ivr.value = ivr_read();
248
    ivr.value = ivr_read();
243
    srlz_d();
249
    srlz_d();
244
 
250
 
245
    irq = irq_dispatch_and_lock(ivr.vector);
-
 
246
    if (irq) {
-
 
247
        irq->handler(irq, irq->arg);
-
 
248
        spinlock_unlock(&irq->lock);
-
 
249
    } else {
-
 
250
        switch (ivr.vector) {
251
        switch (ivr.vector) {
251
        case INTERRUPT_SPURIOUS:
252
        case INTERRUPT_SPURIOUS:
252
#ifdef CONFIG_DEBUG
253
#ifdef CONFIG_DEBUG
253
            printf("cpu%d: spurious interrupt\n", CPU->id);
254
            printf("cpu%d: spurious interrupt\n", CPU->id);
254
#endif
255
#endif
255
            break;
256
            break;
256
 
257
 
-
 
258
#ifdef CONFIG_SMP
-
 
259
        case VECTOR_TLB_SHOOTDOWN_IPI:
-
 
260
            tlb_shootdown_ipi_recv();
-
 
261
            end_of_local_irq();
-
 
262
            break;
-
 
263
#endif
-
 
264
 
-
 
265
        case INTERRUPT_TIMER:
-
 
266
            {
-
 
267
 
-
 
268
                irq_t *irq = irq_dispatch_and_lock(ivr.vector);
-
 
269
                if (irq) {
-
 
270
                    irq->handler(irq, irq->arg);
-
 
271
                    spinlock_unlock(&irq->lock);
-
 
272
                } else {
-
 
273
                    panic("\nUnhandled Internal Timer Interrupt (%d)\n",ivr.vector);
-
 
274
                }
-
 
275
            }  
-
 
276
            break;
-
 
277
               
257
        default:
278
        default:
-
 
279
            {
-
 
280
 
-
 
281
                int ack=false;
-
 
282
                irq_t *irq = irq_dispatch_and_lock(ivr.vector);
-
 
283
                if (irq) {
-
 
284
                    /*
-
 
285
                     * The IRQ handler was found.
-
 
286
                     */
-
 
287
         
-
 
288
                    if (irq->preack) {
-
 
289
                        /* Send EOI before processing the interrupt */
-
 
290
                        end_of_local_irq();
-
 
291
                        ack=true;
-
 
292
                    }
-
 
293
                    irq->handler(irq, irq->arg);
-
 
294
                    spinlock_unlock(&irq->lock);
-
 
295
                } else {
-
 
296
                    /*
-
 
297
                     * Unhandled interrupt.
-
 
298
                     */
-
 
299
                    end_of_local_irq();
-
 
300
                    ack=true;
-
 
301
#ifdef CONFIG_DEBUG
258
            panic("\nUnhandled External Interrupt Vector %d\n",
302
                    printf("\nUnhandled External Interrupt Vector %d\n",ivr.vector);
-
 
303
#endif
-
 
304
                }
259
                ivr.vector);
305
                if(!ack) end_of_local_irq();
-
 
306
 
-
 
307
            }  
-
 
308
 
-
 
309
 
260
            break;
310
            break;
261
        }
311
        }
262
    }
-
 
263
}
312
}
264
 
313
 
265
/** @}
314
/** @}
266
 */
315
 */