Changeset b3b7e14 in mainline for kernel/generic/src/interrupt/interrupt.c
- Timestamp:
- 2010-06-11T15:31:03Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 214ec25c
- Parents:
- be06914
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/interrupt/interrupt.c
rbe06914 rb3b7e14 61 61 /** Register exception handler 62 62 * 63 * @param n Exception number 64 * @param name Description 65 * @param handler Exception handler 66 * 67 */ 68 iroutine exc_register(int n, const char *name, iroutine handler) 69 { 63 * @param n Exception number. 64 * @param name Description. 65 * @param hot Whether the exception is actually handled 66 * in any meaningful way. 67 * @param handler New exception handler. 68 * 69 * @return Previously registered exception handler. 70 * 71 */ 72 iroutine_t exc_register(unsigned int n, const char *name, bool hot, 73 iroutine_t handler) 74 { 75 #if (IVT_ITEMS > 0) 70 76 ASSERT(n < IVT_ITEMS); 77 #endif 71 78 72 79 irq_spinlock_lock(&exctbl_lock, true); 73 80 74 iroutine old = exc_table[n].f;75 exc_table[n]. f= handler;81 iroutine_t old = exc_table[n].handler; 82 exc_table[n].handler = handler; 76 83 exc_table[n].name = name; 84 exc_table[n].hot = hot; 77 85 exc_table[n].cycles = 0; 78 86 exc_table[n].count = 0; … … 89 97 * 90 98 */ 91 void exc_dispatch(int n, istate_t *istate) 92 { 99 void exc_dispatch(unsigned int n, istate_t *istate) 100 { 101 #if (IVT_ITEMS > 0) 93 102 ASSERT(n < IVT_ITEMS); 103 #endif 94 104 95 105 uint64_t begin_cycle = get_cycle(); … … 107 117 #endif 108 118 109 exc_table[n]. f(n + IVT_FIRST, istate);119 exc_table[n].handler(n + IVT_FIRST, istate); 110 120 111 121 #ifdef CONFIG_UDEBUG … … 185 195 #ifdef CONFIG_KCONSOLE 186 196 197 static char flag_buf[MAX_CMDLINE + 1]; 198 187 199 /** Print all exceptions 188 200 * … … 190 202 static int cmd_exc_print(cmd_arg_t *argv) 191 203 { 204 bool excs_all; 205 206 if (str_cmp(flag_buf, "-a") == 0) 207 excs_all = true; 208 else if (str_cmp(flag_buf, "") == 0) 209 excs_all = false; 210 else { 211 printf("Unknown argument \"%s\".\n", flag_buf); 212 return 1; 213 } 214 192 215 #if (IVT_ITEMS > 0) 193 216 unsigned int i; 217 unsigned int rows; 194 218 195 219 irq_spinlock_lock(&exctbl_lock, true); 196 220 197 221 #ifdef __32_BITS__ 198 printf("Exc Description Count Cycles Handler Symbol\n"); 199 printf("--- -------------------- ---------- ---------- ---------- --------\n"); 222 printf("[exc ] [description ] [count ] [cycles ]" 223 " [handler ] [symbol\n"); 224 rows = 1; 200 225 #endif 201 226 202 227 #ifdef __64_BITS__ 203 printf("Exc Description Count Cycles Handler Symbol\n"); 204 printf("--- -------------------- ---------- ---------- ------------------ --------\n"); 228 printf("[exc ] [description ] [count ] [cycles ]" 229 " [handler ]\n"); 230 printf(" [symbol\n"); 231 rows = 2; 205 232 #endif 206 233 207 234 for (i = 0; i < IVT_ITEMS; i++) { 235 if ((!excs_all) && (!exc_table[i].hot)) 236 continue; 237 208 238 uint64_t count; 209 239 char count_suffix; … … 217 247 218 248 const char *symbol = 219 symtab_fmt_name_lookup((unative_t) exc_table[i]. f);249 symtab_fmt_name_lookup((unative_t) exc_table[i].handler); 220 250 221 251 #ifdef __32_BITS__ 222 printf("%- 3u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %10p %s\n",252 printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %10p %s\n", 223 253 i + IVT_FIRST, exc_table[i].name, count, count_suffix, 224 cycles, cycles_suffix, exc_table[i].f, symbol); 254 cycles, cycles_suffix, exc_table[i].handler, symbol); 255 256 PAGING(rows, 1, irq_spinlock_unlock(&exctbl_lock, true), 257 irq_spinlock_lock(&exctbl_lock, true)); 225 258 #endif 226 259 227 260 #ifdef __64_BITS__ 228 printf("%- 3u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %18p %s\n",261 printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %18p\n", 229 262 i + IVT_FIRST, exc_table[i].name, count, count_suffix, 230 cycles, cycles_suffix, exc_table[i].f, symbol); 231 #endif 232 233 if (((i + 1) % 20) == 0) { 234 printf(" -- Press any key to continue -- "); 235 irq_spinlock_unlock(&exctbl_lock, true); 236 indev_pop_character(stdin); 237 irq_spinlock_lock(&exctbl_lock, true); 238 printf("\n"); 239 } 263 cycles, cycles_suffix, exc_table[i].handler); 264 printf(" %s\n", symbol); 265 266 PAGING(rows, 2, irq_spinlock_unlock(&exctbl_lock, true), 267 irq_spinlock_lock(&exctbl_lock, true)); 268 #endif 240 269 } 241 270 242 271 irq_spinlock_unlock(&exctbl_lock, true); 243 #endif 272 #else /* (IVT_ITEMS > 0) */ 273 274 printf("No exception table%s.\n", excs_all ? " (showing all exceptions)" : ""); 275 276 #endif /* (IVT_ITEMS > 0) */ 244 277 245 278 return 1; 246 279 } 280 281 static cmd_arg_t exc_argv = { 282 .type = ARG_TYPE_STRING_OPTIONAL, 283 .buffer = flag_buf, 284 .len = sizeof(flag_buf) 285 }; 247 286 248 287 static cmd_info_t exc_info = { 249 288 .name = "exc", 250 .description = "Print exception table .",289 .description = "Print exception table (use -a for all exceptions).", 251 290 .func = cmd_exc_print, 252 291 .help = NULL, 253 .argc = 0,254 .argv = NULL292 .argc = 1, 293 .argv = &exc_argv 255 294 }; 256 295 … … 268 307 269 308 for (i = 0; i < IVT_ITEMS; i++) 270 exc_register(i, "undef", (iroutine) exc_undef);309 exc_register(i, "undef", false, (iroutine_t) exc_undef); 271 310 #endif 272 311
Note:
See TracChangeset
for help on using the changeset viewer.