Changes in kernel/generic/src/interrupt/interrupt.c [07640dfd:da1bafb] in mainline
- File:
-
- 1 edited
-
kernel/generic/src/interrupt/interrupt.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/interrupt/interrupt.c
r07640dfd rda1bafb 32 32 /** 33 33 * @file 34 * @brief Interrupt redirector.34 * @brief Interrupt redirector. 35 35 * 36 36 * This file provides means of registering interrupt handlers 37 37 * by kernel functions and calling the handlers when interrupts 38 38 * occur. 39 * 39 40 */ 40 41 … … 61 62 62 63 /** Register exception handler 63 * 64 * @param n Exception number 65 * @param name Description 66 * @param f Exception handler 67 */ 68 iroutine exc_register(int n, const char *name, iroutine f) 64 * 65 * @param n Exception number 66 * @param name Description 67 * @param handler Exception handler 68 * 69 */ 70 iroutine exc_register(int n, const char *name, iroutine handler) 69 71 { 70 72 ASSERT(n < IVT_ITEMS); 71 73 72 iroutine old;73 74 74 spinlock_lock(&exctbl_lock); 75 75 76 old = exc_table[n].f;77 exc_table[n].f = f;76 iroutine old = exc_table[n].f; 77 exc_table[n].f = handler; 78 78 exc_table[n].name = name; 79 79 … … 87 87 * Called directly from the assembler code. 88 88 * CPU is interrupts_disable()'d. 89 * 89 90 */ 90 91 void exc_dispatch(int n, istate_t *istate) 91 92 { 92 93 ASSERT(n < IVT_ITEMS); 93 94 94 95 /* Account user cycles */ 96 if (THREAD) { 97 irq_spinlock_lock(&THREAD->lock, false); 98 thread_update_accounting(true); 99 irq_spinlock_unlock(&THREAD->lock, false); 100 } 101 102 #ifdef CONFIG_UDEBUG 95 103 if (THREAD) 96 thread_update_accounting(true); 97 104 THREAD->udebug.uspace_state = istate; 105 #endif 106 107 exc_table[n].f(n + IVT_FIRST, istate); 108 98 109 #ifdef CONFIG_UDEBUG 99 if (THREAD) THREAD->udebug.uspace_state = istate; 100 #endif 101 102 exc_table[n].f(n + IVT_FIRST, istate); 103 104 #ifdef CONFIG_UDEBUG 105 if (THREAD) THREAD->udebug.uspace_state = NULL; 106 #endif 107 110 if (THREAD) 111 THREAD->udebug.uspace_state = NULL; 112 #endif 113 108 114 /* This is a safe place to exit exiting thread */ 109 if ( THREAD && THREAD->interrupted && istate_from_uspace(istate))115 if ((THREAD) && (THREAD->interrupted) && (istate_from_uspace(istate))) 110 116 thread_exit(); 111 112 if (THREAD) 117 118 if (THREAD) { 119 irq_spinlock_lock(&THREAD->lock, false); 113 120 thread_update_accounting(false); 114 } 115 116 /** Default 'null' exception handler */ 121 irq_spinlock_unlock(&THREAD->lock, false); 122 } 123 } 124 125 /** Default 'null' exception handler 126 * 127 */ 117 128 static void exc_undef(int n, istate_t *istate) 118 129 { … … 121 132 } 122 133 123 /** Terminate thread and task if exception came from userspace. */ 134 /** Terminate thread and task if exception came from userspace. 135 * 136 */ 124 137 void fault_if_from_uspace(istate_t *istate, const char *fmt, ...) 125 138 { 126 task_t *task = TASK;127 va_list args;128 129 139 if (!istate_from_uspace(istate)) 130 140 return; 131 141 132 142 printf("Task %s (%" PRIu64 ") killed due to an exception at " 133 "program counter %p.\n", task->name, task->taskid,143 "program counter %p.\n", TASK->name, TASK->taskid, 134 144 istate_get_pc(istate)); 135 145 136 146 stack_trace_istate(istate); 137 147 138 148 printf("Kill message: "); 149 150 va_list args; 139 151 va_start(args, fmt); 140 152 vprintf(fmt, args); 141 153 va_end(args); 142 154 printf("\n"); 143 155 144 156 /* 145 157 * Userspace can subscribe for FAULT events to take action … … 152 164 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid), 153 165 UPPER32(TASK->taskid), (unative_t) THREAD); 154 166 155 167 #ifdef CONFIG_UDEBUG 156 168 /* Wait for a debugging session. */ … … 158 170 #endif 159 171 } 160 161 task_kill( task->taskid);172 173 task_kill(TASK->taskid); 162 174 thread_exit(); 163 175 } … … 165 177 #ifdef CONFIG_KCONSOLE 166 178 167 /** kconsole cmd - print all exceptions */ 179 /** Print all exceptions 180 * 181 */ 168 182 static int cmd_exc_print(cmd_arg_t *argv) 169 183 { 170 184 #if (IVT_ITEMS > 0) 171 185 unsigned int i; 172 186 173 187 spinlock_lock(&exctbl_lock); 174 188 175 189 #ifdef __32_BITS__ 176 190 printf("Exc Description Handler Symbol\n"); 177 191 printf("--- -------------------- ---------- --------\n"); 178 192 #endif 179 193 180 194 #ifdef __64_BITS__ 181 195 printf("Exc Description Handler Symbol\n"); … … 185 199 for (i = 0; i < IVT_ITEMS; i++) { 186 200 const char *symbol = symtab_fmt_name_lookup((unative_t) exc_table[i].f); 187 201 188 202 #ifdef __32_BITS__ 189 203 printf("%-3u %-20s %10p %s\n", i + IVT_FIRST, exc_table[i].name, 190 204 exc_table[i].f, symbol); 191 205 #endif 192 206 193 207 #ifdef __64_BITS__ 194 208 printf("%-3u %-20s %18p %s\n", i + IVT_FIRST, exc_table[i].name, … … 210 224 return 1; 211 225 } 212 213 226 214 227 static cmd_info_t exc_info = { … … 221 234 }; 222 235 223 #endif 224 225 /** Initialize generic exception handling support */ 236 #endif /* CONFIG_KCONSOLE */ 237 238 /** Initialize generic exception handling support 239 * 240 */ 226 241 void exc_init(void) 227 242 { 228 int i; 229 243 (void) exc_undef; 244 245 #if (IVT_ITEMS > 0) 246 unsigned int i; 247 230 248 for (i = 0; i < IVT_ITEMS; i++) 231 249 exc_register(i, "undef", (iroutine) exc_undef); 232 250 #endif 251 233 252 #ifdef CONFIG_KCONSOLE 234 253 cmd_initialize(&exc_info);
Note:
See TracChangeset
for help on using the changeset viewer.
