OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 13, 2024 11:57 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Mon Oct 24, 2011 2:17 pm 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
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.


So it does matter if I do not read the 3 bytes mouse packet if i handle a IRQ12?


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Mon Oct 24, 2011 3:26 pm 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
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.


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Mon Oct 24, 2011 8:01 pm 
Offline
Member
Member
User avatar

Joined: Sat Jul 17, 2010 12:45 am
Posts: 487
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.

_________________
Programming is not about using a language to solve a problem, it's about using logic to find a solution !


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 4:27 am 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
at first a used the initialization sequence from SANiK'S code. then I tried this:

Code:

  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(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.


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 5:44 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 17, 2010 12:45 am
Posts: 487
Code:
outportb(0x64, 0xAE);
Send 0xF4 to the command port, this time to enable keyboard. See how that goes.

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 !


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 6:17 am 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
Chandra wrote:
Send 0xF4 to the command port, this time to enable keyboard. See how that goes.


If I send 0xF4 instead of 0xAE it locks everything up.


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 6:46 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 17, 2010 12:45 am
Posts: 487
megatron23 wrote:
Chandra wrote:
Send 0xF4 to the command port, this time to enable keyboard. See how that goes.

If I send 0xF4 instead of 0xAE it locks everything up.
Probably because you didn't read the ACK byte from the keyboard controller.

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 !


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 1:20 pm 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
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=1&t=19873&start=15

Quote:
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.


What emulator did you use? Does it work everytime w/out problems?


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Tue Oct 25, 2011 10:25 pm 
Offline
Member
Member
User avatar

Joined: Sat Jul 17, 2010 12:45 am
Posts: 487
megatron23 wrote:
What emulator did you use? Does it work everytime w/out problems?
It does, at least with QEMU and BOCHS. The reset routine dis-aligns the mouse packets so I dropped it and it worked fine.

_________________
Programming is not about using a language to solve a problem, it's about using logic to find a solution !


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Wed Oct 26, 2011 4:04 am 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
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.


Can you show me your (now modified) mouse and keyboard initalization code. And the ISR of IRQ1.
What version of qemu did you use?


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Wed Oct 26, 2011 6:23 am 
Offline

Joined: Sat Oct 22, 2011 3:03 pm
Posts: 19
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.


Top
 Profile  
 
 Post subject: Re: ps/2 mouse initalization / keyboard interrupt
PostPosted: Wed Oct 26, 2011 7:12 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
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.

Maybe you should check my initalization code. It's written is asm, but you can read what bytes send and read quite easily.
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], SemrushBot [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group