Ignore:
File:
1 edited

Legend:

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

    r2a103b5 rd19b3fc  
    3737#include <log.h>
    3838#include <panic.h>
    39 #include <genarch/drivers/i8259/i8259.h>
    40 #include <genarch/pic/pic_ops.h>
     39#include <arch/drivers/i8259.h>
    4140#include <halt.h>
    4241#include <cpu.h>
     
    5857 * Interrupt and exception dispatching.
    5958 */
    60 pic_ops_t *pic_ops = NULL;
     59
     60void (*disable_irqs_function)(uint16_t irqmask) = NULL;
     61void (*enable_irqs_function)(uint16_t irqmask) = NULL;
     62void (*eoi_function)(void) = NULL;
     63const char *irqs_info = NULL;
    6164
    6265void istate_decode(istate_t *istate)
     
    8689            "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n",
    8790            istate->r12, istate->r13, istate->r14, istate->r15);
     91}
     92
     93static void trap_virtual_eoi(void)
     94{
     95        if (eoi_function)
     96                eoi_function();
     97        else
     98                panic("No eoi_function.");
     99
    88100}
    89101
     
    145157static void tlb_shootdown_ipi(unsigned int n, istate_t *istate)
    146158{
    147         pic_ops->eoi(0);
     159        trap_virtual_eoi();
    148160        tlb_shootdown_ipi_recv();
    149161}
     
    160172        bool ack = false;
    161173        assert(inum < IRQ_COUNT);
    162         assert(inum != IRQ_PIC1);
     174        assert((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
    163175
    164176        irq_t *irq = irq_dispatch_and_lock(inum);
     
    170182                if (irq->preack) {
    171183                        /* Send EOI before processing the interrupt */
    172                         pic_ops->eoi(inum);
     184                        trap_virtual_eoi();
    173185                        ack = true;
    174186                }
     
    176188                irq_spinlock_unlock(&irq->lock, false);
    177189        } else {
     190                /*
     191                 * Spurious interrupt.
     192                 */
    178193#ifdef CONFIG_DEBUG
    179                 log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ %u", CPU->id,
    180                     inum);
     194                log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt (inum=%u)",
     195                    CPU->id, inum);
    181196#endif
    182197        }
    183198
    184199        if (!ack)
    185                 pic_ops->eoi(inum);
    186 }
    187 
    188 static void pic_spurious(unsigned int n, istate_t *istate)
    189 {
    190         unsigned int inum = n - IVT_IRQBASE;
    191         if (!pic_ops->is_spurious(inum)) {
    192                 /* This is actually not a spurious IRQ, so proceed as usual. */
    193                 irq_interrupt(n, istate);
    194                 return;
    195         }
    196         pic_ops->handle_spurious(n);
    197 #ifdef CONFIG_DEBUG
    198         log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id,
    199             inum);
    200 #endif
     200                trap_virtual_eoi();
    201201}
    202202
     
    209209
    210210        for (i = 0; i < IRQ_COUNT; i++) {
    211                 if ((i != IRQ_PIC0_SPUR) && (i != IRQ_PIC1_SPUR) &&
    212                     (i != IRQ_PIC1))
     211                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    213212                        exc_register(IVT_IRQBASE + i, "irq", true,
    214213                            (iroutine_t) irq_interrupt);
     
    219218        exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault);
    220219        exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault);
    221         exc_register(VECTOR_PIC0_SPUR, "pic0_spurious", true,
    222             (iroutine_t) pic_spurious);
    223         exc_register(VECTOR_PIC1_SPUR, "pic1_spurious", true,
    224             (iroutine_t) pic_spurious);
    225220
    226221#ifdef CONFIG_SMP
     
    230225}
    231226
     227void trap_virtual_enable_irqs(uint16_t irqmask)
     228{
     229        if (enable_irqs_function)
     230                enable_irqs_function(irqmask);
     231        else
     232                panic("No enable_irqs_function.");
     233}
     234
     235void trap_virtual_disable_irqs(uint16_t irqmask)
     236{
     237        if (disable_irqs_function)
     238                disable_irqs_function(irqmask);
     239        else
     240                panic("No disable_irqs_function.");
     241}
     242
    232243/** @}
    233244 */
Note: See TracChangeset for help on using the changeset viewer.