Changeset a35b458 in mainline for kernel/generic/src/interrupt/interrupt.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/interrupt/interrupt.c
r3061bc1 ra35b458 78 78 assert(n < IVT_ITEMS); 79 79 #endif 80 80 81 81 irq_spinlock_lock(&exctbl_lock, true); 82 82 83 83 iroutine_t old = exc_table[n].handler; 84 84 exc_table[n].handler = handler; … … 87 87 exc_table[n].cycles = 0; 88 88 exc_table[n].count = 0; 89 89 90 90 irq_spinlock_unlock(&exctbl_lock, true); 91 91 92 92 return old; 93 93 } … … 104 104 assert(n < IVT_ITEMS); 105 105 #endif 106 106 107 107 /* Account user cycles */ 108 108 if (THREAD) { … … 111 111 irq_spinlock_unlock(&THREAD->lock, false); 112 112 } 113 113 114 114 /* Account CPU usage if it woke up from sleep */ 115 115 if (CPU && CPU->idle) { … … 121 121 irq_spinlock_unlock(&CPU->lock, false); 122 122 } 123 123 124 124 uint64_t begin_cycle = get_cycle(); 125 125 126 126 #ifdef CONFIG_UDEBUG 127 127 if (THREAD) 128 128 THREAD->udebug.uspace_state = istate; 129 129 #endif 130 130 131 131 exc_table[n].handler(n + IVT_FIRST, istate); 132 132 133 133 #ifdef CONFIG_UDEBUG 134 134 if (THREAD) 135 135 THREAD->udebug.uspace_state = NULL; 136 136 #endif 137 137 138 138 /* This is a safe place to exit exiting thread */ 139 139 if ((THREAD) && (THREAD->interrupted) && (istate_from_uspace(istate))) 140 140 thread_exit(); 141 141 142 142 /* Account exception handling */ 143 143 uint64_t end_cycle = get_cycle(); 144 144 145 145 irq_spinlock_lock(&exctbl_lock, false); 146 146 exc_table[n].cycles += end_cycle - begin_cycle; 147 147 exc_table[n].count++; 148 148 irq_spinlock_unlock(&exctbl_lock, false); 149 149 150 150 /* Do not charge THREAD for exception cycles */ 151 151 if (THREAD) { … … 171 171 "program counter %p.\n", TASK->name, TASK->taskid, 172 172 (void *) istate_get_pc(istate)); 173 173 174 174 istate_decode(istate); 175 175 stack_trace_istate(istate); 176 176 177 177 printf("Kill message: "); 178 178 vprintf(fmt, args); 179 179 printf("\n"); 180 180 181 181 task_kill_self(true); 182 182 } … … 201 201 if (!istate_from_uspace(istate)) 202 202 return; 203 203 204 204 va_list args; 205 205 va_start(args, fmt); … … 236 236 { 237 237 bool excs_all; 238 238 239 239 if (str_cmp(flag_buf, "-a") == 0) 240 240 excs_all = true; … … 245 245 return 1; 246 246 } 247 247 248 248 #if (IVT_ITEMS > 0) 249 249 unsigned int i; 250 250 unsigned int rows; 251 251 252 252 irq_spinlock_lock(&exctbl_lock, true); 253 253 254 254 #ifdef __32_BITS__ 255 255 printf("[exc ] [description ] [count ] [cycles ]" … … 257 257 rows = 1; 258 258 #endif 259 259 260 260 #ifdef __64_BITS__ 261 261 printf("[exc ] [description ] [count ] [cycles ]" … … 264 264 rows = 2; 265 265 #endif 266 266 267 267 for (i = 0; i < IVT_ITEMS; i++) { 268 268 if ((!excs_all) && (!exc_table[i].hot)) 269 269 continue; 270 270 271 271 uint64_t count; 272 272 char count_suffix; 273 273 274 274 order_suffix(exc_table[i].count, &count, &count_suffix); 275 275 276 276 uint64_t cycles; 277 277 char cycles_suffix; 278 278 279 279 order_suffix(exc_table[i].cycles, &cycles, &cycles_suffix); 280 280 281 281 const char *symbol = 282 282 symtab_fmt_name_lookup((sysarg_t) exc_table[i].handler); 283 283 284 284 #ifdef __32_BITS__ 285 285 printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %10p %s\n", 286 286 i + IVT_FIRST, exc_table[i].name, count, count_suffix, 287 287 cycles, cycles_suffix, exc_table[i].handler, symbol); 288 288 289 289 PAGING(rows, 1, irq_spinlock_unlock(&exctbl_lock, true), 290 290 irq_spinlock_lock(&exctbl_lock, true)); 291 291 #endif 292 292 293 293 #ifdef __64_BITS__ 294 294 printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %18p\n", … … 296 296 cycles, cycles_suffix, exc_table[i].handler); 297 297 printf(" %s\n", symbol); 298 298 299 299 PAGING(rows, 2, irq_spinlock_unlock(&exctbl_lock, true), 300 300 irq_spinlock_lock(&exctbl_lock, true)); 301 301 #endif 302 302 } 303 303 304 304 irq_spinlock_unlock(&exctbl_lock, true); 305 305 #else /* (IVT_ITEMS > 0) */ 306 306 307 307 printf("No exception table%s.\n", excs_all ? " (showing all exceptions)" : ""); 308 308 309 309 #endif /* (IVT_ITEMS > 0) */ 310 310 311 311 return 1; 312 312 } … … 335 335 { 336 336 (void) exc_undef; 337 337 338 338 #if (IVT_ITEMS > 0) 339 339 unsigned int i; 340 340 341 341 for (i = 0; i < IVT_ITEMS; i++) 342 342 exc_register(i, "undef", false, (iroutine_t) exc_undef); 343 343 #endif 344 344 345 345 #ifdef CONFIG_KCONSOLE 346 346 cmd_initialize(&exc_info);
Note:
See TracChangeset
for help on using the changeset viewer.