[SOLVED] Mouse Interrupt not firing
Posted: Thu Aug 05, 2021 10:44 am
Hi.
This is my first post here so I apologise in advance if I break any protocols.
I have an issue that I have spent the better part of the past three days trying to resolve. I have searched a lot on the internet and tried a lot of solutions on similar questions but still I have not resolved this issue.
The issue is as follows:
I have switched successfully to protected mode, loaded GDT and set up an IDT. The issue is that the mouse interrupt (12) never fires. The keyboard interrupt is working and I have double checked this on a real device.
The IDT is setup correctly as my mouse interrupt handler is called when I manually initiate a software interrupt (int 12). However, no matter what I do with the mouse, I do not get a hardware interrupt both on QEMU and a real pc.
This leads me to believe that the issue is with my mouse setup. Here is the code for my mouse setup:
Can you see what is wrong with this code? Thanks in advance for your help!
This is my first post here so I apologise in advance if I break any protocols.
I have an issue that I have spent the better part of the past three days trying to resolve. I have searched a lot on the internet and tried a lot of solutions on similar questions but still I have not resolved this issue.
The issue is as follows:
I have switched successfully to protected mode, loaded GDT and set up an IDT. The issue is that the mouse interrupt (12) never fires. The keyboard interrupt is working and I have double checked this on a real device.
The IDT is setup correctly as my mouse interrupt handler is called when I manually initiate a software interrupt (int 12). However, no matter what I do with the mouse, I do not get a hardware interrupt both on QEMU and a real pc.
This leads me to believe that the issue is with my mouse setup. Here is the code for my mouse setup:
Code: Select all
void InitialiseMouse() {
unsigned char _status; //unsigned char
// Enable the auxiliary mouse device
MouseWait(1);
outportb(0x64, 0xA8);
//Enable the interrupts
MouseWait(1);
outportb(0x64, 0x20);
MouseWait(0);
_status=(inportb(0x60) | 2);
MouseWait(1);
outportb(0x64, 0x60);
MouseWait(1);
outportb(0x60, _status);
MouseWrite(0xFF);
MouseRead();
//Tell the mouse to use default settings
MouseWrite(0xF6);
MouseRead(); //Acknowledge
//Enable the mouse
MouseWrite(0xF4);
MouseRead();
init_mouse_interrupt();
}
void MouseWrite(unsigned char data) {
MouseWait(1);
outportb(0x64, 0xd4);
MouseWait(1);
outportb(0x60, data);
}
unsigned char MouseRead() {
MouseWait(0);
return inportb(0x60);
}
void MouseWait(unsigned char type) {
int time_out = 100000;
if (type == 0) {
while (time_out--) {
if ((inportb(0x64) & 1) == 1)
return;
}
return;
}
else {
while (time_out--) {
if ((inportb(0x64) & 2) == 0)
return;
}
return;
}
}