Rev 268 | Rev 286 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 268 | Rev 282 | ||
---|---|---|---|
Line 35... | Line 35... | ||
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 <arch.h> |
38 | #include <arch.h> |
39 | #include <symtab.h> |
39 | #include <symtab.h> |
- | 40 | #include <arch/asm.h> |
|
40 | 41 | ||
41 | #define PRINT_INFO_ERRCODE(x) { \ |
42 | #define PRINT_INFO_ERRCODE(n,x) { \ |
42 | char *symbol = get_symtab_entry(stack[1]); \ |
43 | char *symbol = get_symtab_entry(stack[1]); \ |
43 | if (!symbol) \ |
44 | if (!symbol) \ |
44 | symbol = ""; \ |
45 | symbol = ""; \ |
45 | printf("----------------EXCEPTION OCCURED----------------\n"); \ |
46 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \ |
46 | printf("%%rip: %Q (%s)\n",x[1],symbol); \ |
47 | printf("%%rip: %Q (%s)\n",x[1],symbol); \ |
47 | printf("ERROR_WORD=%Q\n", x[0]); \ |
48 | printf("ERROR_WORD=%Q\n", x[0]); \ |
48 | printf("%%rcs=%Q,flags=%Q\n", x[2], x[3]); \ |
49 | printf("%%rcs=%Q,flags=%Q, %%cr0=%Q\n", x[2], x[3],read_cr0()); \ |
49 | printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",x[-1],x[-2],x[-3]); \ |
50 | printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",x[-2],x[-3],x[-4]); \ |
50 | printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",x[-4],x[-5],x[-6]); \ |
51 | printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",x[-5],x[-6],x[-7]); \ |
51 | printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",x[-7],x[-8],x[-9]); \ |
52 | printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",x[-8],x[-9],x[-10]); \ |
52 | printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",x[-10],x[-11],x[-12]); \ |
53 | printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",x[-11],x[-12],x[-13]); \ |
53 | printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",x[-13],x[-14],x); \ |
54 | printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",x[-14],x[-15],x); \ |
- | 55 | printf("%%rbp=%Q\n",x[-1]); \ |
|
54 | printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); \ |
56 | printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); \ |
55 | printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); \ |
57 | printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); \ |
- | 58 | printf(" %Q, %Q, %Q\n", x[11], x[12], x[13]); \ |
|
- | 59 | printf(" %Q, %Q, %Q\n", x[14], x[15], x[16]); \ |
|
- | 60 | printf(" %Q, %Q, %Q\n", x[17], x[18], x[19]); \ |
|
- | 61 | printf(" %Q, %Q, %Q\n", x[20], x[21], x[22]); \ |
|
- | 62 | printf(" %Q, %Q, %Q\n", x[23], x[24], x[25]); \ |
|
56 | } |
63 | } |
57 | 64 | ||
58 | /* |
65 | /* |
59 | * Interrupt and exception dispatching. |
66 | * Interrupt and exception dispatching. |
60 | */ |
67 | */ |
Line 88... | Line 95... | ||
88 | ivt[n](n, stack); |
95 | ivt[n](n, stack); |
89 | } |
96 | } |
90 | 97 | ||
91 | void null_interrupt(__u8 n, __native stack[]) |
98 | void null_interrupt(__u8 n, __native stack[]) |
92 | { |
99 | { |
93 | printf("----------------EXCEPTION OCCURED----------------\n"); |
100 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \ |
94 | printf("int %d: null_interrupt\n", n); |
- | |
95 | printf("stack: %L, %L, %L, %L\n", stack[0], stack[1], stack[2], stack[3]); |
101 | printf("stack: %L, %L, %L, %L\n", stack[0], stack[1], stack[2], stack[3]); |
96 | panic("unserviced interrupt\n"); |
102 | panic("unserviced interrupt\n"); |
97 | } |
103 | } |
98 | 104 | ||
99 | void gp_fault(__u8 n, __native stack[]) |
105 | void gp_fault(__u8 n, __native stack[]) |
100 | { |
106 | { |
101 | PRINT_INFO_ERRCODE(stack); |
107 | PRINT_INFO_ERRCODE(n,stack); |
102 | panic("general protection fault\n"); |
108 | panic("general protection fault\n"); |
103 | } |
109 | } |
104 | 110 | ||
105 | void ss_fault(__u8 n, __native stack[]) |
111 | void ss_fault(__u8 n, __native stack[]) |
106 | { |
112 | { |
107 | PRINT_INFO_ERRCODE(stack); |
113 | PRINT_INFO_ERRCODE(n,stack); |
108 | panic("stack fault\n"); |
114 | panic("stack fault\n"); |
109 | } |
115 | } |
110 | 116 | ||
111 | 117 | ||
112 | void nm_fault(__u8 n, __native stack[]) |
118 | void nm_fault(__u8 n, __native stack[]) |
113 | { |
119 | { |
114 | reset_TS_flag(); |
120 | reset_TS_flag(); |
115 | if ((CPU->fpu_owner)!=NULL) { |
121 | if (CPU->fpu_owner != NULL) { |
116 | fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context)); |
122 | fpu_lazy_context_save(&CPU->fpu_owner->saved_fpu_context); |
- | 123 | /* don't prevent migration */ |
|
117 | (CPU->fpu_owner)->fpu_context_engaged=0; /* don't prevent migration */ |
124 | CPU->fpu_owner->fpu_context_engaged=0; |
- | 125 | } |
|
- | 126 | if (THREAD->fpu_context_exists) |
|
- | 127 | fpu_lazy_context_restore(&THREAD->saved_fpu_context); |
|
- | 128 | else { |
|
- | 129 | fpu_init(); |
|
- | 130 | THREAD->fpu_context_exists=1; |
|
118 | } |
131 | } |
119 | if(THREAD->fpu_context_exists) fpu_lazy_context_restore(&(THREAD->saved_fpu_context)); |
- | |
120 | else {fpu_init();THREAD->fpu_context_exists=1;} |
- | |
121 | CPU->fpu_owner=THREAD; |
132 | CPU->fpu_owner=THREAD; |
122 | } |
133 | } |
123 | 134 | ||
124 | 135 | ||
125 | 136 | ||
126 | void page_fault(__u8 n, __native stack[]) |
137 | void page_fault(__u8 n, __native stack[]) |
127 | { |
138 | { |
128 | PRINT_INFO_ERRCODE(stack); |
139 | PRINT_INFO_ERRCODE(n,stack); |
129 | printf("Page fault address: %Q\n", read_cr2()); |
140 | printf("Page fault address: %Q\n", read_cr2()); |
130 | panic("page fault\n"); |
141 | panic("page fault\n"); |
131 | } |
142 | } |
132 | 143 | ||
133 | void syscall(__u8 n, __native stack[]) |
144 | void syscall(__u8 n, __native stack[]) |