Apologies, here is the rest of the code.
This is the code to setup the interrupts (base and base12 are pointers to function addresses for interrupt handler functions):
Code:
void InitialiseIDT() {
_idt[1].lower = (base & 0xffff);
_idt[1].higher = (base >> 16) & 0xffff;
_idt[1].selector = 0x08;
_idt[1].zero = 0;
_idt[1].flags = 0x8e;
_idt[12].lower = (base12 & 0xffff);
_idt[12].higher = (base12 >> 16) & 0xffff;
_idt[12].selector = 0x08;
_idt[12].zero = 0;
_idt[12].flags = 0x8e;
RemapPIC();
outportb(0x21, 0xfd);
outportb(0xa1, 0xff);
LoadIDT();
}
This is the code to remap pic:
Code:
#define PIC1_C 0x20
#define PIC1_D 0x21
#define PIC2_C 0xa0
#define PIC2_D 0xa1
#define ICW1_DEF 0x10
#define ICW1_ICW4 0x01
#define ICW4_x86 0x01
void RemapPIC() {
unsigned char a, b;
a = inportb(PIC1_D);
b = inportb(PIC2_D);
outportb(PIC1_C, ICW1_DEF | ICW1_ICW4);
outportb(PIC2_C, ICW1_DEF | ICW1_ICW4);
outportb(PIC1_D, 0);
outportb(PIC2_D, 8);
outportb(PIC1_D, 4);
outportb(PIC2_D, 2);
outportb(PIC1_D, ICW4_x86);
outportb(PIC2_D, ICW4_x86);
outportb(PIC1_D, a);
outportb(PIC2_D, b);
}
And this is the assembly code:
Code:
extern _idt
extern HandleISR1, HandleISR12, mouse_handler, initialise_mouse
global isr1, isr12
global LoadIDT, mouse_init
IDTDesc:
dw 2048
dd _idt
isr1:
pusha
call HandleISR1
popa
iret
isr12:
jmp $
pusha
call HandleISR12
popa
iret
LoadIDT:
lidt[IDTDesc]
sti
ret
Like I said if I call int 12 manually in assembly, the interrupt handler 12 function is called. Basically hardware is not generating interrupts.