Cant get PS2 Mouse interrupt to work
Posted: Tue May 09, 2023 12:57 pm
Hi,
I tried implementing an interrupt handler for the mouse in my x64 OS.
The code is the same as SANiK's one, but the interrupt handler is already "installed".
All the IDT stuff is working fine (both the keyboard and PIT work fine even in real hardware).
The only thing i do with the PIC is remapping it, as the wiki says
Maybe I am missing something with the init code:
The handler never fires. I tried with different tutorials, but i get no interrupt: the only thing that changes is that the keyboard stops working.
I tried implementing an interrupt handler for the mouse in my x64 OS.
The code is the same as SANiK's one, but the interrupt handler is already "installed".
All the IDT stuff is working fine (both the keyboard and PIT work fine even in real hardware).
The only thing i do with the PIC is remapping it, as the wiki says
Maybe I am missing something with the init code:
Code: Select all
void ps2mouse_setup() {
// Unmask the pic
uint8_t oldpic = inb(PIC2_DATA);
outb(PIC2_DATA, oldpic & (~PIC_PS2MOUSE_IRQ)); // PIC_PS2MOUSE_IRQ = 0b00010000
uint8_t status;
//Enable the auxiliary mouse device
ps2mouse_wait(1);
outportb(0x64, 0xA8);
//Enable the interrupts
ps2mouse_wait(1);
outportb(0x64, 0x20);
ps2mouse_wait(0);
status = (inportb(0x60) | 2);
ps2mouse_wait(1);
outportb(0x64, 0x60);
ps2mouse_wait(1);
outportb(0x60, status);
//Tell the mouse to use default settings
ps2mouse_write(0xF6);
ps2mouse_read(); //Acknowledge
//Enable the mouse
ps2mouse_write(0xF4);
ps2mouse_read(); //Acknowledge
return;
}