Rev 3386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4153 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | 40 | ||
41 | #include <interrupt.h> |
41 | #include <interrupt.h> |
42 | #include <debug.h> |
42 | #include <debug.h> |
43 | #include <console/kconsole.h> |
43 | #include <console/kconsole.h> |
44 | #include <console/console.h> |
44 | #include <console/console.h> |
45 | #include <console/chardev.h> |
- | |
46 | #include <console/cmd.h> |
45 | #include <console/cmd.h> |
47 | #include <panic.h> |
46 | #include <panic.h> |
48 | #include <print.h> |
47 | #include <print.h> |
49 | #include <symtab.h> |
48 | #include <symtab.h> |
50 | 49 | ||
Line 66... | Line 65... | ||
66 | ASSERT(n < IVT_ITEMS); |
65 | ASSERT(n < IVT_ITEMS); |
67 | 66 | ||
68 | iroutine old; |
67 | iroutine old; |
69 | 68 | ||
70 | spinlock_lock(&exctbl_lock); |
69 | spinlock_lock(&exctbl_lock); |
71 | 70 | ||
72 | old = exc_table[n].f; |
71 | old = exc_table[n].f; |
73 | exc_table[n].f = f; |
72 | exc_table[n].f = f; |
74 | exc_table[n].name = name; |
73 | exc_table[n].name = name; |
75 | 74 | ||
76 | spinlock_unlock(&exctbl_lock); |
75 | spinlock_unlock(&exctbl_lock); |
77 | 76 | ||
78 | return old; |
77 | return old; |
79 | } |
78 | } |
80 | 79 | ||
81 | /** Dispatch exception according to exception table |
80 | /** Dispatch exception according to exception table |
82 | * |
81 | * |
Line 84... | Line 83... | ||
84 | * CPU is interrupts_disable()'d. |
83 | * CPU is interrupts_disable()'d. |
85 | */ |
84 | */ |
86 | void exc_dispatch(int n, istate_t *istate) |
85 | void exc_dispatch(int n, istate_t *istate) |
87 | { |
86 | { |
88 | ASSERT(n < IVT_ITEMS); |
87 | ASSERT(n < IVT_ITEMS); |
- | 88 | ||
- | 89 | #ifdef CONFIG_UDEBUG |
|
- | 90 | if (THREAD) THREAD->udebug.uspace_state = istate; |
|
- | 91 | #endif |
|
89 | 92 | ||
90 | exc_table[n].f(n + IVT_FIRST, istate); |
93 | exc_table[n].f(n + IVT_FIRST, istate); |
- | 94 | ||
- | 95 | #ifdef CONFIG_UDEBUG |
|
- | 96 | if (THREAD) THREAD->udebug.uspace_state = NULL; |
|
- | 97 | #endif |
|
- | 98 | ||
91 | /* This is a safe place to exit exiting thread */ |
99 | /* This is a safe place to exit exiting thread */ |
92 | if (THREAD && THREAD->interrupted && istate_from_uspace(istate)) |
100 | if (THREAD && THREAD->interrupted && istate_from_uspace(istate)) |
93 | thread_exit(); |
101 | thread_exit(); |
94 | } |
102 | } |
95 | 103 | ||
Line 98... | Line 106... | ||
98 | { |
106 | { |
99 | fault_if_from_uspace(istate, "Unhandled exception %d.", n); |
107 | fault_if_from_uspace(istate, "Unhandled exception %d.", n); |
100 | panic("Unhandled exception %d.", n); |
108 | panic("Unhandled exception %d.", n); |
101 | } |
109 | } |
102 | 110 | ||
- | 111 | #ifdef CONFIG_KCONSOLE |
|
- | 112 | ||
103 | /** kconsole cmd - print all exceptions */ |
113 | /** kconsole cmd - print all exceptions */ |
104 | static int exc_print_cmd(cmd_arg_t *argv) |
114 | static int cmd_exc_print(cmd_arg_t *argv) |
105 | { |
115 | { |
106 | #if (IVT_ITEMS > 0) |
116 | #if (IVT_ITEMS > 0) |
107 | unsigned int i; |
117 | unsigned int i; |
108 | char *symbol; |
118 | char *symbol; |
109 | 119 | ||
Line 118... | Line 128... | ||
118 | printf("Exc Description Handler Symbol\n"); |
128 | printf("Exc Description Handler Symbol\n"); |
119 | printf("--- -------------------- ------------------ --------\n"); |
129 | printf("--- -------------------- ------------------ --------\n"); |
120 | #endif |
130 | #endif |
121 | 131 | ||
122 | for (i = 0; i < IVT_ITEMS; i++) { |
132 | for (i = 0; i < IVT_ITEMS; i++) { |
123 | symbol = get_symtab_entry((unative_t) exc_table[i].f); |
133 | symbol = symtab_fmt_name_lookup((unative_t) exc_table[i].f); |
124 | if (!symbol) |
- | |
125 | symbol = "not found"; |
- | |
126 | 134 | ||
127 | #ifdef __32_BITS__ |
135 | #ifdef __32_BITS__ |
128 | printf("%-3u %-20s %10p %s\n", i + IVT_FIRST, exc_table[i].name, |
136 | printf("%-3u %-20s %10p %s\n", i + IVT_FIRST, exc_table[i].name, |
129 | exc_table[i].f, symbol); |
137 | exc_table[i].f, symbol); |
130 | #endif |
138 | #endif |
Line 135... | Line 143... | ||
135 | #endif |
143 | #endif |
136 | 144 | ||
137 | if (((i + 1) % 20) == 0) { |
145 | if (((i + 1) % 20) == 0) { |
138 | printf(" -- Press any key to continue -- "); |
146 | printf(" -- Press any key to continue -- "); |
139 | spinlock_unlock(&exctbl_lock); |
147 | spinlock_unlock(&exctbl_lock); |
140 | getc(stdin); |
148 | _getc(stdin); |
141 | spinlock_lock(&exctbl_lock); |
149 | spinlock_lock(&exctbl_lock); |
142 | printf("\n"); |
150 | printf("\n"); |
143 | } |
151 | } |
144 | } |
152 | } |
145 | 153 | ||
Line 147... | Line 155... | ||
147 | #endif |
155 | #endif |
148 | 156 | ||
149 | return 1; |
157 | return 1; |
150 | } |
158 | } |
151 | 159 | ||
- | 160 | ||
152 | static cmd_info_t exc_info = { |
161 | static cmd_info_t exc_info = { |
153 | .name = "exc", |
162 | .name = "exc", |
154 | .description = "Print exception table.", |
163 | .description = "Print exception table.", |
155 | .func = exc_print_cmd, |
164 | .func = cmd_exc_print, |
156 | .help = NULL, |
165 | .help = NULL, |
157 | .argc = 0, |
166 | .argc = 0, |
158 | .argv = NULL |
167 | .argv = NULL |
159 | }; |
168 | }; |
160 | 169 | ||
- | 170 | #endif |
|
- | 171 | ||
161 | /** Initialize generic exception handling support */ |
172 | /** Initialize generic exception handling support */ |
162 | void exc_init(void) |
173 | void exc_init(void) |
163 | { |
174 | { |
164 | int i; |
175 | int i; |
165 | 176 | ||
166 | for (i = 0; i < IVT_ITEMS; i++) |
177 | for (i = 0; i < IVT_ITEMS; i++) |
167 | exc_register(i, "undef", (iroutine) exc_undef); |
178 | exc_register(i, "undef", (iroutine) exc_undef); |
168 | 179 | ||
- | 180 | #ifdef CONFIG_KCONSOLE |
|
169 | cmd_initialize(&exc_info); |
181 | cmd_initialize(&exc_info); |
170 | if (!cmd_register(&exc_info)) |
182 | if (!cmd_register(&exc_info)) |
171 | panic("could not register command %s\n", exc_info.name); |
183 | printf("Cannot register command %s\n", exc_info.name); |
- | 184 | #endif |
|
172 | } |
185 | } |
173 | 186 | ||
174 | /** @} |
187 | /** @} |
175 | */ |
188 | */ |