Espresso 0.0.1d
This commit is contained in:
@ -4,26 +4,63 @@
|
||||
|
||||
#include <drivers/irq.h>
|
||||
|
||||
irq_func_t func_list[64];
|
||||
#define NUM_IRQS 0x90
|
||||
|
||||
irq_func_t func_list[NUM_IRQS];
|
||||
irq_func_t aux_func_list[NUM_IRQS];
|
||||
|
||||
static volatile uint32_t num_irqs_missed = 0;
|
||||
|
||||
void irq_init(void)
|
||||
{
|
||||
memset(func_list, 0x0, NUM_IRQS);
|
||||
memset(aux_func_list, 0x0, NUM_IRQS);
|
||||
|
||||
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 < 64 && func_list[irq_number])
|
||||
if (irq_number < NUM_IRQS)
|
||||
{
|
||||
func_list[irq_number]();
|
||||
if (func_list[irq_number])
|
||||
{
|
||||
func_list[irq_number]();
|
||||
}
|
||||
else if (aux_func_list[irq_number])
|
||||
{
|
||||
aux_func_list[irq_number]();
|
||||
}
|
||||
else
|
||||
{
|
||||
num_irqs_missed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_irq_handler(uint32_t num, irq_func_t* handler)
|
||||
{
|
||||
if (num < 64)
|
||||
if (num < NUM_IRQS)
|
||||
{
|
||||
func_list[num] = (irq_func_t)handler;
|
||||
}
|
||||
}
|
||||
|
||||
void add_irq_handler(uint32_t num, irq_func_t* handler)
|
||||
{
|
||||
if (num < NUM_IRQS)
|
||||
{
|
||||
if (func_list[num] != 0x0)
|
||||
{
|
||||
if (aux_func_list[num] == 0x0)
|
||||
{
|
||||
aux_func_list[num] = (irq_func_t)handler;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
func_list[num] = (irq_func_t)handler;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user