Subversion Repositories HelenOS

Rev

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

Rev 2787 Rev 4377
Line 42... Line 42...
42
#include <cpu.h>
42
#include <cpu.h>
43
#include <arch/asm.h>
43
#include <arch/asm.h>
44
#include <mm/tlb.h>
44
#include <mm/tlb.h>
45
#include <mm/as.h>
45
#include <mm/as.h>
46
#include <arch.h>
46
#include <arch.h>
47
#include <symtab.h>
-
 
48
#include <proc/thread.h>
47
#include <proc/thread.h>
49
#include <proc/task.h>
48
#include <proc/task.h>
50
#include <synch/spinlock.h>
49
#include <synch/spinlock.h>
51
#include <arch/ddi/ddi.h>
50
#include <arch/ddi/ddi.h>
52
#include <ipc/sysipc.h>
51
#include <ipc/sysipc.h>
53
#include <interrupt.h>
52
#include <interrupt.h>
54
#include <ddi/irq.h>
53
#include <ddi/irq.h>
-
 
54
#include <symtab.h>
55
 
55
 
56
/*
56
/*
57
 * Interrupt and exception dispatching.
57
 * Interrupt and exception dispatching.
58
 */
58
 */
59
 
59
 
Line 61... Line 61...
61
void (* enable_irqs_function)(uint16_t irqmask) = NULL;
61
void (* enable_irqs_function)(uint16_t irqmask) = NULL;
62
void (* eoi_function)(void) = NULL;
62
void (* eoi_function)(void) = NULL;
63
 
63
 
64
void decode_istate(istate_t *istate)
64
void decode_istate(istate_t *istate)
65
{
65
{
66
    char *symbol = get_symtab_entry(istate->eip);
66
    char *symbol;
67
 
67
 
68
    if (!symbol)
-
 
69
        symbol = "";
68
    symbol = symtab_fmt_name_lookup(istate->eip);
70
 
69
 
71
    if (CPU)
70
    if (CPU)
72
        printf("----------------EXCEPTION OCCURED (cpu%u)----------------\n", CPU->id);
71
        printf("----------------EXCEPTION OCCURED (cpu%u)----------------\n", CPU->id);
73
    else
72
    else
74
        printf("----------------EXCEPTION OCCURED----------------\n");
73
        printf("----------------EXCEPTION OCCURED----------------\n");
75
       
74
       
76
    printf("%%eip: %#lx (%s)\n", istate->eip, symbol);
75
    printf("%%eip: %#lx (%s)\n", istate->eip, symbol);
77
    printf("ERROR_WORD=%#lx\n", istate->error_word);
76
    printf("ERROR_WORD=%#lx\n", istate->error_word);
78
    printf("%%cs=%#lx,flags=%#lx\n", istate->cs, istate->eflags);
77
    printf("%%cs=%#lx,flags=%#lx\n", istate->cs, istate->eflags);
79
    printf("%%eax=%#lx, %%ecx=%#lx, %%edx=%#lx, %%esp=%p\n", istate->eax, istate->ecx, istate->edx, &istate->stack[0]);
78
    printf("%%eax=%#lx, %%ecx=%#lx, %%edx=%#lx, %%esp=%p\n", istate->eax, istate->ecx, istate->edx, &istate->stack[0]);
80
#ifdef CONFIG_DEBUG_ALLREGS
-
 
81
    printf("%%esi=%#lx, %%edi=%#lx, %%ebp=%#lx, %%ebx=%#lx\n", istate->esi, istate->edi, istate->ebp, istate->ebx);
-
 
82
#endif
-
 
83
    printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]);
79
    printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]);
84
    printf("       %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]);
80
    printf("       %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]);
85
}
81
}
86
 
82
 
87
static void trap_virtual_eoi(void)
83
static void trap_virtual_eoi(void)
88
{
84
{
89
    if (eoi_function)
85
    if (eoi_function)
90
        eoi_function();
86
        eoi_function();
91
    else
87
    else
92
        panic("no eoi_function\n");
88
        panic("No eoi_function.");
93
 
89
 
94
}
90
}
95
 
91
 
96
static void null_interrupt(int n, istate_t *istate)
92
static void null_interrupt(int n, istate_t *istate)
97
{
93
{
98
    fault_if_from_uspace(istate, "unserviced interrupt: %d", n);
94
    fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n);
99
 
95
 
100
    decode_istate(istate);
96
    decode_istate(istate);
101
    panic("unserviced interrupt: %d\n", n);
97
    panic("Unserviced interrupt: %d.", n);
102
}
98
}
103
 
99
 
104
/** General Protection Fault. */
100
/** General Protection Fault. */
105
static void gp_fault(int n __attribute__((unused)), istate_t *istate)
101
static void gp_fault(int n __attribute__((unused)), istate_t *istate)
106
{
102
{
Line 120... Line 116...
120
             * the instruction.
116
             * the instruction.
121
             */
117
             */
122
            io_perm_bitmap_install();
118
            io_perm_bitmap_install();
123
            return;
119
            return;
124
        }
120
        }
125
        fault_if_from_uspace(istate, "general protection fault");
121
        fault_if_from_uspace(istate, "General protection fault.");
126
    }
122
    }
127
 
123
 
128
    decode_istate(istate);
124
    decode_istate(istate);
129
    panic("general protection fault\n");
125
    panic("General protection fault.");
130
}
126
}
131
 
127
 
132
static void ss_fault(int n __attribute__((unused)), istate_t *istate)
128
static void ss_fault(int n __attribute__((unused)), istate_t *istate)
133
{
129
{
134
    fault_if_from_uspace(istate, "stack fault");
130
    fault_if_from_uspace(istate, "Stack fault.");
135
 
131
 
136
    decode_istate(istate);
132
    decode_istate(istate);
137
    panic("stack fault\n");
133
    panic("Stack fault.");
138
}
134
}
139
 
135
 
140
static void simd_fp_exception(int n __attribute__((unused)), istate_t *istate)
136
static void simd_fp_exception(int n __attribute__((unused)), istate_t *istate)
141
{
137
{
142
    uint32_t mxcsr;
138
    uint32_t mxcsr;
143
    asm (
139
    asm (
144
        "stmxcsr %0;\n"
140
        "stmxcsr %[mxcsr]\n"
145
        : "=m" (mxcsr)
141
        : [mxcsr] "=m" (mxcsr)
146
    );
142
    );
147
    fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx",
143
    fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR: %#zx.",
148
        (unative_t) mxcsr);
144
        (unative_t) mxcsr);
149
 
145
   
150
    decode_istate(istate);
146
    decode_istate(istate);
151
    printf("MXCSR: %#lx\n", mxcsr);
147
    printf("MXCSR: %#lx\n", mxcsr);
152
    panic("SIMD FP exception(19)\n");
148
    panic("SIMD FP exception(19).");
153
}
149
}
154
 
150
 
155
static void nm_fault(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
151
static void nm_fault(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
156
{
152
{
157
#ifdef CONFIG_FPU_LAZY     
153
#ifdef CONFIG_FPU_LAZY     
158
    scheduler_fpu_lazy_request();
154
    scheduler_fpu_lazy_request();
159
#else
155
#else
160
    fault_if_from_uspace(istate, "fpu fault");
156
    fault_if_from_uspace(istate, "FPU fault.");
161
    panic("fpu fault");
157
    panic("FPU fault.");
162
#endif
158
#endif
163
}
159
}
164
 
160
 
165
#ifdef CONFIG_SMP
161
#ifdef CONFIG_SMP
166
static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
162
static void tlb_shootdown_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
Line 189... Line 185...
189
        if (irq->preack) {
185
        if (irq->preack) {
190
            /* Send EOI before processing the interrupt */
186
            /* Send EOI before processing the interrupt */
191
            trap_virtual_eoi();
187
            trap_virtual_eoi();
192
            ack = true;
188
            ack = true;
193
        }
189
        }
194
        irq->handler(irq, irq->arg);
190
        irq->handler(irq);
195
        spinlock_unlock(&irq->lock);
191
        spinlock_unlock(&irq->lock);
196
    } else {
192
    } else {
197
        /*
193
        /*
198
         * Spurious interrupt.
194
         * Spurious interrupt.
199
         */
195
         */
Line 231... Line 227...
231
void trap_virtual_enable_irqs(uint16_t irqmask)
227
void trap_virtual_enable_irqs(uint16_t irqmask)
232
{
228
{
233
    if (enable_irqs_function)
229
    if (enable_irqs_function)
234
        enable_irqs_function(irqmask);
230
        enable_irqs_function(irqmask);
235
    else
231
    else
236
        panic("no enable_irqs_function\n");
232
        panic("No enable_irqs_function.");
237
}
233
}
238
 
234
 
239
void trap_virtual_disable_irqs(uint16_t irqmask)
235
void trap_virtual_disable_irqs(uint16_t irqmask)
240
{
236
{
241
    if (disable_irqs_function)
237
    if (disable_irqs_function)
242
        disable_irqs_function(irqmask);
238
        disable_irqs_function(irqmask);
243
    else
239
    else
244
        panic("no disable_irqs_function\n");
240
        panic("No disable_irqs_function.");
245
}
241
}
246
 
242
 
247
/** @}
243
/** @}
248
 */
244
 */