IRQ mouse driver
Posted: Tue Apr 04, 2017 7:05 am
I am making an os in c and nasm, and I want to do irqs so that I can get a mouse driver to work. I found this: http://www.osdever.net/bkerndev/Docs/irqs.htm, but when I try to compile the c code part of it, I get:
and here is the whole code:
Sorry if this is not the right place to ask, but as you all develop oses as oppose to, for example, the people on stackoverflow or something, then I would assume that you would have encountered this problem once if not, multiple times.
Thanks in advance, all replies will be appreciated!!
Code: Select all
interrupts/irq.c:4:1: error: parameter ‘irq_routines’ is initialized
void* irq_routines[16] = {
Code: Select all
#include "irq.h"
void* irq_routines[16] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
void irq_add_handler(int irq, void (*handler) (struct registers* r)) {
irq_routines[irq] = handler;
}
void irq_remove_handler(int irq) {
irq_routines[irq] = 0;
}
void irq_remap(void) {
outportb(0x20, 0x11);
outportb(0xA0, 0x11);
outportb(0x21, 0x20);
outportb(0xA1, 0x28);
outportb(0x21, 0x04);
outportb(0xA1, 0x02);
outportb(0x21, 0x01);
outportb(0xA1, 0x01);
outportb(0x21, 0x0);
outportb(0xA1, 0x0);
}
void irq_init(void) {
irq_remap();
set_idt_gate(32, (unsigned) irq0);
set_idt_gate(33, (unsigned) irq1);
set_idt_gate(34, (unsigned) irq2);
set_idt_gate(35, (unsigned) irq3);
set_idt_gate(36, (unsigned) irq4);
set_idt_gate(37, (unsigned) irq5);
set_idt_gate(38, (unsigned) irq6);
set_idt_gate(39, (unsigned) irq7);
set_idt_gate(40, (unsigned) irq8);
set_idt_gate(41, (unsigned) irq9);
set_idt_gate(42, (unsigned) irq10);
set_idt_gate(43, (unsigned) irq11);
set_idt_gate(44, (unsigned) irq12);
set_idt_gate(45, (unsigned) irq13);
set_idt_gate(46, (unsigned) irq14);
set_idt_gate(47, (unsigned) irq15);
}
void irq_handler(struct registers* r) {
void (*handler) (struct registers* r);
handler = irq_routines[r->num - 32];
if (handler) {
handler(r);
} if (r->num >= 40) {
outportb(0xA0, 0x20);
}
outportb(0x20, 0x20);
}
Thanks in advance, all replies will be appreciated!!