Changeset 89c57b6 in mainline for kernel/generic/src/interrupt/interrupt.c
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/interrupt/interrupt.c
rcefb126 r89c57b6 45 45 #include <console/console.h> 46 46 #include <console/cmd.h> 47 #include <ipc/event.h>48 47 #include <synch/mutex.h> 49 48 #include <time/delay.h> … … 55 54 #include <arch/cycle.h> 56 55 #include <str.h> 56 #include <trace.h> 57 57 58 58 exc_table_t exc_table[IVT_ITEMS]; … … 97 97 * 98 98 */ 99 void exc_dispatch(unsigned int n, istate_t *istate) 100 { 101 ASSERT(CPU); 102 99 NO_TRACE void exc_dispatch(unsigned int n, istate_t *istate) 100 { 103 101 #if (IVT_ITEMS > 0) 104 102 ASSERT(n < IVT_ITEMS); … … 113 111 114 112 /* Account CPU usage if it has waked up from sleep */ 115 irq_spinlock_lock(&CPU->lock, false); 116 if (CPU->idle) { 117 uint64_t now = get_cycle(); 118 CPU->idle_cycles += now - CPU->last_cycle; 119 CPU->last_cycle = now; 120 CPU->idle = false; 121 } 122 irq_spinlock_unlock(&CPU->lock, false); 113 if (CPU) { 114 irq_spinlock_lock(&CPU->lock, false); 115 if (CPU->idle) { 116 uint64_t now = get_cycle(); 117 CPU->idle_cycles += now - CPU->last_cycle; 118 CPU->last_cycle = now; 119 CPU->idle = false; 120 } 121 irq_spinlock_unlock(&CPU->lock, false); 122 } 123 123 124 124 uint64_t begin_cycle = get_cycle(); … … 159 159 * 160 160 */ 161 static void exc_undef(unsigned int n, istate_t *istate)161 NO_TRACE static void exc_undef(unsigned int n, istate_t *istate) 162 162 { 163 163 fault_if_from_uspace(istate, "Unhandled exception %u.", n); 164 panic ("Unhandled exception %u.", n);164 panic_badtrap(istate, n, "Unhandled exception %u.", n); 165 165 } 166 166 … … 168 168 * 169 169 */ 170 void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)170 NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...) 171 171 { 172 172 if (!istate_from_uspace(istate)) … … 175 175 printf("Task %s (%" PRIu64 ") killed due to an exception at " 176 176 "program counter %p.\n", TASK->name, TASK->taskid, 177 istate_get_pc(istate));177 (void *) istate_get_pc(istate)); 178 178 179 179 stack_trace_istate(istate); … … 187 187 printf("\n"); 188 188 189 task_kill_self(true); 190 } 191 192 /** Get istate structure of a thread. 193 * 194 * Get pointer to the istate structure at the bottom of the kernel stack. 195 * 196 * This function can be called in interrupt or user context. In interrupt 197 * context the istate structure is created by the low-level exception 198 * handler. In user context the istate structure is created by the 199 * low-level syscall handler. 200 */ 201 istate_t *istate_get(thread_t *thread) 202 { 189 203 /* 190 * Userspace can subscribe for FAULT events to take action 191 * whenever a thread faults. (E.g. take a dump, run a debugger). 192 * The notification is always available, but unless Udebug is enabled, 193 * that's all you get. 204 * The istate structure should be right at the bottom of the kernel 205 * stack. 194 206 */ 195 if (event_is_subscribed(EVENT_FAULT)) { 196 /* Notify the subscriber that a fault occurred. */ 197 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid), 198 UPPER32(TASK->taskid), (unative_t) THREAD); 199 200 #ifdef CONFIG_UDEBUG 201 /* Wait for a debugging session. */ 202 udebug_thread_fault(); 203 #endif 204 } 205 206 task_kill(TASK->taskid); 207 thread_exit(); 207 return (istate_t *) ((uint8_t *) thread->kstack + THREAD_STACK_SIZE - 208 sizeof(istate_t)); 208 209 } 209 210 … … 215 216 * 216 217 */ 217 static int cmd_exc_print(cmd_arg_t *argv)218 NO_TRACE static int cmd_exc_print(cmd_arg_t *argv) 218 219 { 219 220 bool excs_all; … … 262 263 263 264 const char *symbol = 264 symtab_fmt_name_lookup(( unative_t) exc_table[i].handler);265 symtab_fmt_name_lookup((sysarg_t) exc_table[i].handler); 265 266 266 267 #ifdef __32_BITS__
Note:
See TracChangeset
for help on using the changeset viewer.