/** Pre-handling function. * @param num IRQ number. * @return True if IRQ should be handled. */ static bool pic_pre_handle(unsigned num) { assert(num < 16); /* Check for spurious IRQs. */ if(num == 7) { /* Read the In-Service Register, check the high bit. */ out8(0x23, 3); if((in8(0x20) & 0x80) == 0) { kprintf(LOG_DEBUG, "pic: spurious IRQ7 (master), ignoring...\n"); return false; } } else if(num == 15) { /* Read the In-Service Register, check the high bit. */ out8(0xA3, 3); if((in8(0xA0) & 0x80) == 0) { kprintf(LOG_DEBUG, "pic: spurious IRQ15 (slave), ignoring...\n"); return false; } } /* Edge-triggered interrupts must be acked before we handle. */ if(!(pic_level_triggered & (1 << num))) pic_eoi(num); return true; }
void timer_intr(void) { timer_systime_counter.low++; if(timer_systime_counter.low >= TIMER_SYSTIME_LOW_RESO) { timer_systime_counter.high++; timer_systime_counter.low = 0; } pic_eoi(PIC_IRQ_TIMER); /* notify "Reception completion" to PIC */ /* { static char i=0; int pos; char s[4]; byte2hex(i,s); i++; pos = console_getpos(); console_locatepos(77,0); console_puts(s); console_putpos(pos); } */ alarm_check(); task_tick(); task_dispatch(); return; }
void cIRQ1(irq_stack_t regs) { uint8_t c = ol_ps2_get_keyboard_scancode(); kb_handle(c); pic_eoi(1); return; }
void cIRQ8(irq_stack_t regs) { printf("test\n"); outb(CMOS_SELECT, CMOS_RTC_IRQ); inb(CMOS_DATA); pic_eoi(8); return; }
void _inthandler26() { if(fdc_reset) wake_up_event(WAIT_IRQ6); else fdc_reset = true; pic_eoi(6); }
INLINE int pic_is_spurious(unsigned irq) { uint16_t isr = pic_get_isr(); if (irq == 7) return isr != 128; else if (irq == 15) { if (isr != 0x8004) { pic_eoi(2); return 0; } else return 1; } else return 0; }
void pic_isr(struct thread_state* state, unsigned ring, unsigned irq) { (void)state; (void)ring; unsigned pirq = irq - 32; if (!pic_is_spurious(pirq)) { if (pirq == 8) rtc_update(); // try to keep RTC latency as low as possible. pic_eoi(pirq); isr_send_signal(irq); } }
void pit_handler(struct interrupt_info* info) { pic_eoi(false); static int counter = 0; static int number = 0; ++counter; if (counter >= PIT_TICKS) { ++number; counter = 0; schedule(THREAD_NEW_STATE_ALIVE); } }
void cIRQ0(irq_stack_t regs) { if (isSleeping) { if (!(sleepTime == 0)) sleepTime--; } pit_timer += 1; pic_eoi(0); return; }
void cIRQ4(irq_stack_t regs) { pic_eoi(4); return; }
void cIRQ11(irq_stack_t regs) { pic_eoi(11); return; }
/** Post-handling function. * @param num IRQ number. */ static void pic_post_handle(unsigned num) { /* Level-triggered interrupts must be acked once all handlers have been * run. */ if(pic_level_triggered & (1 << num)) pic_eoi(num); }
void cIRQ14(irq_stack_t regs) { putc('a'); pic_eoi(14); return; }
void cIRQ15(irq_stack_t regs) { putc('b'); pic_eoi(15); return; }
void cIRQ7(irq_stack_t regs) { pic_eoi(7); return; }
void cIRQ6(irq_stack_t regs) { pic_eoi(6); return; }
void cIRQ10(irq_stack_t regs) { pic_eoi(10); return; }
void cIRQ3(irq_stack_t regs) { pic_eoi(3); return; }
void cIRQ2(irq_stack_t regs) { pic_eoi(2); return; }
void cIRQ5(irq_stack_t regs) { pic_eoi(5); return; }
void cIRQ9(irq_stack_t regs) { putc('a'); pic_eoi(9); return; }