Rev 3431 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3431 | Rev 4377 | ||
|---|---|---|---|
| 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 107... | Line 106... | ||
| 107 | { |
106 | { |
| 108 | fault_if_from_uspace(istate, "Unhandled exception %d.", n); |
107 | fault_if_from_uspace(istate, "Unhandled exception %d.", n); |
| 109 | panic("Unhandled exception %d.", n); |
108 | panic("Unhandled exception %d.", n); |
| 110 | } |
109 | } |
| 111 | 110 | ||
| - | 111 | #ifdef CONFIG_KCONSOLE |
|
| - | 112 | ||
| 112 | /** kconsole cmd - print all exceptions */ |
113 | /** kconsole cmd - print all exceptions */ |
| 113 | static int exc_print_cmd(cmd_arg_t *argv) |
114 | static int cmd_exc_print(cmd_arg_t *argv) |
| 114 | { |
115 | { |
| 115 | #if (IVT_ITEMS > 0) |
116 | #if (IVT_ITEMS > 0) |
| 116 | unsigned int i; |
117 | unsigned int i; |
| 117 | char *symbol; |
118 | char *symbol; |
| 118 | 119 | ||
| Line 127... | Line 128... | ||
| 127 | printf("Exc Description Handler Symbol\n"); |
128 | printf("Exc Description Handler Symbol\n"); |
| 128 | printf("--- -------------------- ------------------ --------\n"); |
129 | printf("--- -------------------- ------------------ --------\n"); |
| 129 | #endif |
130 | #endif |
| 130 | 131 | ||
| 131 | for (i = 0; i < IVT_ITEMS; i++) { |
132 | for (i = 0; i < IVT_ITEMS; i++) { |
| 132 | symbol = get_symtab_entry((unative_t) exc_table[i].f); |
133 | symbol = symtab_fmt_name_lookup((unative_t) exc_table[i].f); |
| 133 | if (!symbol) |
- | |
| 134 | symbol = "not found"; |
- | |
| 135 | 134 | ||
| 136 | #ifdef __32_BITS__ |
135 | #ifdef __32_BITS__ |
| 137 | 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, |
| 138 | exc_table[i].f, symbol); |
137 | exc_table[i].f, symbol); |
| 139 | #endif |
138 | #endif |
| Line 144... | Line 143... | ||
| 144 | #endif |
143 | #endif |
| 145 | 144 | ||
| 146 | if (((i + 1) % 20) == 0) { |
145 | if (((i + 1) % 20) == 0) { |
| 147 | printf(" -- Press any key to continue -- "); |
146 | printf(" -- Press any key to continue -- "); |
| 148 | spinlock_unlock(&exctbl_lock); |
147 | spinlock_unlock(&exctbl_lock); |
| 149 | getc(stdin); |
148 | indev_pop_character(stdin); |
| 150 | spinlock_lock(&exctbl_lock); |
149 | spinlock_lock(&exctbl_lock); |
| 151 | printf("\n"); |
150 | printf("\n"); |
| 152 | } |
151 | } |
| 153 | } |
152 | } |
| 154 | 153 | ||
| Line 156... | Line 155... | ||
| 156 | #endif |
155 | #endif |
| 157 | 156 | ||
| 158 | return 1; |
157 | return 1; |
| 159 | } |
158 | } |
| 160 | 159 | ||
| - | 160 | ||
| 161 | static cmd_info_t exc_info = { |
161 | static cmd_info_t exc_info = { |
| 162 | .name = "exc", |
162 | .name = "exc", |
| 163 | .description = "Print exception table.", |
163 | .description = "Print exception table.", |
| 164 | .func = exc_print_cmd, |
164 | .func = cmd_exc_print, |
| 165 | .help = NULL, |
165 | .help = NULL, |
| 166 | .argc = 0, |
166 | .argc = 0, |
| 167 | .argv = NULL |
167 | .argv = NULL |
| 168 | }; |
168 | }; |
| 169 | 169 | ||
| - | 170 | #endif |
|
| - | 171 | ||
| 170 | /** Initialize generic exception handling support */ |
172 | /** Initialize generic exception handling support */ |
| 171 | void exc_init(void) |
173 | void exc_init(void) |
| 172 | { |
174 | { |
| 173 | int i; |
175 | int i; |
| 174 | 176 | ||
| 175 | for (i = 0; i < IVT_ITEMS; i++) |
177 | for (i = 0; i < IVT_ITEMS; i++) |
| 176 | exc_register(i, "undef", (iroutine) exc_undef); |
178 | exc_register(i, "undef", (iroutine) exc_undef); |
| 177 | 179 | ||
| - | 180 | #ifdef CONFIG_KCONSOLE |
|
| 178 | cmd_initialize(&exc_info); |
181 | cmd_initialize(&exc_info); |
| 179 | if (!cmd_register(&exc_info)) |
182 | if (!cmd_register(&exc_info)) |
| 180 | panic("could not register command %s\n", exc_info.name); |
183 | printf("Cannot register command %s\n", exc_info.name); |
| - | 184 | #endif |
|
| 181 | } |
185 | } |
| 182 | 186 | ||
| 183 | /** @} |
187 | /** @} |
| 184 | */ |
188 | */ |