OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 11:17 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: PS/2 scan code set 2 issues
PostPosted: Sun Dec 25, 2022 2:29 pm 
Offline

Joined: Sun Dec 25, 2022 1:16 pm
Posts: 5
Im having an issue while trying to use scan code set 2 for my keyboard PS/2 driver. When i get an IRQ saying a key has been released, i get another IRQ after it saying it is pressed again even if it wasn't, so a key is always registered down after it has been pressed only once. This happens sometimes on real hardware, always on QEMU and never in Bochs. Is this an issue with my driver, or with PS/2 keyboard using scan code set 2?


Top
 Profile  
 
 Post subject: Re: PS/2 scan code set 2 issues
PostPosted: Tue Jan 03, 2023 9:02 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
That sounds like an issue with your driver. Have you tried logging the scan code bytes as you receive them? If you're receiving any extra scan code bytes, they'll appear in your log.


Top
 Profile  
 
 Post subject: Re: PS/2 scan code set 2 issues
PostPosted: Wed Jan 04, 2023 4:28 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
Hi,

If it wasn't for this quote...
ThisIsAnEpicUsername wrote:
This happens sometimes on real hardware, always on QEMU and never in Bochs. Is this an issue with my driver, or with PS/2 keyboard using scan code set 2?
...my question is that you do realize that a break code for set 2 is 0xF0 and then the key that is being released?
For example, when you press 'S', you will get a single byte from the keyboard: 0x1B
When you release the 'S', you will get two bytes from the keyboard: 0xF0 and 0x1B
Are you mistakenly thinking that the 0x1B is a new 'make' code?

However, since you did say the above quote, I agree with Octocontrabass, I think it to be within your driver, and a log is a good suggestion.

Ben
- https://www.fysnet.net/osdesign_book_series.htm


Top
 Profile  
 
 Post subject: Re: PS/2 scan code set 2 issues
PostPosted: Sat Jan 07, 2023 3:34 am 
Offline

Joined: Sun Dec 25, 2022 1:16 pm
Posts: 5
Hello, thanks for the replies. I fixed the issue - I didn’t realise 2 interrupts were send, one for 0xF0 and another for the key byte. Instead, once I received the first interrupt I read both bytes, so when I received the second interrupt I got what appeared to be the make code and registered a key press. Thanks for the help, anyways.


Top
 Profile  
 
 Post subject: Re: PS/2 scan code set 2 issues
PostPosted: Sat Jan 07, 2023 10:38 am 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
Yes, as you found out, the keyboard will fire an interrupt when it has a byte ready to be read from the output buffer. If the current make/break code is two or more chars, it will interrupt once for each char.

It is up to the hardware (in this case, the emulator) on when to update the output buffer with the next char.

Since you were able to read both bytes on one interrupt notification, QEMU must update the output buffer with the next byte after a read from the port. Hence "always in QEMU". However, Bochs may only update the output buffer on an interrupt notification, hence the "never in Bochs".

The key here (no pun intended) is to remember that you must only read from the keyboard output buffer once per interrupt. Any additional read is considered undefined.

Also, please note that scan set 2 does have a few make/break codes that are multi-byte codes. Does your driver allow for multi-byte codes?

Ben


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 8 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