Ignore:
File:
1 edited

Legend:

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

    r7e752b2 r304342e  
    6363void (* eoi_function)(void) = NULL;
    6464
    65 void istate_decode(istate_t *istate)
    66 {
    67         printf("cs =%#0" PRIx64 "\trip=%p\t"
    68             "rfl=%#0" PRIx64 "\terr=%#0" PRIx64 "\n",
    69             istate->cs, (void *) istate->rip,
    70             istate->rflags, istate->error_word);
    71        
    72         if (istate_from_uspace(istate))
    73                 printf("ss =%#0" PRIx64 "\n", istate->ss);
    74        
    75         printf("rax=%#0" PRIx64 "\trbx=%#0" PRIx64 "\t"
    76             "rcx=%#0" PRIx64 "\trdx=%#0" PRIx64 "\n",
    77             istate->rax, istate->rbx, istate->rcx, istate->rdx);
    78        
    79         printf("rsi=%p\trdi=%p\trbp=%p\trsp=%p\n",
    80             (void *) istate->rsi, (void *) istate->rdi,
    81             (void *) istate->rbp,
    82             istate_from_uspace(istate) ? ((void *) istate->rsp) :
    83             &istate->rsp);
    84        
    85         printf("r8 =%#0" PRIx64 "\tr9 =%#0" PRIx64 "\t"
    86             "r10=%#0" PRIx64 "\tr11=%#0" PRIx64 "\n",
    87             istate->r8, istate->r9, istate->r10, istate->r11);
    88        
    89         printf("r12=%#0" PRIx64 "\tr13=%#0" PRIx64 "\t"
    90             "r14=%#0" PRIx64 "\tr15=%#0" PRIx64 "\n",
    91             istate->r12, istate->r13, istate->r14, istate->r15);
     65void decode_istate(int n, istate_t *istate)
     66{
     67        char *symbol;
     68
     69        symbol = symtab_fmt_name_lookup(istate->rip);
     70
     71        printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n", n, __func__);
     72        printf("%%rip: %#llx (%s)\n", istate->rip, symbol);
     73        printf("ERROR_WORD=%#llx\n", istate->error_word);
     74        printf("%%cs=%#llx, rflags=%#llx, %%cr0=%#llx\n", istate->cs,
     75            istate->rflags, read_cr0());
     76        printf("%%rax=%#llx, %%rcx=%#llx, %%rdx=%#llx\n", istate->rax,
     77            istate->rcx, istate->rdx);
     78        printf("%%rsi=%#llx, %%rdi=%#llx, %%r8=%#llx\n", istate->rsi,
     79            istate->rdi, istate->r8);
     80        printf("%%r9=%#llx, %%r10=%#llx, %%r11=%#llx\n", istate->r9,
     81            istate->r10, istate->r11);
     82        printf("%%rsp=%#llx\n", &istate->stack[0]);
     83       
     84        stack_trace_istate(istate);
    9285}
    9386
     
    10194}
    10295
    103 static void null_interrupt(unsigned int n, istate_t *istate)
    104 {
    105         fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n);
    106         panic_badtrap(istate, n, "Unserviced interrupt.");
    107 }
    108 
    109 static void de_fault(unsigned int n, istate_t *istate)
     96static void null_interrupt(int n, istate_t *istate)
     97{
     98        fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n);
     99        decode_istate(n, istate);
     100        panic("Unserviced interrupt.");
     101}
     102
     103static void de_fault(int n, istate_t *istate)
    110104{
    111105        fault_if_from_uspace(istate, "Divide error.");
    112         panic_badtrap(istate, n, "Divide error.");
    113 }
    114 
    115 /** General Protection Fault.
    116  *
    117  */
    118 static void gp_fault(unsigned int n, istate_t *istate)
     106        decode_istate(n, istate);
     107        panic("Divide error.");
     108}
     109
     110/** General Protection Fault. */
     111static void gp_fault(int n, istate_t *istate)
    119112{
    120113        if (TASK) {
    121                 irq_spinlock_lock(&TASK->lock, false);
    122                 size_t ver = TASK->arch.iomapver;
    123                 irq_spinlock_unlock(&TASK->lock, false);
    124                
     114                size_t ver;
     115
     116                spinlock_lock(&TASK->lock);
     117                ver = TASK->arch.iomapver;
     118                spinlock_unlock(&TASK->lock);
     119
    125120                if (CPU->arch.iomapver_copy != ver) {
    126121                        /*
     
    136131                fault_if_from_uspace(istate, "General protection fault.");
    137132        }
    138         panic_badtrap(istate, n, "General protection fault.");
    139 }
    140 
    141 static void ss_fault(unsigned int n, istate_t *istate)
     133
     134        decode_istate(n, istate);
     135        panic("General protection fault.");
     136}
     137
     138static void ss_fault(int n, istate_t *istate)
    142139{
    143140        fault_if_from_uspace(istate, "Stack fault.");
    144         panic_badtrap(istate, n, "Stack fault.");
    145 }
    146 
    147 static void nm_fault(unsigned int n, istate_t *istate)
     141        decode_istate(n, istate);
     142        panic("Stack fault.");
     143}
     144
     145static void nm_fault(int n, istate_t *istate)
    148146{
    149147#ifdef CONFIG_FPU_LAZY
     
    156154
    157155#ifdef CONFIG_SMP
    158 static void tlb_shootdown_ipi(unsigned int n, istate_t *istate)
     156static void tlb_shootdown_ipi(int n, istate_t *istate)
    159157{
    160158        trap_virtual_eoi();
     
    163161#endif
    164162
    165 /** Handler of IRQ exceptions.
    166  *
    167  */
    168 static void irq_interrupt(unsigned int n, istate_t *istate)
     163/** Handler of IRQ exceptions */
     164static void irq_interrupt(int n, istate_t *istate)
    169165{
    170166        ASSERT(n >= IVT_IRQBASE);
    171167       
    172         unsigned int inum = n - IVT_IRQBASE;
     168        int inum = n - IVT_IRQBASE;
    173169        bool ack = false;
    174170        ASSERT(inum < IRQ_COUNT);
     
    180176                 * The IRQ handler was found.
    181177                 */
    182                
     178                 
    183179                if (irq->preack) {
    184180                        /* Send EOI before processing the interrupt */
     
    187183                }
    188184                irq->handler(irq);
    189                 irq_spinlock_unlock(&irq->lock, false);
     185                spinlock_unlock(&irq->lock);
    190186        } else {
    191187                /*
     
    193189                 */
    194190#ifdef CONFIG_DEBUG
    195                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     191                printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
    196192#endif
    197193        }
     
    203199void interrupt_init(void)
    204200{
    205         unsigned int i;
     201        int i;
    206202       
    207203        for (i = 0; i < IVT_ITEMS; i++)
    208                 exc_register(i, "null", false, (iroutine_t) null_interrupt);
     204                exc_register(i, "null", (iroutine) null_interrupt);
    209205       
    210206        for (i = 0; i < IRQ_COUNT; i++) {
    211207                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    212                         exc_register(IVT_IRQBASE + i, "irq", true,
    213                             (iroutine_t) irq_interrupt);
     208                        exc_register(IVT_IRQBASE + i, "irq",
     209                            (iroutine) irq_interrupt);
    214210        }
    215211       
    216         exc_register(0, "de_fault", true, (iroutine_t) de_fault);
    217         exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
    218         exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
    219         exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     212        exc_register(0, "de_fault", (iroutine) de_fault);
     213        exc_register(7, "nm_fault", (iroutine) nm_fault);
     214        exc_register(12, "ss_fault", (iroutine) ss_fault);
     215        exc_register(13, "gp_fault", (iroutine) gp_fault);
     216        exc_register(14, "ident_mapper", (iroutine) ident_page_fault);
    220217       
    221218#ifdef CONFIG_SMP
    222         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
    223             (iroutine_t) tlb_shootdown_ipi);
     219        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
     220            (iroutine) tlb_shootdown_ipi);
    224221#endif
    225222}
Note: See TracChangeset for help on using the changeset viewer.