Ignore:
File:
1 edited

Legend:

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

    r203deeb8 r0d1e976  
    6363void (* eoi_function)(void) = NULL;
    6464
    65 void decode_istate(istate_t *istate)
    66 {
    67         char *symbol;
    68 
    69         symbol = symtab_fmt_name_lookup(istate->eip);
    70 
    71         if (CPU)
    72                 printf("----------------EXCEPTION OCCURED (cpu%u)----------------\n", CPU->id);
    73         else
    74                 printf("----------------EXCEPTION OCCURED----------------\n");
    75                
    76         printf("%%eip: %#lx (%s)\n", istate->eip, symbol);
    77         printf("ERROR_WORD=%#lx\n", istate->error_word);
    78         printf("%%cs=%#lx,flags=%#lx\n", istate->cs, istate->eflags);
    79         printf("%%eax=%#lx, %%ecx=%#lx, %%edx=%#lx, %%esp=%p\n", istate->eax, istate->ecx, istate->edx, &istate->stack[0]);
    80         printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]);
    81         printf("       %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]);
    82 
    83         stack_trace_istate(istate);
     65void istate_decode(istate_t *istate)
     66{
     67        printf("cs =%p\teip=%p\tefl=%p\terr=%p\n",
     68            istate->cs, istate->eip, istate->eflags, istate->error_word);
     69
     70        printf("ds =%p\tes =%p\tfs =%p\tgs =%p\n",
     71            istate->ds, istate->es, istate->fs, istate->gs);
     72        if (istate_from_uspace(istate))
     73                printf("ss =%p\n", istate->ss);
     74
     75        printf("eax=%p\tebx=%p\tecx=%p\tedx=%p\n",
     76            istate->eax, istate->ebx, istate->ecx, istate->edx);
     77        printf("esi=%p\tedi=%p\tebp=%p\tesp=%p\n",
     78            istate->esi, istate->edi, istate->ebp,
     79            istate_from_uspace(istate) ? istate->esp : (uintptr_t)&istate->esp);
    8480}
    8581
     
    9389}
    9490
    95 static void null_interrupt(int n, istate_t *istate)
    96 {
    97         fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n);
    98 
    99         decode_istate(istate);
    100         panic("Unserviced interrupt: %d.", n);
    101 }
    102 
    103 static void de_fault(int n, istate_t *istate)
     91static void null_interrupt(unsigned int n, istate_t *istate)
     92{
     93        fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n);
     94        panic_badtrap(istate, n, "Unserviced interrupt: %u.", n);
     95}
     96
     97static void de_fault(unsigned int n, istate_t *istate)
    10498{
    10599        fault_if_from_uspace(istate, "Divide error.");
    106 
    107         decode_istate(istate);
    108         panic("Divide error.");
     100        panic_badtrap(istate, n, "Divide error.");
    109101}
    110102
    111103/** General Protection Fault. */
    112 static void gp_fault(int n __attribute__((unused)), istate_t *istate)
     104static void gp_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    113105{
    114106        if (TASK) {
    115                 size_t ver;
     107                irq_spinlock_lock(&TASK->lock, false);
     108                size_t ver = TASK->arch.iomapver;
     109                irq_spinlock_unlock(&TASK->lock, false);
    116110               
    117                 spinlock_lock(&TASK->lock);
    118                 ver = TASK->arch.iomapver;
    119                 spinlock_unlock(&TASK->lock);
    120        
    121111                if (CPU->arch.iomapver_copy != ver) {
    122112                        /*
     
    132122                fault_if_from_uspace(istate, "General protection fault.");
    133123        }
    134 
    135         decode_istate(istate);
    136         panic("General protection fault.");
    137 }
    138 
    139 static void ss_fault(int n __attribute__((unused)), istate_t *istate)
     124        panic_badtrap(istate, n, "General protection fault.");
     125}
     126
     127static void ss_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    140128{
    141129        fault_if_from_uspace(istate, "Stack fault.");
    142 
    143         decode_istate(istate);
    144         panic("Stack fault.");
    145 }
    146 
    147 static void simd_fp_exception(int n __attribute__((unused)), istate_t *istate)
     130        panic_badtrap(istate, n, "Stack fault.");
     131}
     132
     133static void simd_fp_exception(unsigned int n __attribute__((unused)), istate_t *istate)
    148134{
    149135        uint32_t mxcsr;
    150         asm (
     136        asm volatile (
    151137                "stmxcsr %[mxcsr]\n"
    152138                : [mxcsr] "=m" (mxcsr)
    153139        );
    154         fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx.",
     140       
     141        fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0.8x.",
    155142            (unative_t) mxcsr);
    156        
    157         decode_istate(istate);
    158         printf("MXCSR: %#lx\n", mxcsr);
    159         panic("SIMD FP exception(19).");
    160 }
    161 
    162 static void nm_fault(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
    163 {
    164 #ifdef CONFIG_FPU_LAZY     
     143        panic_badtrap(istate, n, "SIMD FP exception, MXCSR=%#0.8x");
     144}
     145
     146static void nm_fault(unsigned int n __attribute__((unused)),
     147    istate_t *istate __attribute__((unused)))
     148{
     149#ifdef CONFIG_FPU_LAZY
    165150        scheduler_fpu_lazy_request();
    166151#else
    167152        fault_if_from_uspace(istate, "FPU fault.");
    168         panic("FPU fault.");
     153        panic_badtrap(istate, n, "FPU fault.");
    169154#endif
    170155}
    171156
    172157#ifdef CONFIG_SMP
    173 static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
     158static void tlb_shootdown_ipi(unsigned int n __attribute__((unused)),
     159    istate_t *istate __attribute__((unused)))
    174160{
    175161        trap_virtual_eoi();
     
    179165
    180166/** Handler of IRQ exceptions */
    181 static void irq_interrupt(int n, istate_t *istate __attribute__((unused)))
     167static void irq_interrupt(unsigned int n, istate_t *istate __attribute__((unused)))
    182168{
    183169        ASSERT(n >= IVT_IRQBASE);
    184170       
    185         int inum = n - IVT_IRQBASE;
     171        unsigned int inum = n - IVT_IRQBASE;
    186172        bool ack = false;
    187173        ASSERT(inum < IRQ_COUNT);
     
    193179                 * The IRQ handler was found.
    194180                 */
    195                  
     181               
    196182                if (irq->preack) {
    197183                        /* Send EOI before processing the interrupt */
     
    200186                }
    201187                irq->handler(irq);
    202                 spinlock_unlock(&irq->lock);
     188                irq_spinlock_unlock(&irq->lock, false);
    203189        } else {
    204190                /*
     
    206192                 */
    207193#ifdef CONFIG_DEBUG
    208                 printf("cpu%u: spurious interrupt (inum=%d)\n", CPU->id, inum);
     194                printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
    209195#endif
    210196        }
     
    216202void interrupt_init(void)
    217203{
    218         int i;
     204        unsigned int i;
    219205       
    220206        for (i = 0; i < IVT_ITEMS; i++)
    221                 exc_register(i, "null", (iroutine) null_interrupt);
     207                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    222208       
    223209        for (i = 0; i < IRQ_COUNT; i++) {
    224210                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    225                         exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
     211                        exc_register(IVT_IRQBASE + i, "irq", true,
     212                            (iroutine_t) irq_interrupt);
    226213        }
    227214       
    228         exc_register(0, "de_fault", (iroutine) de_fault);
    229         exc_register(7, "nm_fault", (iroutine) nm_fault);
    230         exc_register(12, "ss_fault", (iroutine) ss_fault);
    231         exc_register(13, "gp_fault", (iroutine) gp_fault);
    232         exc_register(19, "simd_fp", (iroutine) simd_fp_exception);
     215        exc_register(0, "de_fault", true, (iroutine_t) de_fault);
     216        exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
     217        exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
     218        exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     219        exc_register(19, "simd_fp", true, (iroutine_t) simd_fp_exception);
    233220       
    234221#ifdef CONFIG_SMP
    235         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
     222        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
     223            (iroutine_t) tlb_shootdown_ipi);
    236224#endif
    237225}
Note: See TracChangeset for help on using the changeset viewer.