Changeset 2a103b5 in mainline for kernel/arch/ia32/src/interrupt.c


Ignore:
Timestamp:
2019-06-09T11:31:38Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c48de91
Parents:
b401b33
Message:

Introduce PIC operations indirection mechanism

Some architectures switch from one interrupt controller implementation
to another during runtime. By providing a cleaner indirection mechanism,
it is possible e.g. for the ia32 IRQ 7 handler to distinguish i8259
spurious interrupts from actual IRQ 7 device interrupts, even when the
i8259 interrupt controller is no longer active.

File:
1 edited

Legend:

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

    rb401b33 r2a103b5  
    4040#include <panic.h>
    4141#include <genarch/drivers/i8259/i8259.h>
     42#include <genarch/pic/pic_ops.h>
    4243#include <halt.h>
    4344#include <cpu.h>
     
    6162 */
    6263
    63 void (*disable_irqs_function)(uint16_t irqmask) = NULL;
    64 void (*enable_irqs_function)(uint16_t irqmask) = NULL;
    65 void (*eoi_function)(unsigned int) = NULL;
    66 const char *irqs_info = NULL;
     64pic_ops_t *pic_ops = NULL;
    6765
    6866void istate_decode(istate_t *istate)
     
    8886            istate_from_uspace(istate) ? istate->esp :
    8987            (uint32_t) &istate->esp);
    90 }
    91 
    92 static void trap_virtual_eoi(unsigned int inum)
    93 {
    94         if (eoi_function)
    95                 eoi_function(inum);
    96         else
    97                 panic("No eoi_function.");
    98 
    9988}
    10089
     
    179168    istate_t *istate __attribute__((unused)))
    180169{
    181         trap_virtual_eoi(0);
     170        pic_ops->eoi(0);
    182171        tlb_shootdown_ipi_recv();
    183172}
     
    202191                if (irq->preack) {
    203192                        /* Send EOI before processing the interrupt */
    204                         trap_virtual_eoi(inum);
     193                        pic_ops->eoi(inum);
    205194                        ack = true;
    206195                }
     
    215204
    216205        if (!ack)
    217                 trap_virtual_eoi(inum);
     206                pic_ops->eoi(inum);
    218207}
    219208
     
    221210{
    222211        unsigned int inum = n - IVT_IRQBASE;
    223         if (!pic_is_spurious(inum)) {
     212        if (!pic_ops->is_spurious(inum)) {
    224213                /* This is actually not a spurious IRQ, so proceed as usual. */
    225214                irq_interrupt(n, istate);
    226215                return;
    227216        }
    228         pic_handle_spurious(n);
     217        pic_ops->handle_spurious(n);
    229218#ifdef CONFIG_DEBUG
    230219        log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id,
     
    264253}
    265254
    266 void trap_virtual_enable_irqs(uint16_t irqmask)
    267 {
    268         if (enable_irqs_function)
    269                 enable_irqs_function(irqmask);
    270         else
    271                 panic("No enable_irqs_function.");
    272 }
    273 
    274 void trap_virtual_disable_irqs(uint16_t irqmask)
    275 {
    276         if (disable_irqs_function)
    277                 disable_irqs_function(irqmask);
    278         else
    279                 panic("No disable_irqs_function.");
    280 }
    281 
    282255/** @}
    283256 */
Note: See TracChangeset for help on using the changeset viewer.