Changeset 2a103b5 in mainline
- Timestamp:
- 2019-06-09T11:31:38Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c48de91
- Parents:
- b401b33
- Location:
- kernel
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/arch/interrupt.h
rb401b33 r2a103b5 84 84 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 85 85 86 extern void (*disable_irqs_function)(uint16_t);87 extern void (*enable_irqs_function)(uint16_t);88 extern void (*eoi_function)(unsigned int);89 extern const char *irqs_info;90 91 86 extern void interrupt_init(void); 92 extern void trap_virtual_enable_irqs(uint16_t);93 extern void trap_virtual_disable_irqs(uint16_t);94 87 95 88 #endif -
kernel/arch/amd64/src/amd64.c
rb401b33 r2a103b5 60 60 #include <arch/vreg.h> 61 61 #include <arch/kseg.h> 62 #include <genarch/pic/pic_ops.h> 62 63 63 64 #ifdef CONFIG_SMP … … 123 124 (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE); 124 125 125 /* 126 * Set the enable/disable IRQs handlers. 127 * Set the End-of-Interrupt handler. 128 */ 129 enable_irqs_function = pic_enable_irqs; 130 disable_irqs_function = pic_disable_irqs; 131 eoi_function = pic_eoi; 132 irqs_info = "i8259"; 126 /* Set PIC operations. */ 127 pic_ops = &i8259_pic_ops; 133 128 } 134 129 } … … 209 204 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 210 205 i8042_wire(i8042_instance, kbrd); 211 trap_virtual_enable_irqs(1 << IRQ_KBD);212 trap_virtual_enable_irqs(1 << IRQ_MOUSE);206 pic_ops->enable_irqs(1 << IRQ_KBD); 207 pic_ops->enable_irqs(1 << IRQ_MOUSE); 213 208 } 214 209 } … … 235 230 indev_t *srln = srln_wire(srln_instance, sink); 236 231 ns16550_wire(ns16550_instance, srln); 237 trap_virtual_enable_irqs(1 << IRQ_NS16550);232 pic_ops->enable_irqs(1 << IRQ_NS16550); 238 233 } 239 234 #endif … … 246 241 #endif 247 242 248 if (irqs_info != NULL) 249 sysinfo_set_item_val(irqs_info, NULL, true); 243 sysinfo_set_item_val(pic_ops->get_name(), NULL, true); 250 244 } 251 245 -
kernel/arch/amd64/src/interrupt.c
rb401b33 r2a103b5 38 38 #include <panic.h> 39 39 #include <genarch/drivers/i8259/i8259.h> 40 #include <genarch/pic/pic_ops.h> 40 41 #include <halt.h> 41 42 #include <cpu.h> … … 57 58 * Interrupt and exception dispatching. 58 59 */ 59 60 void (*disable_irqs_function)(uint16_t irqmask) = NULL; 61 void (*enable_irqs_function)(uint16_t irqmask) = NULL; 62 void (*eoi_function)(unsigned int) = NULL; 63 const char *irqs_info = NULL; 60 pic_ops_t *pic_ops = NULL; 64 61 65 62 void istate_decode(istate_t *istate) … … 89 86 "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n", 90 87 istate->r12, istate->r13, istate->r14, istate->r15); 91 }92 93 static void trap_virtual_eoi(unsigned int irq)94 {95 if (eoi_function)96 eoi_function(irq);97 else98 panic("No eoi_function.");99 100 88 } 101 89 … … 157 145 static void tlb_shootdown_ipi(unsigned int n, istate_t *istate) 158 146 { 159 trap_virtual_eoi(0);147 pic_ops->eoi(0); 160 148 tlb_shootdown_ipi_recv(); 161 149 } … … 182 170 if (irq->preack) { 183 171 /* Send EOI before processing the interrupt */ 184 trap_virtual_eoi(inum);172 pic_ops->eoi(inum); 185 173 ack = true; 186 174 } … … 195 183 196 184 if (!ack) 197 trap_virtual_eoi(inum);185 pic_ops->eoi(inum); 198 186 } 199 187 … … 201 189 { 202 190 unsigned int inum = n - IVT_IRQBASE; 203 if (!pic_ is_spurious(inum)) {191 if (!pic_ops->is_spurious(inum)) { 204 192 /* This is actually not a spurious IRQ, so proceed as usual. */ 205 193 irq_interrupt(n, istate); 206 194 return; 207 195 } 208 pic_ handle_spurious(n);196 pic_ops->handle_spurious(n); 209 197 #ifdef CONFIG_DEBUG 210 198 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id, … … 242 230 } 243 231 244 void trap_virtual_enable_irqs(uint16_t irqmask)245 {246 if (enable_irqs_function)247 enable_irqs_function(irqmask);248 else249 panic("No enable_irqs_function.");250 }251 252 void trap_virtual_disable_irqs(uint16_t irqmask)253 {254 if (disable_irqs_function)255 disable_irqs_function(irqmask);256 else257 panic("No disable_irqs_function.");258 }259 260 232 /** @} 261 233 */ -
kernel/arch/ia32/include/arch/interrupt.h
rb401b33 r2a103b5 88 88 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 89 89 90 extern void (*disable_irqs_function)(uint16_t);91 extern void (*enable_irqs_function)(uint16_t);92 extern void (*eoi_function)(unsigned int);93 extern const char *irqs_info;94 95 90 extern void interrupt_init(void); 96 extern void trap_virtual_enable_irqs(uint16_t);97 extern void trap_virtual_disable_irqs(uint16_t);98 91 99 92 #endif -
kernel/arch/ia32/include/arch/smp/apic.h
rb401b33 r2a103b5 43 43 #include <cpu.h> 44 44 #include <stdint.h> 45 #include <genarch/pic/pic_ops.h> 45 46 46 47 #define FIXED (0 << 0) … … 347 348 } io_apic_id_t; 348 349 350 extern pic_ops_t apic_pic_ops; 351 349 352 extern volatile uint32_t *l_apic; 350 353 extern volatile uint32_t *io_apic; -
kernel/arch/ia32/src/drivers/i8254.c
rb401b33 r2a103b5 96 96 { 97 97 pio_write_8(CLK_PORT4, 0x36); 98 pic_disable_irqs(1 << IRQ_CLK);98 i8259_disable_irqs(1 << IRQ_CLK); 99 99 pio_write_8(CLK_PORT1, (CLK_CONST / HZ) & 0xf); 100 100 pio_write_8(CLK_PORT1, (CLK_CONST / HZ) >> 8); 101 pic_enable_irqs(1 << IRQ_CLK);101 i8259_enable_irqs(1 << IRQ_CLK); 102 102 } 103 103 -
kernel/arch/ia32/src/ia32.c
rb401b33 r2a103b5 58 58 #include <genarch/multiboot/multiboot.h> 59 59 #include <genarch/multiboot/multiboot2.h> 60 #include <genarch/pic/pic_ops.h> 60 61 #include <arch/pm.h> 61 62 #include <arch/vreg.h> … … 112 113 (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE); 113 114 114 /* 115 * Set the enable/disable IRQs handlers. 116 * Set the End-of-Interrupt handler. 117 */ 118 enable_irqs_function = pic_enable_irqs; 119 disable_irqs_function = pic_disable_irqs; 120 eoi_function = pic_eoi; 121 irqs_info = "i8259"; 115 /* Set PIC operations. */ 116 pic_ops = &i8259_pic_ops; 122 117 } 123 118 } … … 194 189 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 195 190 i8042_wire(i8042_instance, kbrd); 196 trap_virtual_enable_irqs(1 << IRQ_KBD);197 trap_virtual_enable_irqs(1 << IRQ_MOUSE);191 pic_ops->enable_irqs(1 << IRQ_KBD); 192 pic_ops->enable_irqs(1 << IRQ_MOUSE); 198 193 } 199 194 } … … 220 215 indev_t *srln = srln_wire(srln_instance, sink); 221 216 ns16550_wire(ns16550_instance, srln); 222 trap_virtual_enable_irqs(1 << IRQ_NS16550);217 pic_ops->enable_irqs(1 << IRQ_NS16550); 223 218 } 224 219 #endif … … 231 226 #endif 232 227 233 if (irqs_info != NULL) 234 sysinfo_set_item_val(irqs_info, NULL, true); 228 sysinfo_set_item_val(pic_ops->get_name(), NULL, true); 235 229 } 236 230 -
kernel/arch/ia32/src/interrupt.c
rb401b33 r2a103b5 40 40 #include <panic.h> 41 41 #include <genarch/drivers/i8259/i8259.h> 42 #include <genarch/pic/pic_ops.h> 42 43 #include <halt.h> 43 44 #include <cpu.h> … … 61 62 */ 62 63 63 void (*disable_irqs_function)(uint16_t irqmask) = NULL; 64 void (*enable_irqs_function)(uint16_t irqmask) = NULL; 65 void (*eoi_function)(unsigned int) = NULL; 66 const char *irqs_info = NULL; 64 pic_ops_t *pic_ops = NULL; 67 65 68 66 void istate_decode(istate_t *istate) … … 88 86 istate_from_uspace(istate) ? istate->esp : 89 87 (uint32_t) &istate->esp); 90 }91 92 static void trap_virtual_eoi(unsigned int inum)93 {94 if (eoi_function)95 eoi_function(inum);96 else97 panic("No eoi_function.");98 99 88 } 100 89 … … 179 168 istate_t *istate __attribute__((unused))) 180 169 { 181 trap_virtual_eoi(0);170 pic_ops->eoi(0); 182 171 tlb_shootdown_ipi_recv(); 183 172 } … … 202 191 if (irq->preack) { 203 192 /* Send EOI before processing the interrupt */ 204 trap_virtual_eoi(inum);193 pic_ops->eoi(inum); 205 194 ack = true; 206 195 } … … 215 204 216 205 if (!ack) 217 trap_virtual_eoi(inum);206 pic_ops->eoi(inum); 218 207 } 219 208 … … 221 210 { 222 211 unsigned int inum = n - IVT_IRQBASE; 223 if (!pic_ is_spurious(inum)) {212 if (!pic_ops->is_spurious(inum)) { 224 213 /* This is actually not a spurious IRQ, so proceed as usual. */ 225 214 irq_interrupt(n, istate); 226 215 return; 227 216 } 228 pic_ handle_spurious(n);217 pic_ops->handle_spurious(n); 229 218 #ifdef CONFIG_DEBUG 230 219 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id, … … 264 253 } 265 254 266 void trap_virtual_enable_irqs(uint16_t irqmask)267 {268 if (enable_irqs_function)269 enable_irqs_function(irqmask);270 else271 panic("No enable_irqs_function.");272 }273 274 void trap_virtual_disable_irqs(uint16_t irqmask)275 {276 if (disable_irqs_function)277 disable_irqs_function(irqmask);278 else279 panic("No disable_irqs_function.");280 }281 282 255 /** @} 283 256 */ -
kernel/arch/ia32/src/smp/apic.c
rb401b33 r2a103b5 47 47 #include <arch.h> 48 48 #include <ddi/irq.h> 49 #include <genarch/pic/pic_ops.h> 49 50 50 51 #ifdef CONFIG_SMP … … 63 64 */ 64 65 66 static const char *apic_get_name(void); 67 static bool l_apic_is_spurious(unsigned int); 68 static void l_apic_handle_spurious(unsigned int); 69 70 pic_ops_t apic_pic_ops = { 71 .get_name = apic_get_name, 72 .enable_irqs = io_apic_enable_irqs, 73 .disable_irqs = io_apic_disable_irqs, 74 .eoi = l_apic_eoi, 75 .is_spurious = l_apic_is_spurious, 76 .handle_spurious = l_apic_handle_spurious, 77 }; 78 65 79 /* 66 80 * These variables either stay configured as initilalized, or are changed by … … 125 139 #endif /* LAPIC_VERBOSE */ 126 140 141 const char *apic_get_name(void) 142 { 143 return "apic"; 144 } 145 146 bool l_apic_is_spurious(unsigned int n) 147 { 148 return n == VECTOR_APIC_SPUR; 149 } 150 151 void l_apic_handle_spurious(unsigned int n) 152 { 153 } 154 127 155 /** APIC spurious interrupt handler. 128 156 * … … 134 162 istate_t *istate __attribute__((unused))) 135 163 { 136 #ifdef CONFIG_DEBUG137 log(LF_ARCH, LVL_DEBUG, "cpu%u: APIC spurious interrupt", CPU->id);138 #endif139 164 } 140 165 … … 175 200 (iroutine_t) apic_spurious); 176 201 177 enable_irqs_function = io_apic_enable_irqs; 178 disable_irqs_function = io_apic_disable_irqs; 179 eoi_function = l_apic_eoi; 180 irqs_info = "apic"; 202 pic_ops = &apic_pic_ops; 181 203 182 204 /* -
kernel/arch/ia32/src/smp/smp.c
rb401b33 r2a103b5 130 130 pio_write_8((ioport8_t *) 0x71, 0xa); 131 131 132 pic_disable_irqs(0xffff);132 i8259_disable_irqs(0xffff); 133 133 apic_init(); 134 134 -
kernel/arch/ia64/include/arch/interrupt.h
rb401b33 r2a103b5 92 92 extern void disabled_fp_register(unsigned int, istate_t *); 93 93 94 extern void trap_virtual_enable_irqs(uint16_t);95 96 94 void exception_init(void); 97 95 #endif -
kernel/arch/ia64/src/interrupt.c
rb401b33 r2a103b5 301 301 } 302 302 303 void trap_virtual_enable_irqs(uint16_t irqmask)304 {305 }306 307 303 void exception_init(void) 308 304 { -
kernel/arch/mips32/src/mach/malta/malta.c
rb401b33 r2a103b5 75 75 { 76 76 uint8_t isa_irq = host2uint32_t_le(pio_read_32(GT64120_PCI0_INTACK)); 77 if ( pic_is_spurious(isa_irq)) {78 pic_handle_spurious(isa_irq);77 if (i8259_is_spurious(isa_irq)) { 78 i8259_handle_spurious(isa_irq); 79 79 #ifdef CONFIG_DEBUG 80 80 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", … … 93 93 #endif 94 94 } 95 pic_eoi(isa_irq);95 i8259_eoi(isa_irq); 96 96 } 97 97 … … 146 146 indev_t *srln = srln_wire(srln_instance, sink); 147 147 ns16550_wire(tty_instance, srln); 148 pic_enable_irqs(1 << TTY_ISA_IRQ);148 i8259_enable_irqs(1 << TTY_ISA_IRQ); 149 149 } 150 150 } -
kernel/genarch/include/genarch/drivers/i8259/i8259.h
rb401b33 r2a103b5 38 38 #include <typedefs.h> 39 39 #include <arch/interrupt.h> 40 #include <genarch/pic/pic_ops.h> 40 41 #include <stdbool.h> 41 42 … … 62 63 } __attribute__((packed)) i8259_t; 63 64 65 extern pic_ops_t i8259_pic_ops; 66 64 67 extern void i8259_init(i8259_t *, i8259_t *, unsigned int); 65 extern void pic_enable_irqs(uint16_t);66 extern void pic_disable_irqs(uint16_t);67 extern void pic_eoi(unsigned int);68 extern bool pic_is_spurious(unsigned int);69 extern void pic_handle_spurious(unsigned int);68 extern void i8259_enable_irqs(uint16_t); 69 extern void i8259_disable_irqs(uint16_t); 70 extern void i8259_eoi(unsigned int); 71 extern bool i8259_is_spurious(unsigned int); 72 extern void i8259_handle_spurious(unsigned int); 70 73 71 74 #endif -
kernel/genarch/src/drivers/i8259/i8259.c
rb401b33 r2a103b5 43 43 #include <interrupt.h> 44 44 45 static const char *i8259_get_name(void); 46 47 pic_ops_t i8259_pic_ops = { 48 .get_name = i8259_get_name, 49 .enable_irqs = i8259_enable_irqs, 50 .disable_irqs = i8259_disable_irqs, 51 .eoi = i8259_eoi, 52 .is_spurious = i8259_is_spurious, 53 .handle_spurious = i8259_handle_spurious 54 }; 55 45 56 // XXX: need to change pic_* API to get rid of these 46 57 static i8259_t *saved_pic0; … … 76 87 pio_write_8(&pic1->port2, 1); 77 88 78 pic_disable_irqs(0xffff); /* disable all irq's */79 pic_enable_irqs(1 << PIC0_IRQ_PIC1); /* but enable PIC0_IRQ_PIC1 */89 i8259_disable_irqs(0xffff); /* disable all irq's */ 90 i8259_enable_irqs(1 << PIC0_IRQ_PIC1); /* but enable PIC0_IRQ_PIC1 */ 80 91 } 81 92 82 void pic_enable_irqs(uint16_t irqmask) 93 const char *i8259_get_name(void) 94 { 95 return "i8259"; 96 } 97 98 void i8259_enable_irqs(uint16_t irqmask) 83 99 { 84 100 uint8_t x; … … 96 112 } 97 113 98 void pic_disable_irqs(uint16_t irqmask)114 void i8259_disable_irqs(uint16_t irqmask) 99 115 { 100 116 uint8_t x; … … 112 128 } 113 129 114 void pic_eoi(unsigned int irq)130 void i8259_eoi(unsigned int irq) 115 131 { 116 132 if (irq >= PIC0_IRQ_COUNT) … … 119 135 } 120 136 121 bool pic_is_spurious(unsigned int irq)137 bool i8259_is_spurious(unsigned int irq) 122 138 { 123 139 pio_write_8(&saved_pic0->port1, PIC_OCW3 | PIC_OCW3_READ_ISR); … … 128 144 } 129 145 130 void pic_handle_spurious(unsigned int irq)146 void i8259_handle_spurious(unsigned int irq) 131 147 { 132 148 /* For spurious IRQs from pic1, we need to isssue an EOI to pic0 */
Note:
See TracChangeset
for help on using the changeset viewer.