So it does matter if I do not read the 3 bytes mouse packet if i handle a IRQ12?turdus wrote:That could take a while to set. Read and check it in a loop (timeout). For example I try it 1000 times before saying it was a false IRQ.
[RESOLVED] ps/2 mouse initalization / keyboard interrupt
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
well I did wait. even for 1m cycles and more. the byte at 0x64 is always 0 although a IRQ12 fired. that may come from the emu as does the one and only IRQ 1 that signals the release of the enter key when starting the emulation.
the ISR for the keyboard does enable the keyboard and signal eoi when returning. after that IRQ1 does not fire anymore. all other IRQs like 0,8 or 12 do work without problems.
I did not enable IRQ2, and if I do, it changes nothing.
the ISR for the keyboard does enable the keyboard and signal eoi when returning. after that IRQ1 does not fire anymore. all other IRQs like 0,8 or 12 do work without problems.
I did not enable IRQ2, and if I do, it changes nothing.
Re: ps/2 mouse initalization / keyboard interrupt
What initialization commands did you send for enabling the Mouse Packets? You may want to post that snippet too.
Run your code under BOCHS and see how it reports the key strokes. It is possible that the debug window acknowledges "Scan code turned off" which is the obvious cause of incorrect initialization commands. Or may be, "Keyboard: Internal Buffer Full" when the handler is not called in the first place. This helps to catch up most of the issues at an instant.
Run your code under BOCHS and see how it reports the key strokes. It is possible that the debug window acknowledges "Scan code turned off" which is the obvious cause of incorrect initialization commands. Or may be, "Keyboard: Internal Buffer Full" when the handler is not called in the first place. This helps to catch up most of the issues at an instant.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
at first a used the initialization sequence from SANiK'S code. then I tried this:
mouse_wait(arg) waits for bit 0 set or bit 1 unset on port 0x64 if argument is 0 or 1 respectively.
mouse_wait_ack(arg) waits for 0xFA or given argument on port 0x60.
In Qemu it works perfectly except that IRQ1 does not fire after IRQ12 fires for the first time.
BOCHS does send another ACK somewhere which kinda messes up the data packets, but it does not report any errors from the keyboard and IRQ1 does not work either.
Code: Select all
mouse_wait(1);
outportb(0x64, 0xA8);
mouse_wait(1);
outportb(0x64, 0x20);
mouse_wait(0);
_status=(inportb(0x60) | 2);
_status= (_status & 0xDF);
mouse_wait(1);
outportb(0x64, 0x60);
mouse_wait(1);
outportb(0x60, _status);
mouse_write(0xFF);
mouse_read_ack(0xAA); //wait for 0xAA on reset
mouse_write(0xEA);
mouse_read_ack();
mouse_write(0xF4);
mouse_read_ack();
outportb(0x64, 0xAE);
mouse_wait_ack(arg) waits for 0xFA or given argument on port 0x60.
In Qemu it works perfectly except that IRQ1 does not fire after IRQ12 fires for the first time.
BOCHS does send another ACK somewhere which kinda messes up the data packets, but it does not report any errors from the keyboard and IRQ1 does not work either.
Re: ps/2 mouse initalization / keyboard interrupt
Code: Select all
outportb(0x64, 0xAE);
Edit: Do not issue command 0xD4 before 0xF4 as that would validate the command for mouse.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
If I send 0xF4 instead of 0xAE it locks everything up.Chandra wrote:Send 0xF4 to the command port, this time to enable keyboard. See how that goes.
Re: ps/2 mouse initalization / keyboard interrupt
Probably because you didn't read the ACK byte from the keyboard controller.megatron23 wrote:If I send 0xF4 instead of 0xAE it locks everything up.Chandra wrote:Send 0xF4 to the command port, this time to enable keyboard. See how that goes.
Besides, I tried your initialization code. No problem there, other than the reset command which causes mouse to behave really weird, no problem with the keyboard though. The only change I made was replace mouse_read_ack(0xAA); with mouse_read(); since I don't have your version.
With that, it's really hard to find the source of problem. Can you attach your binary and the source files? This problem really got me interested.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
After a lot of search I found out that I am not the only one with that problem:
http://forum.osdev.org/viewtopic.php?f= ... 3&start=15
http://forum.osdev.org/viewtopic.php?f= ... 3&start=15
What emulator did you use? Does it work everytime w/out problems?Besides, I tried your initialization code. No problem there, other than the reset command which causes mouse to behave really weird, no problem with the keyboard though.
Re: ps/2 mouse initalization / keyboard interrupt
It does, at least with QEMU and BOCHS. The reset routine dis-aligns the mouse packets so I dropped it and it worked fine.megatron23 wrote:What emulator did you use? Does it work everytime w/out problems?
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
Can you show me your (now modified) mouse and keyboard initalization code. And the ISR of IRQ1.Chandra wrote:It does, at least with QEMU and BOCHS. The reset routine dis-aligns the mouse packets so I dropped it and it worked fine.
What version of qemu did you use?
-
- Posts: 19
- Joined: Sat Oct 22, 2011 3:03 pm
Re: ps/2 mouse initalization / keyboard interrupt
Finally it worked. I did not send anything to set or reset. Just enabling the interrupts an 0xF4 to enable the mouse. That's it. At least for qemu.
Re: ps/2 mouse initalization / keyboard interrupt
Maybe you should check my initalization code. It's written is asm, but you can read what bytes send and read quite easily.megatron23 wrote:Finally it worked. I did not send anything to set or reset. Just enabling the interrupts an 0xF4 to enable the mouse. That's it. At least for qemu.
http://forum.osdev.org/viewtopic.php?f=1&t=24277
The sequance to use is not straightforward, there are funny things like optional ack and values read instead of ack, and others. The init seq I use is a known good one, and it also enables wheel and 4th, 5th buttons for you, and autodetects the packet size (whether 3 or 4 bytes). And it does not interfere with keyboard.