Subversion Repositories HelenOS-historic

Rev

Rev 794 | Rev 852 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 794 Rev 799
Line 76... Line 76...
76
   
76
   
77
    printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
77
    printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
78
           pstate->ra,rasymbol);
78
           pstate->ra,rasymbol);
79
}
79
}
80
 
80
 
81
static void unhandled_exception(int n, void *data)
81
static void unhandled_exception(int n, struct exception_regdump *pstate)
82
{
82
{
83
    struct exception_regdump *pstate = (struct exception_regdump *)data;
-
 
84
 
-
 
85
    print_regdump(pstate);
83
    print_regdump(pstate);
86
    panic("unhandled exception %s\n", exctable[n]);
84
    panic("unhandled exception %s\n", exctable[n]);
87
}
85
}
88
 
86
 
89
static void breakpoint_exception(int n, void *data)
87
static void breakpoint_exception(int n, struct exception_regdump *pstate)
90
{
88
{
91
    struct exception_regdump *pstate = (struct exception_regdump *)data;
-
 
92
 
-
 
93
#ifdef CONFIG_DEBUG
89
#ifdef CONFIG_DEBUG
94
    debugger_bpoint(pstate);
90
    debugger_bpoint(pstate);
95
#else
91
#else
96
    /* it is necessary to not re-execute BREAK instruction after
92
    /* it is necessary to not re-execute BREAK instruction after
97
       returning from Exception handler
93
       returning from Exception handler
98
       (see page 138 in R4000 Manual for more information) */
94
       (see page 138 in R4000 Manual for more information) */
99
    pstate->epc += 4;
95
    pstate->epc += 4;
100
#endif
96
#endif
101
}
97
}
102
 
98
 
103
static void tlbmod_exception(int n, void *data)
99
static void tlbmod_exception(int n, struct exception_regdump *pstate)
104
{
100
{
105
    struct exception_regdump *pstate = (struct exception_regdump *)data;
-
 
106
    tlb_modified(pstate);
101
    tlb_modified(pstate);
107
}
102
}
108
 
103
 
109
static void tlbinv_exception(int n, void *data)
104
static void tlbinv_exception(int n, struct exception_regdump *pstate)
110
{
105
{
111
    struct exception_regdump *pstate = (struct exception_regdump *)data;
-
 
112
    tlb_invalid(pstate);
106
    tlb_invalid(pstate);
113
}
107
}
114
 
108
 
115
#ifdef CONFIG_FPU_LAZY
109
#ifdef CONFIG_FPU_LAZY
116
static void cpuns_exception(int n, void *data)
110
static void cpuns_exception(int n, struct exception_regdump *pstate)
117
{
111
{
118
    if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
112
    if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
119
        scheduler_fpu_lazy_request();
113
        scheduler_fpu_lazy_request();
120
    else
114
    else
121
        panic("unhandled Coprocessor Unusable Exception\n");
115
        panic("unhandled Coprocessor Unusable Exception\n");
122
}
116
}
123
#endif
117
#endif
124
 
118
 
125
static void interrupt_exception(int n, void *pstate)
119
static void interrupt_exception(int n, struct exception_regdump *pstate)
126
{
120
{
127
    __u32 cause;
121
    __u32 cause;
128
    int i;
122
    int i;
129
   
123
   
130
    /* decode interrupt number and process the interrupt */
124
    /* decode interrupt number and process the interrupt */
Line 135... Line 129...
135
            exc_dispatch(i+INT_OFFSET, pstate);
129
            exc_dispatch(i+INT_OFFSET, pstate);
136
}
130
}
137
 
131
 
138
#include <debug.h>
132
#include <debug.h>
139
/** Handle syscall userspace call */
133
/** Handle syscall userspace call */
140
static void syscall_exception(int n, void *data)
134
static void syscall_exception(int n, struct exception_regdump *pstate)
141
{
135
{
142
    struct exception_regdump *pstate = (struct exception_regdump *)data;
-
 
143
   
-
 
144
    if (pstate->a3 < SYSCALL_END)
136
    if (pstate->a3 < SYSCALL_END)
145
        pstate->v0 = syscall_table[pstate->a3](pstate->a0,
137
        pstate->v0 = syscall_table[pstate->a3](pstate->a0,
146
                               pstate->a1,
138
                               pstate->a1,
147
                               pstate->a2);
139
                               pstate->a2);
148
    else
140
    else
Line 195... Line 187...
195
{
187
{
196
    int i;
188
    int i;
197
 
189
 
198
    /* Clear exception table */
190
    /* Clear exception table */
199
    for (i=0;i < IVT_ITEMS; i++)
191
    for (i=0;i < IVT_ITEMS; i++)
200
        exc_register(i, "undef", unhandled_exception);
192
        exc_register(i, "undef", (iroutine) unhandled_exception);
201
    exc_register(EXC_Bp, "bkpoint", breakpoint_exception);
193
    exc_register(EXC_Bp, "bkpoint", (iroutine) breakpoint_exception);
202
    exc_register(EXC_Mod, "tlb_mod", tlbmod_exception);
194
    exc_register(EXC_Mod, "tlb_mod", (iroutine) tlbmod_exception);
203
    exc_register(EXC_TLBL, "tlbinvl", tlbinv_exception);
195
    exc_register(EXC_TLBL, "tlbinvl", (iroutine) tlbinv_exception);
204
    exc_register(EXC_TLBS, "tlbinvl", tlbinv_exception);
196
    exc_register(EXC_TLBS, "tlbinvl", (iroutine) tlbinv_exception);
205
    exc_register(EXC_Int, "interrupt", interrupt_exception);
197
    exc_register(EXC_Int, "interrupt", (iroutine) interrupt_exception);
206
#ifdef CONFIG_FPU_LAZY
198
#ifdef CONFIG_FPU_LAZY
207
    exc_register(EXC_CpU, "cpunus", cpuns_exception);
199
    exc_register(EXC_CpU, "cpunus", (iroutine) cpuns_exception);
208
#endif
200
#endif
209
    exc_register(EXC_Sys, "syscall", syscall_exception);
201
    exc_register(EXC_Sys, "syscall", (iroutine) syscall_exception);
210
}
202
}