49 lines
814 B
C
49 lines
814 B
C
#include <stdio.h>
|
|
#include <drivers/ps2_keyboard.h>
|
|
#include <drivers/pit.h>
|
|
#include <port_io.h>
|
|
|
|
#include <drivers/irq.h>
|
|
|
|
#define NUM_IRQS 0x90
|
|
|
|
irq_func_t func_list[NUM_IRQS];
|
|
|
|
|
|
|
|
static volatile uint32_t num_irqs_missed = 0;
|
|
|
|
void irq_init(void)
|
|
{
|
|
for (int i = 0; i < NUM_IRQS; i++)
|
|
{
|
|
func_list[i] = 0x0;
|
|
}
|
|
set_irq_handler(0, (irq_func_t*)pit_handler);
|
|
set_irq_handler(1, (irq_func_t*)keyboard_handler);
|
|
}
|
|
|
|
void irq_handler(uint8_t irq_number)
|
|
{
|
|
if (irq_number < NUM_IRQS)
|
|
{
|
|
if (func_list[irq_number])
|
|
{
|
|
func_list[irq_number]();
|
|
outb(0x20, 0x20); /* Acknowledge the IRQ to PIC */
|
|
}
|
|
else
|
|
{
|
|
num_irqs_missed++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void set_irq_handler(uint32_t num, irq_func_t* handler)
|
|
{
|
|
if (num < NUM_IRQS)
|
|
{
|
|
func_list[num] = (irq_func_t)handler;
|
|
}
|
|
}
|