Ignore:
File:
1 edited

Legend:

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

    r98000fb racc7ce4  
    5353#include <ddi/irq.h>
    5454#include <symtab.h>
     55#include <stacktrace.h>
    5556
    5657/*
     
    6162void (* enable_irqs_function)(uint16_t irqmask) = NULL;
    6263void (* eoi_function)(void) = NULL;
    63 
    64 void 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]);
     64const char *irqs_info = NULL;
     65
     66void 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);
    8293}
    8394
     
    91102}
    92103
    93 static 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. */
    101 static void gp_fault(int n, istate_t *istate)
     104static 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
     110static 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 */
     119static void gp_fault(unsigned int n, istate_t *istate)
    102120{
    103121        if (TASK) {
    104                 size_t ver;
    105 
    106                 spinlock_lock(&TASK->lock);
    107                 ver = TASK->arch.iomapver;
    108                 spinlock_unlock(&TASK->lock);
    109 
     122                irq_spinlock_lock(&TASK->lock, false);
     123                size_t ver = TASK->arch.iomapver;
     124                irq_spinlock_unlock(&TASK->lock, false);
     125               
    110126                if (CPU->arch.iomapver_copy != ver) {
    111127                        /*
     
    121137                fault_if_from_uspace(istate, "General protection fault.");
    122138        }
    123 
    124         decode_istate(n, istate);
    125         panic("General protection fault.");
    126 }
    127 
    128 static void ss_fault(int n, istate_t *istate)
     139        panic_badtrap(istate, n, "General protection fault.");
     140}
     141
     142static void ss_fault(unsigned int n, istate_t *istate)
    129143{
    130144        fault_if_from_uspace(istate, "Stack fault.");
    131         decode_istate(n, istate);
    132         panic("Stack fault.");
    133 }
    134 
    135 static void nm_fault(int n, istate_t *istate)
     145        panic_badtrap(istate, n, "Stack fault.");
     146}
     147
     148static void nm_fault(unsigned int n, istate_t *istate)
    136149{
    137150#ifdef CONFIG_FPU_LAZY
     
    144157
    145158#ifdef CONFIG_SMP
    146 static void tlb_shootdown_ipi(int n, istate_t *istate)
     159static void tlb_shootdown_ipi(unsigned int n, istate_t *istate)
    147160{
    148161        trap_virtual_eoi();
     
    151164#endif
    152165
    153 /** Handler of IRQ exceptions */
    154 static void irq_interrupt(int n, istate_t *istate)
     166/** Handler of IRQ exceptions.
     167 *
     168 */
     169static void irq_interrupt(unsigned int n, istate_t *istate)
    155170{
    156171        ASSERT(n >= IVT_IRQBASE);
    157172       
    158         int inum = n - IVT_IRQBASE;
     173        unsigned int inum = n - IVT_IRQBASE;
    159174        bool ack = false;
    160175        ASSERT(inum < IRQ_COUNT);
     
    166181                 * The IRQ handler was found.
    167182                 */
    168                  
     183               
    169184                if (irq->preack) {
    170185                        /* Send EOI before processing the interrupt */
     
    173188                }
    174189                irq->handler(irq);
    175                 spinlock_unlock(&irq->lock);
     190                irq_spinlock_unlock(&irq->lock, false);
    176191        } else {
    177192                /*
     
    179194                 */
    180195#ifdef CONFIG_DEBUG
    181                 printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
     196                printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
    182197#endif
    183198        }
     
    189204void interrupt_init(void)
    190205{
    191         int i;
     206        unsigned int i;
    192207       
    193208        for (i = 0; i < IVT_ITEMS; i++)
    194                 exc_register(i, "null", (iroutine) null_interrupt);
     209                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    195210       
    196211        for (i = 0; i < IRQ_COUNT; i++) {
    197212                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    198                         exc_register(IVT_IRQBASE + i, "irq",
    199                             (iroutine) irq_interrupt);
     213                        exc_register(IVT_IRQBASE + i, "irq", true,
     214                            (iroutine_t) irq_interrupt);
    200215        }
    201216       
    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);
     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);
    206221       
    207222#ifdef CONFIG_SMP
    208         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
    209             (iroutine) tlb_shootdown_ipi);
     223        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
     224            (iroutine_t) tlb_shootdown_ipi);
    210225#endif
    211226}
Note: See TracChangeset for help on using the changeset viewer.