Changeset 8607db8 in mainline for kernel/arch/amd64/src/interrupt.c


Ignore:
Timestamp:
2006-10-27T13:34:20Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ec04b20
Parents:
16d71f41
Message:

amd64: adopt new IRQ interface

File:
1 edited

Legend:

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

    r16d71f41 r8607db8  
    5252#include <arch/ddi/ddi.h>
    5353#include <interrupt.h>
    54 #include <ipc/irq.h>
    55 
    56 void print_info_errcode(int n, istate_t *istate)
     54#include <ddi/irq.h>
     55
     56/*
     57 * Interrupt and exception dispatching.
     58 */
     59
     60void (* disable_irqs_function)(uint16_t irqmask) = NULL;
     61void (* enable_irqs_function)(uint16_t irqmask) = NULL;
     62void (* eoi_function)(void) = NULL;
     63
     64void decode_istate(int n, istate_t *istate)
    5765{
    5866        char *symbol;
     
    7684}
    7785
    78 /*
    79  * Interrupt and exception dispatching.
    80  */
    81 
    82 void (* disable_irqs_function)(uint16_t irqmask) = NULL;
    83 void (* enable_irqs_function)(uint16_t irqmask) = NULL;
    84 void (* eoi_function)(void) = NULL;
    85 
    86 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)
    8796{
    8897        fault_if_from_uspace(istate, "unserviced interrupt: %d", n);
    89         print_info_errcode(n, istate);
     98        decode_istate(n, istate);
    9099        panic("unserviced interrupt\n");
    91100}
    92101
    93102/** General Protection Fault. */
    94 void gp_fault(int n, istate_t *istate)
     103static void gp_fault(int n, istate_t *istate)
    95104{
    96105        if (TASK) {
     
    115124        }
    116125
    117         print_info_errcode(n, istate);
     126        decode_istate(n, istate);
    118127        panic("general protection fault\n");
    119128}
    120129
    121 void ss_fault(int n, istate_t *istate)
     130static void ss_fault(int n, istate_t *istate)
    122131{
    123132        fault_if_from_uspace(istate, "stack fault");
    124         print_info_errcode(n, istate);
     133        decode_istate(n, istate);
    125134        panic("stack fault\n");
    126135}
    127136
    128 void nm_fault(int n, istate_t *istate)
     137static void nm_fault(int n, istate_t *istate)
    129138{
    130139#ifdef CONFIG_FPU_LAZY     
     
    136145}
    137146
    138 void tlb_shootdown_ipi(int n, istate_t *istate)
     147static void tlb_shootdown_ipi(int n, istate_t *istate)
    139148{
    140149        trap_virtual_eoi();
    141150        tlb_shootdown_ipi_recv();
     151}
     152
     153/** Handler of IRQ exceptions */
     154static void irq_interrupt(int n, istate_t *istate)
     155{
     156        ASSERT(n >= IVT_IRQBASE);
     157       
     158        int inum = n - IVT_IRQBASE;
     159        ASSERT(inum < IRQ_COUNT);
     160        ASSERT((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
     161
     162        irq_t *irq = irq_dispatch_and_lock(inum);
     163        if (irq) {
     164                /*
     165                 * The IRQ handler was found.
     166                 */
     167                irq->handler(irq, irq->arg);
     168                spinlock_unlock(&irq->lock);
     169        } else {
     170                /*
     171                 * Spurious interrupt.
     172                 */
     173#ifdef CONFIG_DEBUG
     174                printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
     175#endif
     176        }
     177        trap_virtual_eoi();
     178}
     179
     180void interrupt_init(void)
     181{
     182        int i;
     183       
     184        for (i = 0; i < IVT_ITEMS; i++)
     185                exc_register(i, "null", (iroutine) null_interrupt);
     186       
     187        for (i = 0; i < IRQ_COUNT; i++) {
     188                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     189                        exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
     190        }
     191       
     192        exc_register(7, "nm_fault", (iroutine) nm_fault);
     193        exc_register(12, "ss_fault", (iroutine) ss_fault);
     194        exc_register(13, "gp_fault", (iroutine) gp_fault);
     195        exc_register(14, "ident_mapper", (iroutine) ident_page_fault);
     196       
     197#ifdef CONFIG_SMP
     198        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
     199#endif
    142200}
    143201
     
    158216}
    159217
    160 void trap_virtual_eoi(void)
    161 {
    162         if (eoi_function)
    163                 eoi_function();
    164         else
    165                 panic("no eoi_function\n");
    166 
    167 }
    168 
    169218/** @}
    170219 */
Note: See TracChangeset for help on using the changeset viewer.