Ignore:
File:
1 edited

Legend:

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

    rd99c1d2 r0c61955  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    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         const char *pcsymbol = symtab_fmt_name_lookup(istate->epc);
    77         const char *rasymbol = symtab_fmt_name_lookup(istate->ra);
    78        
    79         printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol,
    80             istate->ra, rasymbol, istate->sp);
    81 }
    82 
    83 static void unhandled_exception(int n, istate_t *istate)
     74void istate_decode(istate_t *istate)
     75{
     76        printf("epc=%p\tsta=%p\tlo =%p\thi =%p\n",
     77            istate->epc, istate->status, istate->lo, istate->hi);
     78        printf("a0 =%p\ta1 =%p\ta2 =%p\ta3 =%p\n",
     79            istate->a0, istate->a1, istate->a2, istate->a3);
     80        printf("t0 =%p\tt1 =%p\tt2 =%p\tt3 =%p\n",
     81            istate->t0, istate->t1, istate->t2, istate->t3);
     82        printf("t4 =%p\tt5 =%p\tt6 =%p\tt7 =%p\n",
     83            istate->t4, istate->t5, istate->t6, istate->t7);
     84        printf("t8 =%p\tt9 =%p\tv0 =%p\tv1 =%p\n",
     85            istate->t8, istate->t9, istate->v0, istate->v1);
     86        printf("s0 =%p\ts1 =%p\ts2 =%p\ts3 =%p\n",
     87            istate->s0, istate->s1, istate->s2, istate->s3);
     88        printf("s4 =%p\ts5 =%p\ts6 =%p\ts7 =%p\n",
     89            istate->s4, istate->s5, istate->s6, istate->s7);
     90        printf("s8 =%p\tat =%p\tkt0=%p\tkt1=%p\n",
     91            istate->s8, istate->at, istate->kt0, istate->kt1);
     92        printf("sp =%p\tra =%p\tgp =%p\n",
     93            istate->sp, istate->ra, istate->gp);
     94}
     95
     96static void unhandled_exception(unsigned int n, istate_t *istate)
    8497{
    8598        fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]);
    86        
    87         print_regdump(istate);
    88         panic("Unhandled exception %s.", exctable[n]);
    89 }
    90 
    91 static void reserved_instr_exception(int n, istate_t *istate)
     99        panic_badtrap(istate, n, "Unhandled exception %s.", exctable[n]);
     100}
     101
     102static void reserved_instr_exception(unsigned int n, istate_t *istate)
    92103{
    93104        if (*((uint32_t *) istate->epc) == 0x7c03e83b) {
    94105                ASSERT(THREAD);
    95106                istate->epc += 4;
    96                 istate->v1 = istate->k1;
     107                istate->v1 = istate->kt1;
    97108        } else
    98109                unhandled_exception(n, istate);
    99110}
    100111
    101 static void breakpoint_exception(int n, istate_t *istate)
     112static void breakpoint_exception(unsigned int n, istate_t *istate)
    102113{
    103114#ifdef CONFIG_DEBUG
     
    111122}
    112123
    113 static void tlbmod_exception(int n, istate_t *istate)
     124static void tlbmod_exception(unsigned int n, istate_t *istate)
    114125{
    115126        tlb_modified(istate);
    116127}
    117128
    118 static void tlbinv_exception(int n, istate_t *istate)
     129static void tlbinv_exception(unsigned int n, istate_t *istate)
    119130{
    120131        tlb_invalid(istate);
     
    122133
    123134#ifdef CONFIG_FPU_LAZY
    124 static void cpuns_exception(int n, istate_t *istate)
     135static void cpuns_exception(unsigned int n, istate_t *istate)
    125136{
    126137        if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
    127138                scheduler_fpu_lazy_request();
    128139        else {
    129                 fault_if_from_uspace(istate, "Unhandled Coprocessor Unusable Exception.");
    130                 panic("Unhandled Coprocessor Unusable Exception.");
     140                fault_if_from_uspace(istate,
     141                    "Unhandled Coprocessor Unusable Exception.");
     142                panic_badtrap(istate, n,
     143                    "Unhandled Coprocessor Unusable Exception.");
    131144        }
    132145}
    133146#endif
    134147
    135 static void interrupt_exception(int n, istate_t *istate)
    136 {
    137         uint32_t cause;
    138         int i;
    139        
    140         /* decode interrupt number and process the interrupt */
    141         cause = (cp0_cause_read() >> 8) & 0xff;
    142        
     148static void interrupt_exception(unsigned int n, istate_t *istate)
     149{
     150        /* Decode interrupt number and process the interrupt */
     151        uint32_t cause = (cp0_cause_read() >> 8) & 0xff;
     152       
     153        unsigned int i;
    143154        for (i = 0; i < 8; i++) {
    144155                if (cause & (1 << i)) {
     
    149160                                 */
    150161                                irq->handler(irq);
    151                                 spinlock_unlock(&irq->lock);
     162                                irq_spinlock_unlock(&irq->lock, false);
    152163                        } else {
    153164                                /*
     
    155166                                 */
    156167#ifdef CONFIG_DEBUG
    157                                 printf("cpu%u: spurious interrupt (inum=%d)\n",
     168                                printf("cpu%u: spurious interrupt (inum=%u)\n",
    158169                                    CPU->id, i);
    159170#endif
     
    164175
    165176/** Handle syscall userspace call */
    166 static void syscall_exception(int n, istate_t *istate)
    167 {
    168         panic("Syscall is handled through shortcut.");
     177static void syscall_exception(unsigned int n, istate_t *istate)
     178{
     179        fault_if_from_uspace(istate, "Syscall is handled through shortcut.");
    169180}
    170181
    171182void exception_init(void)
    172183{
    173         int i;
    174 
     184        unsigned int i;
     185       
    175186        /* Clear exception table */
    176187        for (i = 0; i < IVT_ITEMS; i++)
    177                 exc_register(i, "undef", (iroutine) unhandled_exception);
    178        
    179         exc_register(EXC_Bp, "bkpoint", (iroutine) breakpoint_exception);
    180         exc_register(EXC_RI, "resinstr", (iroutine) reserved_instr_exception);
    181         exc_register(EXC_Mod, "tlb_mod", (iroutine) tlbmod_exception);
    182         exc_register(EXC_TLBL, "tlbinvl", (iroutine) tlbinv_exception);
    183         exc_register(EXC_TLBS, "tlbinvl", (iroutine) tlbinv_exception);
    184         exc_register(EXC_Int, "interrupt", (iroutine) interrupt_exception);
     188                exc_register(i, "undef", false,
     189                    (iroutine_t) unhandled_exception);
     190       
     191        exc_register(EXC_Bp, "bkpoint", true,
     192            (iroutine_t) breakpoint_exception);
     193        exc_register(EXC_RI, "resinstr", true,
     194            (iroutine_t) reserved_instr_exception);
     195        exc_register(EXC_Mod, "tlb_mod", true,
     196            (iroutine_t) tlbmod_exception);
     197        exc_register(EXC_TLBL, "tlbinvl", true,
     198            (iroutine_t) tlbinv_exception);
     199        exc_register(EXC_TLBS, "tlbinvl", true,
     200            (iroutine_t) tlbinv_exception);
     201        exc_register(EXC_Int, "interrupt", true,
     202            (iroutine_t) interrupt_exception);
     203       
    185204#ifdef CONFIG_FPU_LAZY
    186         exc_register(EXC_CpU, "cpunus", (iroutine) cpuns_exception);
    187 #endif
    188         exc_register(EXC_Sys, "syscall", (iroutine) syscall_exception);
     205        exc_register(EXC_CpU, "cpunus", true,
     206            (iroutine_t) cpuns_exception);
     207#endif
     208       
     209        exc_register(EXC_Sys, "syscall", true,
     210            (iroutine_t) syscall_exception);
    189211}
    190212
Note: See TracChangeset for help on using the changeset viewer.