Subversion Repositories HelenOS

Rev

Rev 1060 | Rev 1196 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1060 Rev 1100
1
/*
1
/*
2
 * Copyright (C) 2001-2004 Jakub Jermar
2
 * Copyright (C) 2001-2004 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <arch/interrupt.h>
29
#include <arch/interrupt.h>
30
#include <print.h>
30
#include <print.h>
31
#include <debug.h>
31
#include <debug.h>
32
#include <panic.h>
32
#include <panic.h>
33
#include <arch/i8259.h>
33
#include <arch/i8259.h>
34
#include <func.h>
34
#include <func.h>
35
#include <cpu.h>
35
#include <cpu.h>
36
#include <arch/asm.h>
36
#include <arch/asm.h>
37
#include <mm/tlb.h>
37
#include <mm/tlb.h>
38
#include <mm/as.h>
38
#include <mm/as.h>
39
#include <arch.h>
39
#include <arch.h>
40
#include <symtab.h>
40
#include <symtab.h>
41
#include <arch/asm.h>
41
#include <arch/asm.h>
42
#include <proc/scheduler.h>
42
#include <proc/scheduler.h>
43
#include <proc/thread.h>
43
#include <proc/thread.h>
44
 
44
 
45
void print_info_errcode(int n, istate_t *istate)
45
void print_info_errcode(int n, istate_t *istate)
46
{
46
{
47
    char *symbol;
47
    char *symbol;
48
/*  __u64 *x = &istate->stack[0]; */
48
/*  __u64 *x = &istate->stack[0]; */
49
 
49
 
50
    if (!(symbol=get_symtab_entry(istate->rip)))
50
    if (!(symbol=get_symtab_entry(istate->rip)))
51
        symbol = "";
51
        symbol = "";
52
 
52
 
53
    printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n, __FUNCTION__);
53
    printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n, __FUNCTION__);
54
    printf("%%rip: %Q (%s)\n",istate->rip, symbol);
54
    printf("%%rip: %Q (%s)\n",istate->rip, symbol);
55
    printf("ERROR_WORD=%Q\n", istate->error_word);
55
    printf("ERROR_WORD=%Q\n", istate->error_word);
56
    printf("%%rcs=%Q, flags=%Q, %%cr0=%Q\n", istate->cs, istate->rflags,read_cr0());
56
    printf("%%rcs=%Q, flags=%Q, %%cr0=%Q\n", istate->cs, istate->rflags,read_cr0());
57
    printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",istate->rax,istate->rbx,istate->rcx);
57
    printf("%%rax=%Q, %%rcx=%Q, %%rdx=%Q\n",istate->rax,istate->rcx,istate->rdx);
58
    printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",istate->rdx,istate->rsi,istate->rdi);
58
    printf("%%rsi=%Q, %%rdi=%Q, %%r8 =%Q\n",istate->rsi,istate->rdi,istate->r8);
59
    printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",istate->r8,istate->r9,istate->r10);
59
    printf("%%r9 =%Q, %%r10 =%Q, %%r11=%Q\n",istate->r9,istate->r10,istate->r11);
-
 
60
#ifdef CONFIG_DEBUG_ALLREGS 
60
    printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",istate->r11,istate->r12,istate->r13);
61
    printf("%%r12=%Q, %%r13=%Q, %%r14=%Q\n",istate->r12,istate->r13,istate->r14);
61
    printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",istate->r14,istate->r15,&istate->stack[0]);
62
    printf("%%r15=%Q, %%rbx=%Q, %%rbp=%Q\n",istate->r15,istate->rbx,&istate->rbp);
62
    printf("%%rbp=%Q\n",istate->rbp);
-
 
63
/*      
63
#endif
64
    printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]);
-
 
65
    printf("       %Q, %Q, %Q\n", x[8], x[9], x[10]);
64
    printf("%%rsp=%Q\n",&istate->stack[0]);
66
    printf("       %Q, %Q, %Q\n", x[11], x[12], x[13]);
-
 
67
    printf("       %Q, %Q, %Q\n", x[14], x[15], x[16]);
-
 
68
*/
-
 
69
}
65
}
70
 
66
 
71
/*
67
/*
72
 * Interrupt and exception dispatching.
68
 * Interrupt and exception dispatching.
73
 */
69
 */
74
 
70
 
75
void (* disable_irqs_function)(__u16 irqmask) = NULL;
71
void (* disable_irqs_function)(__u16 irqmask) = NULL;
76
void (* enable_irqs_function)(__u16 irqmask) = NULL;
72
void (* enable_irqs_function)(__u16 irqmask) = NULL;
77
void (* eoi_function)(void) = NULL;
73
void (* eoi_function)(void) = NULL;
78
 
74
 
79
void null_interrupt(int n, istate_t *istate)
75
void null_interrupt(int n, istate_t *istate)
80
{
76
{
81
    print_info_errcode(n, istate);
77
    print_info_errcode(n, istate);
82
    panic("unserviced interrupt\n");
78
    panic("unserviced interrupt\n");
83
}
79
}
84
 
80
 
85
void gp_fault(int n, istate_t *istate)
81
void gp_fault(int n, istate_t *istate)
86
{
82
{
87
    print_info_errcode(n, istate);
83
    print_info_errcode(n, istate);
88
    panic("general protection fault\n");
84
    panic("general protection fault\n");
89
}
85
}
90
 
86
 
91
void ss_fault(int n, istate_t *istate)
87
void ss_fault(int n, istate_t *istate)
92
{
88
{
93
    print_info_errcode(n, istate);
89
    print_info_errcode(n, istate);
94
    panic("stack fault\n");
90
    panic("stack fault\n");
95
}
91
}
96
 
92
 
97
void nm_fault(int n, istate_t *istate)
93
void nm_fault(int n, istate_t *istate)
98
{
94
{
99
#ifdef CONFIG_FPU_LAZY     
95
#ifdef CONFIG_FPU_LAZY     
100
    scheduler_fpu_lazy_request();
96
    scheduler_fpu_lazy_request();
101
#else
97
#else
102
    panic("fpu fault");
98
    panic("fpu fault");
103
#endif
99
#endif
104
}
100
}
105
 
101
 
106
void tlb_shootdown_ipi(int n, istate_t *istate)
102
void tlb_shootdown_ipi(int n, istate_t *istate)
107
{
103
{
108
    trap_virtual_eoi();
104
    trap_virtual_eoi();
109
    tlb_shootdown_ipi_recv();
105
    tlb_shootdown_ipi_recv();
110
}
106
}
111
 
107
 
112
void trap_virtual_enable_irqs(__u16 irqmask)
108
void trap_virtual_enable_irqs(__u16 irqmask)
113
{
109
{
114
    if (enable_irqs_function)
110
    if (enable_irqs_function)
115
        enable_irqs_function(irqmask);
111
        enable_irqs_function(irqmask);
116
    else
112
    else
117
        panic("no enable_irqs_function\n");
113
        panic("no enable_irqs_function\n");
118
}
114
}
119
 
115
 
120
void trap_virtual_disable_irqs(__u16 irqmask)
116
void trap_virtual_disable_irqs(__u16 irqmask)
121
{
117
{
122
    if (disable_irqs_function)
118
    if (disable_irqs_function)
123
        disable_irqs_function(irqmask);
119
        disable_irqs_function(irqmask);
124
    else
120
    else
125
        panic("no disable_irqs_function\n");
121
        panic("no disable_irqs_function\n");
126
}
122
}
127
 
123
 
128
void trap_virtual_eoi(void)
124
void trap_virtual_eoi(void)
129
{
125
{
130
    if (eoi_function)
126
    if (eoi_function)
131
        eoi_function();
127
        eoi_function();
132
    else
128
    else
133
        panic("no eoi_function\n");
129
        panic("no eoi_function\n");
134
 
130
 
135
}
131
}
136
 
132