Ignore:
File:
1 edited

Legend:

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

    racc7ce4 r98000fb  
    5353#include <ddi/irq.h>
    5454#include <symtab.h>
    55 #include <stacktrace.h>
    5655
    5756/*
     
    6261void (* enable_irqs_function)(uint16_t irqmask) = NULL;
    6362void (* eoi_function)(void) = NULL;
    64 const char *irqs_info = NULL;
    65 
    66 void istate_decode(istate_t *istate)
    67 {
    68         printf("cs =%#0" PRIx64 "\trip=%p\t"
    69             "rfl=%#0" PRIx64 "\terr=%#0" PRIx64 "\n",
    70             istate->cs, (void *) istate->rip,
    71             istate->rflags, istate->error_word);
    72        
    73         if (istate_from_uspace(istate))
    74                 printf("ss =%#0" PRIx64 "\n", istate->ss);
    75        
    76         printf("rax=%#0" PRIx64 "\trbx=%#0" PRIx64 "\t"
    77             "rcx=%#0" PRIx64 "\trdx=%#0" PRIx64 "\n",
    78             istate->rax, istate->rbx, istate->rcx, istate->rdx);
    79        
    80         printf("rsi=%p\trdi=%p\trbp=%p\trsp=%p\n",
    81             (void *) istate->rsi, (void *) istate->rdi,
    82             (void *) istate->rbp,
    83             istate_from_uspace(istate) ? ((void *) istate->rsp) :
    84             &istate->rsp);
    85        
    86         printf("r8 =%#0" PRIx64 "\tr9 =%#0" PRIx64 "\t"
    87             "r10=%#0" PRIx64 "\tr11=%#0" PRIx64 "\n",
    88             istate->r8, istate->r9, istate->r10, istate->r11);
    89        
    90         printf("r12=%#0" PRIx64 "\tr13=%#0" PRIx64 "\t"
    91             "r14=%#0" PRIx64 "\tr15=%#0" PRIx64 "\n",
    92             istate->r12, istate->r13, istate->r14, istate->r15);
     63
     64void decode_istate(int n, istate_t *istate)
     65{
     66        char *symbol;
     67
     68        symbol = symtab_fmt_name_lookup(istate->rip);
     69
     70        printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n", n, __func__);
     71        printf("%%rip: %#llx (%s)\n", istate->rip, symbol);
     72        printf("ERROR_WORD=%#llx\n", istate->error_word);
     73        printf("%%cs=%#llx, rflags=%#llx, %%cr0=%#llx\n", istate->cs,
     74            istate->rflags, read_cr0());
     75        printf("%%rax=%#llx, %%rcx=%#llx, %%rdx=%#llx\n", istate->rax,
     76            istate->rcx, istate->rdx);
     77        printf("%%rsi=%#llx, %%rdi=%#llx, %%r8=%#llx\n", istate->rsi,
     78            istate->rdi, istate->r8);
     79        printf("%%r9=%#llx, %%r10=%#llx, %%r11=%#llx\n", istate->r9,
     80            istate->r10, istate->r11);
     81        printf("%%rsp=%#llx\n", &istate->stack[0]);
    9382}
    9483
     
    10291}
    10392
    104 static void null_interrupt(unsigned int n, istate_t *istate)
    105 {
    106         fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n);
    107         panic_badtrap(istate, n, "Unserviced interrupt.");
    108 }
    109 
    110 static void de_fault(unsigned int n, istate_t *istate)
    111 {
    112         fault_if_from_uspace(istate, "Divide error.");
    113         panic_badtrap(istate, n, "Divide error.");
    114 }
    115 
    116 /** General Protection Fault.
    117  *
    118  */
    119 static void gp_fault(unsigned int n, istate_t *istate)
     93static void null_interrupt(int n, istate_t *istate)
     94{
     95        fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n);
     96        decode_istate(n, istate);
     97        panic("Unserviced interrupt.");
     98}
     99
     100/** General Protection Fault. */
     101static void gp_fault(int n, istate_t *istate)
    120102{
    121103        if (TASK) {
    122                 irq_spinlock_lock(&TASK->lock, false);
    123                 size_t ver = TASK->arch.iomapver;
    124                 irq_spinlock_unlock(&TASK->lock, false);
    125                
     104                size_t ver;
     105
     106                spinlock_lock(&TASK->lock);
     107                ver = TASK->arch.iomapver;
     108                spinlock_unlock(&TASK->lock);
     109
    126110                if (CPU->arch.iomapver_copy != ver) {
    127111                        /*
     
    137121                fault_if_from_uspace(istate, "General protection fault.");
    138122        }
    139         panic_badtrap(istate, n, "General protection fault.");
    140 }
    141 
    142 static void ss_fault(unsigned int n, istate_t *istate)
     123
     124        decode_istate(n, istate);
     125        panic("General protection fault.");
     126}
     127
     128static void ss_fault(int n, istate_t *istate)
    143129{
    144130        fault_if_from_uspace(istate, "Stack fault.");
    145         panic_badtrap(istate, n, "Stack fault.");
    146 }
    147 
    148 static void nm_fault(unsigned int n, istate_t *istate)
     131        decode_istate(n, istate);
     132        panic("Stack fault.");
     133}
     134
     135static void nm_fault(int n, istate_t *istate)
    149136{
    150137#ifdef CONFIG_FPU_LAZY
     
    157144
    158145#ifdef CONFIG_SMP
    159 static void tlb_shootdown_ipi(unsigned int n, istate_t *istate)
     146static void tlb_shootdown_ipi(int n, istate_t *istate)
    160147{
    161148        trap_virtual_eoi();
     
    164151#endif
    165152
    166 /** Handler of IRQ exceptions.
    167  *
    168  */
    169 static void irq_interrupt(unsigned int n, istate_t *istate)
     153/** Handler of IRQ exceptions */
     154static void irq_interrupt(int n, istate_t *istate)
    170155{
    171156        ASSERT(n >= IVT_IRQBASE);
    172157       
    173         unsigned int inum = n - IVT_IRQBASE;
     158        int inum = n - IVT_IRQBASE;
    174159        bool ack = false;
    175160        ASSERT(inum < IRQ_COUNT);
     
    181166                 * The IRQ handler was found.
    182167                 */
    183                
     168                 
    184169                if (irq->preack) {
    185170                        /* Send EOI before processing the interrupt */
     
    188173                }
    189174                irq->handler(irq);
    190                 irq_spinlock_unlock(&irq->lock, false);
     175                spinlock_unlock(&irq->lock);
    191176        } else {
    192177                /*
     
    194179                 */
    195180#ifdef CONFIG_DEBUG
    196                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     181                printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
    197182#endif
    198183        }
     
    204189void interrupt_init(void)
    205190{
    206         unsigned int i;
     191        int i;
    207192       
    208193        for (i = 0; i < IVT_ITEMS; i++)
    209                 exc_register(i, "null", false, (iroutine_t) null_interrupt);
     194                exc_register(i, "null", (iroutine) null_interrupt);
    210195       
    211196        for (i = 0; i < IRQ_COUNT; i++) {
    212197                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    213                         exc_register(IVT_IRQBASE + i, "irq", true,
    214                             (iroutine_t) irq_interrupt);
     198                        exc_register(IVT_IRQBASE + i, "irq",
     199                            (iroutine) irq_interrupt);
    215200        }
    216201       
    217         exc_register(0, "de_fault", true, (iroutine_t) de_fault);
    218         exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
    219         exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
    220         exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     202        exc_register(7, "nm_fault", (iroutine) nm_fault);
     203        exc_register(12, "ss_fault", (iroutine) ss_fault);
     204        exc_register(13, "gp_fault", (iroutine) gp_fault);
     205        exc_register(14, "ident_mapper", (iroutine) ident_page_fault);
    221206       
    222207#ifdef CONFIG_SMP
    223         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
    224             (iroutine_t) tlb_shootdown_ipi);
     208        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
     209            (iroutine) tlb_shootdown_ipi);
    225210#endif
    226211}
Note: See TracChangeset for help on using the changeset viewer.