Changeset fd67c9f in mainline for kernel/genarch
- Timestamp:
- 2019-04-06T08:10:27Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 534bcdf
- Parents:
- ef56a43
- Location:
- kernel/genarch
- Files:
-
- 2 edited
-
include/genarch/drivers/i8259/i8259.h (modified) (3 diffs)
-
src/drivers/i8259/i8259.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/genarch/drivers/i8259/i8259.h
ref56a43 rfd67c9f 38 38 #include <typedefs.h> 39 39 #include <arch/interrupt.h> 40 #include <stdbool.h> 40 41 41 42 /* ICW1 bits */ … … 43 44 #define PIC_ICW1_NEEDICW4 (1 << 0) 44 45 46 /* OCW3 bits */ 47 #define PIC_OCW3 (1 << 3) 48 #define PIC_OCW3_READ_ISR (3 << 0) 49 45 50 /* OCW4 bits */ 46 51 #define PIC_OCW4 (0 << 3) 47 52 #define PIC_OCW4_NSEOI (1 << 5) 53 54 #define PIC_IRQ_COUNT 8 55 #define PIC_SPURIOUS_IRQ 7 48 56 49 57 typedef struct { … … 56 64 extern void pic_disable_irqs(uint16_t); 57 65 extern void pic_eoi(unsigned int); 66 extern bool pic_is_spurious(unsigned int); 67 extern void pic_handle_spurious(unsigned int); 58 68 59 69 #endif -
kernel/genarch/src/drivers/i8259/i8259.c
ref56a43 rfd67c9f 90 90 (uint8_t) (x & (~(irqmask & 0xff)))); 91 91 } 92 if (irqmask >> 8) {92 if (irqmask >> PIC_IRQ_COUNT) { 93 93 x = pio_read_8(&saved_pic1->port2); 94 94 pio_write_8(&saved_pic1->port2, 95 (uint8_t) (x & (~(irqmask >> 8))));95 (uint8_t) (x & (~(irqmask >> PIC_IRQ_COUNT)))); 96 96 } 97 97 } … … 106 106 (uint8_t) (x | (irqmask & 0xff))); 107 107 } 108 if (irqmask >> 8) {108 if (irqmask >> PIC_IRQ_COUNT) { 109 109 x = pio_read_8(&saved_pic1->port2); 110 pio_write_8(&saved_pic1->port2, (uint8_t) (x | (irqmask >> 8))); 110 pio_write_8(&saved_pic1->port2, 111 (uint8_t) (x | (irqmask >> PIC_IRQ_COUNT))); 111 112 } 112 113 } … … 114 115 void pic_eoi(unsigned int irq) 115 116 { 116 if (irq >= 8)117 if (irq >= PIC_IRQ_COUNT) 117 118 pio_write_8(&saved_pic1->port1, PIC_OCW4 | PIC_OCW4_NSEOI); 118 119 pio_write_8(&saved_pic0->port1, PIC_OCW4 | PIC_OCW4_NSEOI); 119 120 } 120 121 122 bool pic_is_spurious(unsigned int irq) 123 { 124 pio_write_8(&saved_pic0->port1, PIC_OCW3 | PIC_OCW3_READ_ISR); 125 pio_write_8(&saved_pic1->port1, PIC_OCW3 | PIC_OCW3_READ_ISR); 126 uint8_t isr_lo = pio_read_8(&saved_pic0->port1); 127 uint8_t isr_hi = pio_read_8(&saved_pic1->port1); 128 return !(((isr_hi << PIC_IRQ_COUNT) | isr_lo) & (1 << irq)); 129 } 130 131 void pic_handle_spurious(unsigned int irq) 132 { 133 /* For spurious IRQs from pic1, we need to isssue an EOI to pic0 */ 134 if (irq >= PIC_IRQ_COUNT) 135 pio_write_8(&saved_pic0->port1, PIC_OCW4 | PIC_OCW4_NSEOI); 136 } 137 121 138 /** @} 122 139 */
Note:
See TracChangeset
for help on using the changeset viewer.
