Changes in kernel/arch/amd64/src/interrupt.c [98000fb:acc7ce4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/interrupt.c
r98000fb racc7ce4 53 53 #include <ddi/irq.h> 54 54 #include <symtab.h> 55 #include <stacktrace.h> 55 56 56 57 /* … … 61 62 void (* enable_irqs_function)(uint16_t irqmask) = NULL; 62 63 void (* eoi_function)(void) = NULL; 63 64 void decode_istate(int n, istate_t *istate) 65 { 66 char *symbol; 67 68 symbol = symtab_fmt_name_lookup(istate->rip); 69 70 printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n", n, __func__); 71 printf("%%rip: %#llx (%s)\n", istate->rip, symbol); 72 printf("ERROR_WORD=%#llx\n", istate->error_word); 73 printf("%%cs=%#llx, rflags=%#llx, %%cr0=%#llx\n", istate->cs, 74 istate->rflags, read_cr0()); 75 printf("%%rax=%#llx, %%rcx=%#llx, %%rdx=%#llx\n", istate->rax, 76 istate->rcx, istate->rdx); 77 printf("%%rsi=%#llx, %%rdi=%#llx, %%r8=%#llx\n", istate->rsi, 78 istate->rdi, istate->r8); 79 printf("%%r9=%#llx, %%r10=%#llx, %%r11=%#llx\n", istate->r9, 80 istate->r10, istate->r11); 81 printf("%%rsp=%#llx\n", &istate->stack[0]); 64 const char *irqs_info = NULL; 65 66 void istate_decode(istate_t *istate) 67 { 68 printf("cs =%#0" PRIx64 "\trip=%p\t" 69 "rfl=%#0" PRIx64 "\terr=%#0" PRIx64 "\n", 70 istate->cs, (void *) istate->rip, 71 istate->rflags, istate->error_word); 72 73 if (istate_from_uspace(istate)) 74 printf("ss =%#0" PRIx64 "\n", istate->ss); 75 76 printf("rax=%#0" PRIx64 "\trbx=%#0" PRIx64 "\t" 77 "rcx=%#0" PRIx64 "\trdx=%#0" PRIx64 "\n", 78 istate->rax, istate->rbx, istate->rcx, istate->rdx); 79 80 printf("rsi=%p\trdi=%p\trbp=%p\trsp=%p\n", 81 (void *) istate->rsi, (void *) istate->rdi, 82 (void *) istate->rbp, 83 istate_from_uspace(istate) ? ((void *) istate->rsp) : 84 &istate->rsp); 85 86 printf("r8 =%#0" PRIx64 "\tr9 =%#0" PRIx64 "\t" 87 "r10=%#0" PRIx64 "\tr11=%#0" PRIx64 "\n", 88 istate->r8, istate->r9, istate->r10, istate->r11); 89 90 printf("r12=%#0" PRIx64 "\tr13=%#0" PRIx64 "\t" 91 "r14=%#0" PRIx64 "\tr15=%#0" PRIx64 "\n", 92 istate->r12, istate->r13, istate->r14, istate->r15); 82 93 } 83 94 … … 91 102 } 92 103 93 static void null_interrupt(int n, istate_t *istate) 94 { 95 fault_if_from_uspace(istate, "Unserviced interrupt: %d.", n); 96 decode_istate(n, istate); 97 panic("Unserviced interrupt."); 98 } 99 100 /** General Protection Fault. */ 101 static void gp_fault(int n, istate_t *istate) 104 static void null_interrupt(unsigned int n, istate_t *istate) 105 { 106 fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n); 107 panic_badtrap(istate, n, "Unserviced interrupt."); 108 } 109 110 static void de_fault(unsigned int n, istate_t *istate) 111 { 112 fault_if_from_uspace(istate, "Divide error."); 113 panic_badtrap(istate, n, "Divide error."); 114 } 115 116 /** General Protection Fault. 117 * 118 */ 119 static void gp_fault(unsigned int n, istate_t *istate) 102 120 { 103 121 if (TASK) { 104 size_t ver; 105 106 spinlock_lock(&TASK->lock); 107 ver = TASK->arch.iomapver; 108 spinlock_unlock(&TASK->lock); 109 122 irq_spinlock_lock(&TASK->lock, false); 123 size_t ver = TASK->arch.iomapver; 124 irq_spinlock_unlock(&TASK->lock, false); 125 110 126 if (CPU->arch.iomapver_copy != ver) { 111 127 /* … … 121 137 fault_if_from_uspace(istate, "General protection fault."); 122 138 } 123 124 decode_istate(n, istate); 125 panic("General protection fault."); 126 } 127 128 static void ss_fault(int n, istate_t *istate) 139 panic_badtrap(istate, n, "General protection fault."); 140 } 141 142 static void ss_fault(unsigned int n, istate_t *istate) 129 143 { 130 144 fault_if_from_uspace(istate, "Stack fault."); 131 decode_istate(n, istate); 132 panic("Stack fault."); 133 } 134 135 static void nm_fault(int n, istate_t *istate) 145 panic_badtrap(istate, n, "Stack fault."); 146 } 147 148 static void nm_fault(unsigned int n, istate_t *istate) 136 149 { 137 150 #ifdef CONFIG_FPU_LAZY … … 144 157 145 158 #ifdef CONFIG_SMP 146 static void tlb_shootdown_ipi( int n, istate_t *istate)159 static void tlb_shootdown_ipi(unsigned int n, istate_t *istate) 147 160 { 148 161 trap_virtual_eoi(); … … 151 164 #endif 152 165 153 /** Handler of IRQ exceptions */ 154 static void irq_interrupt(int n, istate_t *istate) 166 /** Handler of IRQ exceptions. 167 * 168 */ 169 static void irq_interrupt(unsigned int n, istate_t *istate) 155 170 { 156 171 ASSERT(n >= IVT_IRQBASE); 157 172 158 int inum = n - IVT_IRQBASE;173 unsigned int inum = n - IVT_IRQBASE; 159 174 bool ack = false; 160 175 ASSERT(inum < IRQ_COUNT); … … 166 181 * The IRQ handler was found. 167 182 */ 168 183 169 184 if (irq->preack) { 170 185 /* Send EOI before processing the interrupt */ … … 173 188 } 174 189 irq->handler(irq); 175 spinlock_unlock(&irq->lock);190 irq_spinlock_unlock(&irq->lock, false); 176 191 } else { 177 192 /* … … 179 194 */ 180 195 #ifdef CONFIG_DEBUG 181 printf("cpu% d: spurious interrupt (inum=%d)\n", CPU->id, inum);196 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum); 182 197 #endif 183 198 } … … 189 204 void interrupt_init(void) 190 205 { 191 int i;206 unsigned int i; 192 207 193 208 for (i = 0; i < IVT_ITEMS; i++) 194 exc_register(i, "null", (iroutine) null_interrupt);209 exc_register(i, "null", false, (iroutine_t) null_interrupt); 195 210 196 211 for (i = 0; i < IRQ_COUNT; i++) { 197 212 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1)) 198 exc_register(IVT_IRQBASE + i, "irq", 199 (iroutine ) irq_interrupt);213 exc_register(IVT_IRQBASE + i, "irq", true, 214 (iroutine_t) irq_interrupt); 200 215 } 201 216 202 exc_register( 7, "nm_fault", (iroutine) nm_fault);203 exc_register( 12, "ss_fault", (iroutine) ss_fault);204 exc_register(1 3, "gp_fault", (iroutine) gp_fault);205 exc_register(1 4, "ident_mapper", (iroutine) ident_page_fault);217 exc_register(0, "de_fault", true, (iroutine_t) de_fault); 218 exc_register(7, "nm_fault", true, (iroutine_t) nm_fault); 219 exc_register(12, "ss_fault", true, (iroutine_t) ss_fault); 220 exc_register(13, "gp_fault", true, (iroutine_t) gp_fault); 206 221 207 222 #ifdef CONFIG_SMP 208 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", 209 (iroutine ) tlb_shootdown_ipi);223 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true, 224 (iroutine_t) tlb_shootdown_ipi); 210 225 #endif 211 226 }
Note:
See TracChangeset
for help on using the changeset viewer.