Ignore:
File:
1 edited

Legend:

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

    r7e752b2 r203deeb8  
    6363void (* eoi_function)(void) = NULL;
    6464
    65 void 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);
     65void 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);
    8884}
    8985
     
    9793}
    9894
    99 static 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 
    105 static void de_fault(unsigned int n, istate_t *istate)
     95static 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
     103static void de_fault(int n, istate_t *istate)
    106104{
    107105        fault_if_from_uspace(istate, "Divide error.");
    108         panic_badtrap(istate, n, "Divide error.");
     106
     107        decode_istate(istate);
     108        panic("Divide error.");
    109109}
    110110
    111111/** General Protection Fault. */
    112 static void gp_fault(unsigned int n __attribute__((unused)), istate_t *istate)
     112static void gp_fault(int n __attribute__((unused)), istate_t *istate)
    113113{
    114114        if (TASK) {
    115                 irq_spinlock_lock(&TASK->lock, false);
    116                 size_t ver = TASK->arch.iomapver;
    117                 irq_spinlock_unlock(&TASK->lock, false);
     115                size_t ver;
    118116               
     117                spinlock_lock(&TASK->lock);
     118                ver = TASK->arch.iomapver;
     119                spinlock_unlock(&TASK->lock);
     120       
    119121                if (CPU->arch.iomapver_copy != ver) {
    120122                        /*
     
    130132                fault_if_from_uspace(istate, "General protection fault.");
    131133        }
    132         panic_badtrap(istate, n, "General protection fault.");
    133 }
    134 
    135 static void ss_fault(unsigned int n __attribute__((unused)), istate_t *istate)
     134
     135        decode_istate(istate);
     136        panic("General protection fault.");
     137}
     138
     139static void ss_fault(int n __attribute__((unused)), istate_t *istate)
    136140{
    137141        fault_if_from_uspace(istate, "Stack fault.");
    138         panic_badtrap(istate, n, "Stack fault.");
    139 }
    140 
    141 static void simd_fp_exception(unsigned int n __attribute__((unused)), istate_t *istate)
     142
     143        decode_istate(istate);
     144        panic("Stack fault.");
     145}
     146
     147static void simd_fp_exception(int n __attribute__((unused)), istate_t *istate)
    142148{
    143149        uint32_t mxcsr;
    144         asm volatile (
     150        asm (
    145151                "stmxcsr %[mxcsr]\n"
    146152                : [mxcsr] "=m" (mxcsr)
    147153        );
    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 
    154 static void nm_fault(unsigned int n __attribute__((unused)),
    155     istate_t *istate __attribute__((unused)))
    156 {
    157 #ifdef CONFIG_FPU_LAZY
     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
     162static void nm_fault(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
     163{
     164#ifdef CONFIG_FPU_LAZY     
    158165        scheduler_fpu_lazy_request();
    159166#else
    160167        fault_if_from_uspace(istate, "FPU fault.");
    161         panic_badtrap(istate, n, "FPU fault.");
     168        panic("FPU fault.");
    162169#endif
    163170}
    164171
    165172#ifdef CONFIG_SMP
    166 static void tlb_shootdown_ipi(unsigned int n __attribute__((unused)),
    167     istate_t *istate __attribute__((unused)))
     173static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
    168174{
    169175        trap_virtual_eoi();
     
    173179
    174180/** Handler of IRQ exceptions */
    175 static void irq_interrupt(unsigned int n, istate_t *istate __attribute__((unused)))
     181static void irq_interrupt(int n, istate_t *istate __attribute__((unused)))
    176182{
    177183        ASSERT(n >= IVT_IRQBASE);
    178184       
    179         unsigned int inum = n - IVT_IRQBASE;
     185        int inum = n - IVT_IRQBASE;
    180186        bool ack = false;
    181187        ASSERT(inum < IRQ_COUNT);
     
    187193                 * The IRQ handler was found.
    188194                 */
    189                
     195                 
    190196                if (irq->preack) {
    191197                        /* Send EOI before processing the interrupt */
     
    194200                }
    195201                irq->handler(irq);
    196                 irq_spinlock_unlock(&irq->lock, false);
     202                spinlock_unlock(&irq->lock);
    197203        } else {
    198204                /*
     
    200206                 */
    201207#ifdef CONFIG_DEBUG
    202                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     208                printf("cpu%u: spurious interrupt (inum=%d)\n", CPU->id, inum);
    203209#endif
    204210        }
     
    210216void interrupt_init(void)
    211217{
    212         unsigned int i;
     218        int i;
    213219       
    214220        for (i = 0; i < IVT_ITEMS; i++)
    215                 exc_register(i, "null", false, (iroutine_t) null_interrupt);
     221                exc_register(i, "null", (iroutine) null_interrupt);
    216222       
    217223        for (i = 0; i < IRQ_COUNT; i++) {
    218224                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    219                         exc_register(IVT_IRQBASE + i, "irq", true,
    220                             (iroutine_t) irq_interrupt);
     225                        exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
    221226        }
    222227       
    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);
     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);
    228233       
    229234#ifdef CONFIG_SMP
    230         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
    231             (iroutine_t) tlb_shootdown_ipi);
     235        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
    232236#endif
    233237}
Note: See TracChangeset for help on using the changeset viewer.