Ignore:
File:
1 edited

Legend:

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

    r203deeb8 r7e752b2  
    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 =%#0" PRIx32 "\teip=%p\t"
     68            "efl=%#0" PRIx32 "\terr=%#0" PRIx32 "\n",
     69            istate->cs, (void *) istate->eip,
     70            istate->eflags, istate->error_word);
     71       
     72        printf("ds =%#0" PRIx32 "\tes =%#0" PRIx32 "\t"
     73            "fs =%#0" PRIx32 "\tgs =%#0" PRIx32 "\n",
     74            istate->ds, istate->es, istate->fs, istate->gs);
     75       
     76        if (istate_from_uspace(istate))
     77                printf("ss =%#0" PRIx32 "\n", istate->ss);
     78       
     79        printf("eax=%#0" PRIx32 "\tebx=%#0" PRIx32 "\t"
     80            "ecx=%#0" PRIx32 "\tedx=%#0" PRIx32 "\n",
     81            istate->eax, istate->ebx, istate->ecx, istate->edx);
     82       
     83        printf("esi=%p\tedi=%p\tebp=%p\tesp=%p\n",
     84            (void *) istate->esi, (void *) istate->edi,
     85            (void *) istate->ebp,
     86            istate_from_uspace(istate) ? ((void *) istate->esp) :
     87            &istate->esp);
    8488}
    8589
     
    9397}
    9498
    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)
     99static void null_interrupt(unsigned int n, istate_t *istate)
     100{
     101        fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n);
     102        panic_badtrap(istate, n, "Unserviced interrupt: %u.", n);
     103}
     104
     105static void de_fault(unsigned int n, istate_t *istate)
    104106{
    105107        fault_if_from_uspace(istate, "Divide error.");
    106 
    107         decode_istate(istate);
    108         panic("Divide error.");
     108        panic_badtrap(istate, n, "Divide error.");
    109109}
    110110
    111111/** General Protection Fault. */
    112 static void gp_fault(int n __attribute__((unused)), istate_t *istate)
     112static void gp_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    113113{
    114114        if (TASK) {
    115                 size_t ver;
     115                irq_spinlock_lock(&TASK->lock, false);
     116                size_t ver = TASK->arch.iomapver;
     117                irq_spinlock_unlock(&TASK->lock, false);
    116118               
    117                 spinlock_lock(&TASK->lock);
    118                 ver = TASK->arch.iomapver;
    119                 spinlock_unlock(&TASK->lock);
    120        
    121119                if (CPU->arch.iomapver_copy != ver) {
    122120                        /*
     
    132130                fault_if_from_uspace(istate, "General protection fault.");
    133131        }
    134 
    135         decode_istate(istate);
    136         panic("General protection fault.");
    137 }
    138 
    139 static void ss_fault(int n __attribute__((unused)), istate_t *istate)
     132        panic_badtrap(istate, n, "General protection fault.");
     133}
     134
     135static void ss_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    140136{
    141137        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)
     138        panic_badtrap(istate, n, "Stack fault.");
     139}
     140
     141static void simd_fp_exception(unsigned int n __attribute__((unused)), istate_t *istate)
    148142{
    149143        uint32_t mxcsr;
    150         asm (
     144        asm volatile (
    151145                "stmxcsr %[mxcsr]\n"
    152146                : [mxcsr] "=m" (mxcsr)
    153147        );
    154         fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx.",
    155             (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     
     148       
     149        fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0" PRIx32 ".",
     150            mxcsr);
     151        panic_badtrap(istate, n, "SIMD FP exception");
     152}
     153
     154static void nm_fault(unsigned int n __attribute__((unused)),
     155    istate_t *istate __attribute__((unused)))
     156{
     157#ifdef CONFIG_FPU_LAZY
    165158        scheduler_fpu_lazy_request();
    166159#else
    167160        fault_if_from_uspace(istate, "FPU fault.");
    168         panic("FPU fault.");
     161        panic_badtrap(istate, n, "FPU fault.");
    169162#endif
    170163}
    171164
    172165#ifdef CONFIG_SMP
    173 static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
     166static void tlb_shootdown_ipi(unsigned int n __attribute__((unused)),
     167    istate_t *istate __attribute__((unused)))
    174168{
    175169        trap_virtual_eoi();
     
    179173
    180174/** Handler of IRQ exceptions */
    181 static void irq_interrupt(int n, istate_t *istate __attribute__((unused)))
     175static void irq_interrupt(unsigned int n, istate_t *istate __attribute__((unused)))
    182176{
    183177        ASSERT(n >= IVT_IRQBASE);
    184178       
    185         int inum = n - IVT_IRQBASE;
     179        unsigned int inum = n - IVT_IRQBASE;
    186180        bool ack = false;
    187181        ASSERT(inum < IRQ_COUNT);
     
    193187                 * The IRQ handler was found.
    194188                 */
    195                  
     189               
    196190                if (irq->preack) {
    197191                        /* Send EOI before processing the interrupt */
     
    200194                }
    201195                irq->handler(irq);
    202                 spinlock_unlock(&irq->lock);
     196                irq_spinlock_unlock(&irq->lock, false);
    203197        } else {
    204198                /*
     
    206200                 */
    207201#ifdef CONFIG_DEBUG
    208                 printf("cpu%u: spurious interrupt (inum=%d)\n", CPU->id, inum);
     202                printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
    209203#endif
    210204        }
     
    216210void interrupt_init(void)
    217211{
    218         int i;
     212        unsigned int i;
    219213       
    220214        for (i = 0; i < IVT_ITEMS; i++)
    221                 exc_register(i, "null", (iroutine) null_interrupt);
     215                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    222216       
    223217        for (i = 0; i < IRQ_COUNT; i++) {
    224218                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    225                         exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
     219                        exc_register(IVT_IRQBASE + i, "irq", true,
     220                            (iroutine_t) irq_interrupt);
    226221        }
    227222       
    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);
     223        exc_register(0, "de_fault", true, (iroutine_t) de_fault);
     224        exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
     225        exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
     226        exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     227        exc_register(19, "simd_fp", true, (iroutine_t) simd_fp_exception);
    233228       
    234229#ifdef CONFIG_SMP
    235         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
     230        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
     231            (iroutine_t) tlb_shootdown_ipi);
    236232#endif
    237233}
Note: See TracChangeset for help on using the changeset viewer.