Changeset ec04b20 in mainline for kernel/arch/ia32xen/src/interrupt.c


Ignore:
Timestamp:
2006-10-27T13:56:25Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
410ed0d
Parents:
8607db8
Message:

ia32xen: adopt new IRQ interface

File:
1 edited

Legend:

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

    r8607db8 rec04b20  
    5151#include <ipc/sysipc.h>
    5252#include <interrupt.h>
     53#include <ddi/irq.h>
    5354
    5455/*
     
    6061void (* eoi_function)(void) = NULL;
    6162
    62 void PRINT_INFO_ERRCODE(istate_t *istate)
     63void decode_istate(istate_t *istate)
    6364{
    6465        char *symbol = get_symtab_entry(istate->eip);
     
    8384}
    8485
    85 void null_interrupt(int n, istate_t *istate)
     86static void trap_virtual_eoi(void)
     87{
     88        if (eoi_function)
     89                eoi_function();
     90        else
     91                panic("no eoi_function\n");
     92
     93}
     94
     95static void null_interrupt(int n, istate_t *istate)
    8696{
    8797        fault_if_from_uspace(istate, "unserviced interrupt: %d", n);
    8898
    89         PRINT_INFO_ERRCODE(istate);
     99        decode_istate(istate);
    90100        panic("unserviced interrupt: %d\n", n);
    91101}
    92102
    93103/** General Protection Fault. */
    94 void gp_fault(int n, istate_t *istate)
     104static void gp_fault(int n, istate_t *istate)
    95105{
    96106        if (TASK) {
     
    115125        }
    116126
    117         PRINT_INFO_ERRCODE(istate);
     127        decode_istate(istate);
    118128        panic("general protection fault\n");
    119129}
    120130
    121 void ss_fault(int n, istate_t *istate)
     131static void ss_fault(int n, istate_t *istate)
    122132{
    123133        fault_if_from_uspace(istate, "stack fault");
    124134
    125         PRINT_INFO_ERRCODE(istate);
     135        decode_istate(istate);
    126136        panic("stack fault\n");
    127137}
    128138
    129 void simd_fp_exception(int n, istate_t *istate)
     139static void simd_fp_exception(int n, istate_t *istate)
    130140{
    131141        uint32_t mxcsr;
     
    138148                             (unative_t)mxcsr);
    139149
    140         PRINT_INFO_ERRCODE(istate);
     150        decode_istate(istate);
    141151        printf("MXCSR: %#zx\n",(unative_t)(mxcsr));
    142152        panic("SIMD FP exception(19)\n");
    143153}
    144154
    145 void nm_fault(int n, istate_t *istate)
     155static void nm_fault(int n, istate_t *istate)
    146156{
    147157#ifdef CONFIG_FPU_LAZY     
     
    153163}
    154164
    155 void syscall(int n, istate_t *istate)
    156 {
    157         panic("Obsolete syscall handler.");
    158 }
    159 
    160 void tlb_shootdown_ipi(int n, istate_t *istate)
     165#ifdef CONFIG_SMP
     166static void tlb_shootdown_ipi(int n, istate_t *istate)
    161167{
    162168        trap_virtual_eoi();
    163169        tlb_shootdown_ipi_recv();
    164170}
     171#endif
     172
     173/** Handler of IRQ exceptions */
     174static void irq_interrupt(int n, istate_t *istate)
     175{
     176        ASSERT(n >= IVT_IRQBASE);
     177       
     178        int inum = n - IVT_IRQBASE;
     179        ASSERT(inum < IRQ_COUNT);
     180        ASSERT((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
     181
     182        irq_t *irq = irq_dispatch_and_lock(inum);
     183        if (irq) {
     184                /*
     185                 * The IRQ handler was found.
     186                 */
     187                irq->handler(irq, irq->arg);
     188                spinlock_unlock(&irq->lock);
     189        } else {
     190                /*
     191                 * Spurious interrupt.
     192                 */
     193#ifdef CONFIG_DEBUG
     194                printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
     195#endif
     196        }
     197        trap_virtual_eoi();
     198}
     199
     200void interrupt_init(void)
     201{
     202        int i;
     203       
     204        for (i = 0; i < IVT_ITEMS; i++)
     205                exc_register(i, "null", (iroutine) null_interrupt);
     206       
     207        for (i = 0; i < IRQ_COUNT; i++) {
     208                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     209                        exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
     210        }
     211       
     212        exc_register(7, "nm_fault", (iroutine) nm_fault);
     213        exc_register(12, "ss_fault", (iroutine) ss_fault);
     214        exc_register(13, "gp_fault", (iroutine) gp_fault);
     215        exc_register(19, "simd_fp", (iroutine) simd_fp_exception);
     216       
     217#ifdef CONFIG_SMP
     218        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
     219#endif
     220}
    165221
    166222void trap_virtual_enable_irqs(uint16_t irqmask)
     
    180236}
    181237
    182 void trap_virtual_eoi(void)
    183 {
    184         if (eoi_function)
    185                 eoi_function();
    186         else
    187                 panic("no eoi_function\n");
    188 
    189 }
    190 
    191238/** @}
    192239 */
Note: See TracChangeset for help on using the changeset viewer.