Changeset 8607db8 in mainline
- Timestamp:
- 2006-10-27T13:34:20Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ec04b20
- Parents:
- 16d71f41
- Location:
- kernel/arch/amd64
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/interrupt.h
r16d71f41 r8607db8 46 46 47 47 #define IVT_EXCBASE 0 48 #define IVT_IRQBASE (IVT_EXCBASE +EXC_COUNT)49 #define IVT_FREEBASE (IVT_IRQBASE+IRQ_COUNT)48 #define IVT_IRQBASE (IVT_EXCBASE + EXC_COUNT) 49 #define IVT_FREEBASE (IVT_IRQBASE + IRQ_COUNT) 50 50 51 #define IRQ_CLK 052 #define IRQ_KBD 153 #define IRQ_PIC1 251 #define IRQ_CLK 0 52 #define IRQ_KBD 1 53 #define IRQ_PIC1 2 54 54 #define IRQ_PIC_SPUR 7 55 #define IRQ_MOUSE 12 55 56 56 57 /* this one must have four least significant bits set to ones */ 57 #define VECTOR_APIC_SPUR (IVT_ITEMS -1)58 #define VECTOR_APIC_SPUR (IVT_ITEMS - 1) 58 59 59 #if (((VECTOR_APIC_SPUR + 1) %16) || VECTOR_APIC_SPUR >= IVT_ITEMS)60 #if (((VECTOR_APIC_SPUR + 1) % 16) || VECTOR_APIC_SPUR >= IVT_ITEMS) 60 61 #error Wrong definition of VECTOR_APIC_SPUR 61 62 #endif 62 63 63 #define VECTOR_DEBUG 1 64 #define VECTOR_PIC_SPUR (IVT_IRQBASE+IRQ_PIC_SPUR) 65 #define VECTOR_CLK (IVT_IRQBASE+IRQ_CLK) 66 #define VECTOR_KBD (IVT_IRQBASE+IRQ_KBD) 67 68 #define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE+0) 69 #define VECTOR_WAKEUP_IPI (IVT_FREEBASE+1) 70 #define VECTOR_DEBUG_IPI (IVT_FREEBASE+2) 64 #define VECTOR_DEBUG 1 65 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 66 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) 67 #define VECTOR_SYSCALL IVT_FREEBASE 68 #define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE + 1) 69 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 71 70 72 71 /** This is passed to interrupt handlers */ … … 113 112 extern void (* eoi_function)(void); 114 113 115 extern void print_info_errcode(int n, istate_t *istate); 116 extern void null_interrupt(int n, istate_t *istate); 117 extern void gp_fault(int n, istate_t *istate); 118 extern void nm_fault(int n, istate_t *istate); 119 extern void ss_fault(int n, istate_t *istate); 120 extern void page_fault(int n, istate_t *istate); 121 extern void syscall(int n, istate_t *istate); 122 extern void tlb_shootdown_ipi(int n, istate_t *istate); 123 114 extern void decode_istate(int n, istate_t *istate); 115 extern void interrupt_init(void); 124 116 extern void trap_virtual_enable_irqs(uint16_t irqmask); 125 117 extern void trap_virtual_disable_irqs(uint16_t irqmask); 126 extern void trap_virtual_eoi(void);127 118 /* AMD64 - specific page handler */ 128 119 extern void ident_page_fault(int n, istate_t *istate); -
kernel/arch/amd64/include/mm/page.h
r16d71f41 r8607db8 191 191 192 192 extern void page_arch_init(void); 193 extern void page_fault(int n, istate_t *istate); 193 194 194 195 #endif /* __ASM__ */ -
kernel/arch/amd64/src/amd64.c
r16d71f41 r8607db8 62 62 #include <syscall/syscall.h> 63 63 #include <console/console.h> 64 #include <ddi/irq.h> 65 #include <ddi/device.h> 64 66 65 67 … … 131 133 132 134 if (config.cpu_active == 1) { 135 interrupt_init(); 133 136 bios_init(); 134 i8259_init(); /* PIC */ 135 i8254_init(); /* hard clock */ 136 137 #ifdef CONFIG_SMP 138 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", 139 tlb_shootdown_ipi); 140 #endif /* CONFIG_SMP */ 137 138 /* PIC */ 139 i8259_init(); 141 140 } 142 141 } … … 145 144 { 146 145 if (config.cpu_active == 1) { 146 /* Initialize IRQ routing */ 147 irq_init(IRQ_COUNT, IRQ_COUNT); 148 149 /* hard clock */ 150 i8254_init(); 151 147 152 #ifdef CONFIG_FB 148 153 if (vesa_present()) … … 151 156 #endif 152 157 ega_init(); /* video */ 158 153 159 /* Enable debugger */ 154 160 debugger_init(); … … 184 190 void arch_post_smp_init(void) 185 191 { 186 i8042_init(); /* keyboard controller */ 192 /* keyboard controller */ 193 i8042_init(device_assign_devno(), IRQ_KBD, device_assign_devno(), IRQ_MOUSE); 187 194 } 188 195 … … 190 197 { 191 198 i8254_calibrate_delay_loop(); 192 i8254_normal_operation(); 199 if (config.cpu_active == 1) { 200 /* 201 * This has to be done only on UP. 202 * On SMP, i8254 is not used for time keeping and its interrupt pin remains masked. 203 */ 204 i8254_normal_operation(); 205 } 193 206 } 194 207 -
kernel/arch/amd64/src/interrupt.c
r16d71f41 r8607db8 52 52 #include <arch/ddi/ddi.h> 53 53 #include <interrupt.h> 54 #include <ipc/irq.h> 55 56 void print_info_errcode(int n, istate_t *istate) 54 #include <ddi/irq.h> 55 56 /* 57 * Interrupt and exception dispatching. 58 */ 59 60 void (* disable_irqs_function)(uint16_t irqmask) = NULL; 61 void (* enable_irqs_function)(uint16_t irqmask) = NULL; 62 void (* eoi_function)(void) = NULL; 63 64 void decode_istate(int n, istate_t *istate) 57 65 { 58 66 char *symbol; … … 76 84 } 77 85 78 /* 79 * Interrupt and exception dispatching. 80 */ 81 82 void (* disable_irqs_function)(uint16_t irqmask) = NULL; 83 void (* enable_irqs_function)(uint16_t irqmask) = NULL; 84 void (* eoi_function)(void) = NULL; 85 86 void null_interrupt(int n, istate_t *istate) 86 static void trap_virtual_eoi(void) 87 { 88 if (eoi_function) 89 eoi_function(); 90 else 91 panic("no eoi_function\n"); 92 93 } 94 95 static void null_interrupt(int n, istate_t *istate) 87 96 { 88 97 fault_if_from_uspace(istate, "unserviced interrupt: %d", n); 89 print_info_errcode(n, istate);98 decode_istate(n, istate); 90 99 panic("unserviced interrupt\n"); 91 100 } 92 101 93 102 /** General Protection Fault. */ 94 void gp_fault(int n, istate_t *istate)103 static void gp_fault(int n, istate_t *istate) 95 104 { 96 105 if (TASK) { … … 115 124 } 116 125 117 print_info_errcode(n, istate);126 decode_istate(n, istate); 118 127 panic("general protection fault\n"); 119 128 } 120 129 121 void ss_fault(int n, istate_t *istate)130 static void ss_fault(int n, istate_t *istate) 122 131 { 123 132 fault_if_from_uspace(istate, "stack fault"); 124 print_info_errcode(n, istate);133 decode_istate(n, istate); 125 134 panic("stack fault\n"); 126 135 } 127 136 128 void nm_fault(int n, istate_t *istate)137 static void nm_fault(int n, istate_t *istate) 129 138 { 130 139 #ifdef CONFIG_FPU_LAZY … … 136 145 } 137 146 138 void tlb_shootdown_ipi(int n, istate_t *istate)147 static void tlb_shootdown_ipi(int n, istate_t *istate) 139 148 { 140 149 trap_virtual_eoi(); 141 150 tlb_shootdown_ipi_recv(); 151 } 152 153 /** Handler of IRQ exceptions */ 154 static void irq_interrupt(int n, istate_t *istate) 155 { 156 ASSERT(n >= IVT_IRQBASE); 157 158 int inum = n - IVT_IRQBASE; 159 ASSERT(inum < IRQ_COUNT); 160 ASSERT((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1)); 161 162 irq_t *irq = irq_dispatch_and_lock(inum); 163 if (irq) { 164 /* 165 * The IRQ handler was found. 166 */ 167 irq->handler(irq, irq->arg); 168 spinlock_unlock(&irq->lock); 169 } else { 170 /* 171 * Spurious interrupt. 172 */ 173 #ifdef CONFIG_DEBUG 174 printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum); 175 #endif 176 } 177 trap_virtual_eoi(); 178 } 179 180 void interrupt_init(void) 181 { 182 int i; 183 184 for (i = 0; i < IVT_ITEMS; i++) 185 exc_register(i, "null", (iroutine) null_interrupt); 186 187 for (i = 0; i < IRQ_COUNT; i++) { 188 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1)) 189 exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt); 190 } 191 192 exc_register(7, "nm_fault", (iroutine) nm_fault); 193 exc_register(12, "ss_fault", (iroutine) ss_fault); 194 exc_register(13, "gp_fault", (iroutine) gp_fault); 195 exc_register(14, "ident_mapper", (iroutine) ident_page_fault); 196 197 #ifdef CONFIG_SMP 198 exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi); 199 #endif 142 200 } 143 201 … … 158 216 } 159 217 160 void trap_virtual_eoi(void)161 {162 if (eoi_function)163 eoi_function();164 else165 panic("no eoi_function\n");166 167 }168 169 218 /** @} 170 219 */ -
kernel/arch/amd64/src/mm/page.c
r16d71f41 r8607db8 111 111 } 112 112 113 exc_register(14, "page_fault", (iroutine) page_fault);113 exc_register(14, "page_fault", (iroutine) page_fault); 114 114 write_cr3((uintptr_t) AS_KERNEL->page_table); 115 115 } … … 194 194 fault_if_from_uspace(istate, "Page fault: %#x", page); 195 195 196 print_info_errcode(n, istate);196 decode_istate(n, istate); 197 197 printf("Page fault address: %llx\n", page); 198 198 panic("page fault\n"); -
kernel/arch/amd64/src/pm.c
r16d71f41 r8607db8 181 181 182 182 idt_setoffset(d, ((uintptr_t) interrupt_handlers) + i*interrupt_handler_size); 183 exc_register(i, "undef", (iroutine)null_interrupt);184 183 } 185 186 exc_register( 7, "nm_fault", nm_fault);187 exc_register(12, "ss_fault", ss_fault);188 exc_register(13, "gp_fault", gp_fault);189 exc_register(14, "ident_mapper", ident_page_fault);190 184 } 191 185
Note:
See TracChangeset
for help on using the changeset viewer.