Rev 825 | Rev 1021 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 825 | Rev 958 | ||
|---|---|---|---|
| Line 40... | Line 40... | ||
| 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 | /* |
- | |
| 46 | static void messy_stack_trace(__native *stack) |
- | |
| 47 | { |
- | |
| 48 | __native *upper_limit = (__native *)(((__native)get_stack_base()) + STACK_SIZE); |
- | |
| 49 | char *symbol; |
- | |
| 50 | - | ||
| 51 | printf("Stack contents: "); |
- | |
| 52 | while (stack < upper_limit) { |
- | |
| 53 | symbol = get_symtab_entry((__address)*stack); |
- | |
| 54 | if (symbol) |
- | |
| 55 | printf("%s, ", symbol); |
- | |
| 56 | stack++; |
- | |
| 57 | } |
- | |
| 58 | printf("\n"); |
- | |
| 59 | } |
- | |
| 60 | */ |
- | |
| 61 | - | ||
| 62 | static void print_info_errcode(int n, struct interrupt_context *ctx) |
45 | static void print_info_errcode(int n, istate_t *istate) |
| 63 | { |
46 | { |
| 64 | char *symbol; |
47 | char *symbol; |
| 65 | __u64 *x = &ctx->stack[0]; |
48 | __u64 *x = &istate->stack[0]; |
| 66 | 49 | ||
| 67 | if (!(symbol=get_symtab_entry(x[1]))) |
50 | if (!(symbol=get_symtab_entry(x[1]))) |
| 68 | symbol = ""; |
51 | symbol = ""; |
| 69 | 52 | ||
| 70 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); |
53 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); |
| 71 | printf("%%rip: %Q (%s)\n",ctx->stack[1],symbol); |
54 | printf("%%rip: %Q (%s)\n",istate->stack[1],symbol); |
| 72 | printf("ERROR_WORD=%Q\n", ctx->stack[0]); |
55 | printf("ERROR_WORD=%Q\n", istate->stack[0]); |
| 73 | printf("%%rcs=%Q,flags=%Q, %%cr0=%Q\n", ctx->stack[2], |
56 | printf("%%rcs=%Q,flags=%Q, %%cr0=%Q\n", istate->stack[2], |
| 74 | ctx->stack[3],read_cr0()); |
57 | istate->stack[3],read_cr0()); |
| 75 | printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",ctx->rax,ctx->rbx,ctx->rcx); |
58 | printf("%%rax=%Q, %%rbx=%Q, %%rcx=%Q\n",istate->rax,istate->rbx,istate->rcx); |
| 76 | printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",ctx->rdx,ctx->rsi,ctx->rdi); |
59 | printf("%%rdx=%Q, %%rsi=%Q, %%rdi=%Q\n",istate->rdx,istate->rsi,istate->rdi); |
| 77 | printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",ctx->r8,ctx->r9,ctx->r10); |
60 | printf("%%r8 =%Q, %%r9 =%Q, %%r10=%Q\n",istate->r8,istate->r9,istate->r10); |
| 78 | printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",ctx->r11,ctx->r12,ctx->r13); |
61 | printf("%%r11=%Q, %%r12=%Q, %%r13=%Q\n",istate->r11,istate->r12,istate->r13); |
| 79 | printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",ctx->r14,ctx->r15,&ctx->stack[0]); |
62 | printf("%%r14=%Q, %%r15=%Q, %%rsp=%Q\n",istate->r14,istate->r15,&istate->stack[0]); |
| 80 | printf("%%rbp=%Q\n",ctx->rbp); |
63 | printf("%%rbp=%Q\n",istate->rbp); |
| 81 | printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); |
64 | printf("stack: %Q, %Q, %Q\n", x[5], x[6], x[7]); |
| 82 | printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); |
65 | printf(" %Q, %Q, %Q\n", x[8], x[9], x[10]); |
| 83 | printf(" %Q, %Q, %Q\n", x[11], x[12], x[13]); |
66 | printf(" %Q, %Q, %Q\n", x[11], x[12], x[13]); |
| 84 | printf(" %Q, %Q, %Q\n", x[14], x[15], x[16]); |
67 | printf(" %Q, %Q, %Q\n", x[14], x[15], x[16]); |
| 85 | // messy_stack_trace(&x[5]); |
- | |
| 86 | } |
68 | } |
| 87 | 69 | ||
| 88 | /* |
70 | /* |
| 89 | * Interrupt and exception dispatching. |
71 | * Interrupt and exception dispatching. |
| 90 | */ |
72 | */ |
| 91 | 73 | ||
| 92 | void (* disable_irqs_function)(__u16 irqmask) = NULL; |
74 | void (* disable_irqs_function)(__u16 irqmask) = NULL; |
| 93 | void (* enable_irqs_function)(__u16 irqmask) = NULL; |
75 | void (* enable_irqs_function)(__u16 irqmask) = NULL; |
| 94 | void (* eoi_function)(void) = NULL; |
76 | void (* eoi_function)(void) = NULL; |
| 95 | 77 | ||
| 96 | void null_interrupt(int n, struct interrupt_context *ctx) |
78 | void null_interrupt(int n, istate_t *istate) |
| 97 | { |
79 | { |
| 98 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \ |
80 | printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n",n,__FUNCTION__); \ |
| 99 | printf("stack: %X, %X, %X, %X\n", ctx->stack[0], ctx->stack[1], |
81 | printf("stack: %X, %X, %X, %X\n", istate->stack[0], istate->stack[1], |
| 100 | ctx->stack[2], ctx->stack[3]); |
82 | istate->stack[2], istate->stack[3]); |
| 101 | panic("unserviced interrupt\n"); |
83 | panic("unserviced interrupt\n"); |
| 102 | } |
84 | } |
| 103 | 85 | ||
| 104 | void gp_fault(int n, void *stack) |
86 | void gp_fault(int n, istate_t *istate) |
| 105 | { |
87 | { |
| 106 | print_info_errcode(n,stack); |
88 | print_info_errcode(n, istate); |
| 107 | panic("general protection fault\n"); |
89 | panic("general protection fault\n"); |
| 108 | } |
90 | } |
| 109 | 91 | ||
| 110 | void ss_fault(int n, void *stack) |
92 | void ss_fault(int n, istate_t *istate) |
| 111 | { |
93 | { |
| 112 | print_info_errcode(n,stack); |
94 | print_info_errcode(n, istate); |
| 113 | panic("stack fault\n"); |
95 | panic("stack fault\n"); |
| 114 | } |
96 | } |
| 115 | 97 | ||
| 116 | 98 | ||
| 117 | void nm_fault(int n, void *stack) |
99 | void nm_fault(int n, istate_t *istate) |
| 118 | { |
100 | { |
| 119 | #ifdef CONFIG_FPU_LAZY |
101 | #ifdef CONFIG_FPU_LAZY |
| 120 | scheduler_fpu_lazy_request(); |
102 | scheduler_fpu_lazy_request(); |
| 121 | #else |
103 | #else |
| 122 | panic("fpu fault"); |
104 | panic("fpu fault"); |
| 123 | #endif |
105 | #endif |
| 124 | } |
106 | } |
| 125 | 107 | ||
| 126 | void page_fault(int n, struct interrupt_context *ctx) |
108 | void page_fault(int n, istate_t *istate) |
| 127 | { |
109 | { |
| 128 | __address page; |
110 | __address page; |
| 129 | 111 | ||
| 130 | page = read_cr2(); |
112 | page = read_cr2(); |
| 131 | if (!as_page_fault(page)) { |
113 | if (!as_page_fault(page)) { |
| 132 | print_info_errcode(n,ctx); |
114 | print_info_errcode(n, istate); |
| 133 | printf("Page fault address: %Q\n", page); |
115 | printf("Page fault address: %Q\n", page); |
| 134 | panic("page fault\n"); |
116 | panic("page fault\n"); |
| 135 | } |
117 | } |
| 136 | } |
118 | } |
| 137 | 119 | ||
| 138 | void tlb_shootdown_ipi(int n, void *stack) |
120 | void tlb_shootdown_ipi(int n, istate_t *istate) |
| 139 | { |
121 | { |
| 140 | trap_virtual_eoi(); |
122 | trap_virtual_eoi(); |
| 141 | tlb_shootdown_ipi_recv(); |
123 | tlb_shootdown_ipi_recv(); |
| 142 | } |
124 | } |
| 143 | 125 | ||