Changes in kernel/arch/amd64/src/interrupt.c [acc7ce4:98000fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/interrupt.c
racc7ce4 r98000fb 53 53 #include <ddi/irq.h> 54 54 #include <symtab.h> 55 #include <stacktrace.h>56 55 57 56 /* … … 62 61 void (* enable_irqs_function)(uint16_t irqmask) = NULL; 63 62 void (* eoi_function)(void) = NULL; 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); 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]); 93 82 } 94 83 … … 102 91 } 103 92 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) 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) 120 102 { 121 103 if (TASK) { 122 irq_spinlock_lock(&TASK->lock, false); 123 size_t ver = TASK->arch.iomapver; 124 irq_spinlock_unlock(&TASK->lock, false); 125 104 size_t ver; 105 106 spinlock_lock(&TASK->lock); 107 ver = TASK->arch.iomapver; 108 spinlock_unlock(&TASK->lock); 109 126 110 if (CPU->arch.iomapver_copy != ver) { 127 111 /* … … 137 121 fault_if_from_uspace(istate, "General protection fault."); 138 122 } 139 panic_badtrap(istate, n, "General protection fault."); 140 } 141 142 static void ss_fault(unsigned int n, istate_t *istate) 123 124 decode_istate(n, istate); 125 panic("General protection fault."); 126 } 127 128 static void ss_fault(int n, istate_t *istate) 143 129 { 144 130 fault_if_from_uspace(istate, "Stack fault."); 145 panic_badtrap(istate, n, "Stack fault."); 146 } 147 148 static void nm_fault(unsigned int n, istate_t *istate) 131 decode_istate(n, istate); 132 panic("Stack fault."); 133 } 134 135 static void nm_fault(int n, istate_t *istate) 149 136 { 150 137 #ifdef CONFIG_FPU_LAZY … … 157 144 158 145 #ifdef CONFIG_SMP 159 static void tlb_shootdown_ipi( unsignedint n, istate_t *istate)146 static void tlb_shootdown_ipi(int n, istate_t *istate) 160 147 { 161 148 trap_virtual_eoi(); … … 164 151 #endif 165 152 166 /** Handler of IRQ exceptions. 167 * 168 */ 169 static void irq_interrupt(unsigned int n, istate_t *istate) 153 /** Handler of IRQ exceptions */ 154 static void irq_interrupt(int n, istate_t *istate) 170 155 { 171 156 ASSERT(n >= IVT_IRQBASE); 172 157 173 unsignedint inum = n - IVT_IRQBASE;158 int inum = n - IVT_IRQBASE; 174 159 bool ack = false; 175 160 ASSERT(inum < IRQ_COUNT); … … 181 166 * The IRQ handler was found. 182 167 */ 183 168 184 169 if (irq->preack) { 185 170 /* Send EOI before processing the interrupt */ … … 188 173 } 189 174 irq->handler(irq); 190 irq_spinlock_unlock(&irq->lock, false);175 spinlock_unlock(&irq->lock); 191 176 } else { 192 177 /* … … 194 179 */ 195 180 #ifdef CONFIG_DEBUG 196 printf("cpu% u: spurious interrupt (inum=%u)\n", CPU->id, inum);181 printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum); 197 182 #endif 198 183 } … … 204 189 void interrupt_init(void) 205 190 { 206 unsignedint i;191 int i; 207 192 208 193 for (i = 0; i < IVT_ITEMS; i++) 209 exc_register(i, "null", false, (iroutine_t) null_interrupt);194 exc_register(i, "null", (iroutine) null_interrupt); 210 195 211 196 for (i = 0; i < IRQ_COUNT; i++) { 212 197 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1)) 213 exc_register(IVT_IRQBASE + i, "irq", true,214 (iroutine _t) irq_interrupt);198 exc_register(IVT_IRQBASE + i, "irq", 199 (iroutine) irq_interrupt); 215 200 } 216 201 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(1 2, "ss_fault", true, (iroutine_t) ss_fault);220 exc_register(1 3, "gp_fault", true, (iroutine_t) gp_fault);202 exc_register(7, "nm_fault", (iroutine) nm_fault); 203 exc_register(12, "ss_fault", (iroutine) ss_fault); 204 exc_register(13, "gp_fault", (iroutine) gp_fault); 205 exc_register(14, "ident_mapper", (iroutine) ident_page_fault); 221 206 222 207 #ifdef CONFIG_SMP 223 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,224 (iroutine _t) tlb_shootdown_ipi);208 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", 209 (iroutine) tlb_shootdown_ipi); 225 210 #endif 226 211 }
Note:
See TracChangeset
for help on using the changeset viewer.