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