Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/exception.c

    re16e0d59 r22a28a69  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    3838#include <panic.h>
    3939#include <arch/cp0.h>
    40 #include <arch/types.h>
     40#include <typedefs.h>
    4141#include <arch.h>
    4242#include <debug.h>
     
    4949#include <symtab.h>
    5050
    51 static char * exctable[] = {
     51static const char *exctable[] = {
    5252        "Interrupt",
    5353        "TLB Modified",
     
    6767        "Floating Point",
    6868        NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    69         "WatchHi/WatchLo", /* 23 */
     69        "WatchHi/WatchLo",  /* 23 */
    7070        NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    7171        "Virtual Coherency - data",
    7272};
    7373
    74 static void print_regdump(istate_t *istate)
    75 {
    76         char *pcsymbol, *rasymbol;
    77 
    78         pcsymbol = symtab_fmt_name_lookup(istate->epc);
    79         rasymbol = symtab_fmt_name_lookup(istate->ra);
    80 
    81         printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol,
    82             istate->ra, rasymbol, istate->sp);
    83 }
    84 
    85 static void unhandled_exception(int n, istate_t *istate)
     74void istate_decode(istate_t *istate)
     75{
     76        printf("at=%p\tv0=%p\tv1=%p\n", istate->at, istate->v0, istate->v1);
     77        printf("a0=%p\ta1=%p\ta2=%p\n", istate->a0, istate->a1, istate->a2);
     78        printf("a3=%p\tt0=%p\tt1=%p\n", istate->a3, istate->t0, istate->t1);
     79        printf("t2=%p\tt3=%p\tt4=%p\n", istate->t2, istate->t3, istate->t4);
     80        printf("t5=%p\tt6=%p\tt7=%p\n", istate->t5, istate->t6, istate->t7);
     81        printf("t8=%p\tt9=%p\tgp=%p\n", istate->t8, istate->t9, istate->gp);
     82        printf("sp=%p\tra=%p\t\n", istate->sp, istate->ra);
     83        printf("lo=%p\thi=%p\t\n", istate->lo, istate->hi);
     84        printf("cp0_status=%p\tcp0_epc=%p\tk1=%p\n",
     85            istate->status, istate->epc, istate->k1);
     86}
     87
     88static void unhandled_exception(unsigned int n, istate_t *istate)
    8689{
    8790        fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]);
    88        
    89         print_regdump(istate);
    90         panic("Unhandled exception %s.", exctable[n]);
    91 }
    92 
    93 static void reserved_instr_exception(int n, istate_t *istate)
    94 {
    95         if (*((uint32_t *)istate->epc) == 0x7c03e83b) {
     91        panic_badtrap(istate, n, "Unhandled exception %s.", exctable[n]);
     92}
     93
     94static void reserved_instr_exception(unsigned int n, istate_t *istate)
     95{
     96        if (*((uint32_t *) istate->epc) == 0x7c03e83b) {
    9697                ASSERT(THREAD);
    9798                istate->epc += 4;
    9899                istate->v1 = istate->k1;
    99         } else 
     100        } else
    100101                unhandled_exception(n, istate);
    101102}
    102103
    103 static void breakpoint_exception(int n, istate_t *istate)
     104static void breakpoint_exception(unsigned int n, istate_t *istate)
    104105{
    105106#ifdef CONFIG_DEBUG
     
    113114}
    114115
    115 static void tlbmod_exception(int n, istate_t *istate)
     116static void tlbmod_exception(unsigned int n, istate_t *istate)
    116117{
    117118        tlb_modified(istate);
    118119}
    119120
    120 static void tlbinv_exception(int n, istate_t *istate)
     121static void tlbinv_exception(unsigned int n, istate_t *istate)
    121122{
    122123        tlb_invalid(istate);
     
    124125
    125126#ifdef CONFIG_FPU_LAZY
    126 static void cpuns_exception(int n, istate_t *istate)
     127static void cpuns_exception(unsigned int n, istate_t *istate)
    127128{
    128129        if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
    129130                scheduler_fpu_lazy_request();
    130131        else {
    131                 fault_if_from_uspace(istate, "Unhandled Coprocessor Unusable Exception.");
    132                 panic("Unhandled Coprocessor Unusable Exception.");
     132                fault_if_from_uspace(istate,
     133                    "Unhandled Coprocessor Unusable Exception.");
     134                panic_badtrap(istate, n,
     135                    "Unhandled Coprocessor Unusable Exception.");
    133136        }
    134137}
    135138#endif
    136139
    137 static void interrupt_exception(int n, istate_t *istate)
    138 {
    139         uint32_t cause;
    140         int i;
    141        
    142         /* decode interrupt number and process the interrupt */
    143         cause = (cp0_cause_read() >> 8) & 0xff;
    144        
     140static void interrupt_exception(unsigned int n, istate_t *istate)
     141{
     142        /* Decode interrupt number and process the interrupt */
     143        uint32_t cause = (cp0_cause_read() >> 8) & 0xff;
     144       
     145        unsigned int i;
    145146        for (i = 0; i < 8; i++) {
    146147                if (cause & (1 << i)) {
     
    151152                                 */
    152153                                irq->handler(irq);
    153                                 spinlock_unlock(&irq->lock);
     154                                irq_spinlock_unlock(&irq->lock, false);
    154155                        } else {
    155156                                /*
     
    157158                                 */
    158159#ifdef CONFIG_DEBUG
    159                                 printf("cpu%u: spurious interrupt (inum=%d)\n",
     160                                printf("cpu%u: spurious interrupt (inum=%u)\n",
    160161                                    CPU->id, i);
    161162#endif
     
    166167
    167168/** Handle syscall userspace call */
    168 static void syscall_exception(int n, istate_t *istate)
    169 {
    170         panic("Syscall is handled through shortcut.");
     169static void syscall_exception(unsigned int n, istate_t *istate)
     170{
     171        fault_if_from_uspace(istate, "Syscall is handled through shortcut.");
    171172}
    172173
    173174void exception_init(void)
    174175{
    175         int i;
    176 
     176        unsigned int i;
     177       
    177178        /* Clear exception table */
    178179        for (i = 0; i < IVT_ITEMS; i++)
    179                 exc_register(i, "undef", (iroutine) unhandled_exception);
    180        
    181         exc_register(EXC_Bp, "bkpoint", (iroutine) breakpoint_exception);
    182         exc_register(EXC_RI, "resinstr", (iroutine) reserved_instr_exception);
    183         exc_register(EXC_Mod, "tlb_mod", (iroutine) tlbmod_exception);
    184         exc_register(EXC_TLBL, "tlbinvl", (iroutine) tlbinv_exception);
    185         exc_register(EXC_TLBS, "tlbinvl", (iroutine) tlbinv_exception);
    186         exc_register(EXC_Int, "interrupt", (iroutine) interrupt_exception);
     180                exc_register(i, "undef", false,
     181                    (iroutine_t) unhandled_exception);
     182       
     183        exc_register(EXC_Bp, "bkpoint", true,
     184            (iroutine_t) breakpoint_exception);
     185        exc_register(EXC_RI, "resinstr", true,
     186            (iroutine_t) reserved_instr_exception);
     187        exc_register(EXC_Mod, "tlb_mod", true,
     188            (iroutine_t) tlbmod_exception);
     189        exc_register(EXC_TLBL, "tlbinvl", true,
     190            (iroutine_t) tlbinv_exception);
     191        exc_register(EXC_TLBS, "tlbinvl", true,
     192            (iroutine_t) tlbinv_exception);
     193        exc_register(EXC_Int, "interrupt", true,
     194            (iroutine_t) interrupt_exception);
     195       
    187196#ifdef CONFIG_FPU_LAZY
    188         exc_register(EXC_CpU, "cpunus", (iroutine) cpuns_exception);
    189 #endif
    190         exc_register(EXC_Sys, "syscall", (iroutine) syscall_exception);
     197        exc_register(EXC_CpU, "cpunus", true,
     198            (iroutine_t) cpuns_exception);
     199#endif
     200       
     201        exc_register(EXC_Sys, "syscall", true,
     202            (iroutine_t) syscall_exception);
    191203}
    192204
Note: See TracChangeset for help on using the changeset viewer.