2018-07-20 15:41:58 +02:00
|
|
|
#include "irq.h"
|
|
|
|
#include "idt.h"
|
|
|
|
#include "pic.h"
|
2018-08-06 21:00:58 +02:00
|
|
|
#include "stdarg.h"
|
2018-07-20 15:41:58 +02:00
|
|
|
|
|
|
|
int irqSetup()
|
|
|
|
{
|
2020-04-27 00:14:37 +02:00
|
|
|
initPic();
|
|
|
|
return 0;
|
2018-07-20 15:41:58 +02:00
|
|
|
}
|
|
|
|
|
2020-04-27 00:14:37 +02:00
|
|
|
irq_handler irq_handler_array[IRQ_NUM] = {
|
|
|
|
NULL,
|
|
|
|
};
|
2018-07-20 15:41:58 +02:00
|
|
|
|
|
|
|
int irqSetRoutine(int irq, irq_handler handler)
|
|
|
|
{
|
|
|
|
uint32_t flags;
|
|
|
|
if ((irq < 0) || irq >= IRQ_NUM)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
disable_IRQs(flags);
|
|
|
|
|
|
|
|
irq_handler_array[irq] = handler;
|
|
|
|
|
|
|
|
if (handler != NULL) {
|
2020-04-27 00:14:37 +02:00
|
|
|
int ret = idt_set_handler(IRQ_INTERRUPT_BASE_ADDRESS + irq,
|
|
|
|
(unsigned int)irq_handler_array[irq], 0);
|
2018-07-20 15:41:58 +02:00
|
|
|
if (!ret)
|
|
|
|
enableIrq(irq);
|
|
|
|
}
|
|
|
|
restore_IRQs(flags);
|
|
|
|
return 0;
|
|
|
|
}
|