PS2 mouse and keyboard : bad cohabitation
PS2 mouse and keyboard : bad cohabitation
Hello, i have made a driver for the ps2 mouse and it's works good but when i test with the keyboard, one time, the keyboard doesnt works and the mouse yes, but one other time, the keyboard works and the mouse not. I thinks the problems is the ps2 controllers, what i need to have a good cohabitation ?
- Combuster
- Member

- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: PS2 mouse and keyboard : bad cohabitation
You can't separate the PS/2 mouse and keyboard code into two drivers. They share the same controller and control ports and need a common part to prevent them from influencing each other.
Re: PS2 mouse and keyboard : bad cohabitation
How works this common part to prevent them from influencing each other ? because the ps2 mouse and the keyboard use different IRQ,
Re: PS2 mouse and keyboard : bad cohabitation
Hi,
Of course once you've designed it as 3 separate drivers, you don't necessarily need to implement it as 3 separate drivers. The important thing is having some sort of abstraction between the keyboard/mouse stuff and the controller stuff...
Cheers,
Brendan
True, but you can separate it into 3 drivers: one for the PS/2 controller, and one for each device connected to the PS/2 controller. It's not even that hard - all you do is define some sort of interface that allows the keyboard driver and mouse driver to talk to the PS/2 controller's driver.Combuster wrote:You can't separate the PS/2 mouse and keyboard code into two drivers. They share the same controller and control ports and need a common part to prevent them from influencing each other.
Of course once you've designed it as 3 separate drivers, you don't necessarily need to implement it as 3 separate drivers. The important thing is having some sort of abstraction between the keyboard/mouse stuff and the controller stuff...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: PS2 mouse and keyboard : bad cohabitation
The common part is that the KBC will queue data and mix the mouse and keyboard data. So if your Keyboard driver is not aware of the mouse driver, it will throw away mouse data and likewise for the mouse driver.
You read and acknowledge data from the controller using the same ports. Have a look at the attached files. You will see that eventhough two IRQ's are used, reading the data is done in the same way and a decission is made at the time of reading data as to if it is for the Keyboard or the mouse.
You read and acknowledge data from the controller using the same ports. Have a look at the attached files. You will see that eventhough two IRQ's are used, reading the data is done in the same way and a decission is made at the time of reading data as to if it is for the Keyboard or the mouse.
- Attachments
-
[The extension pas has been deactivated and can no longer be displayed.]
-
[The extension pas has been deactivated and can no longer be displayed.]
Re: PS2 mouse and keyboard : bad cohabitation
You make the classic mistake of reading more than one byte when receiving an IRQ. You should not do this: read one byte at each IRQ, and you'll be fine.mybura wrote:You read and acknowledge data from the controller using the same ports. Have a look at the attached files. You will see that eventhough two IRQ's are used, reading the data is done in the same way and a decission is made at the time of reading data as to if it is for the Keyboard or the mouse.
JAL
Re: PS2 mouse and keyboard : bad cohabitation
Might explain why on some hardware it works and other it doesn't. I've found that on some ps2 emulated USB hardware the driver would hang on data from the mouse and keyboard at the same time.
Re: PS2 mouse and keyboard : bad cohabitation
Could very well be. The hardware expects one byte to be read, then the IRQ to be acknowledged. There's no telling how it reacts when you read a sequence of bytes, then acknowledge a single IRQ. Could be that the other IRQs are still pending, and when you start reading, there's no data (which is not surprising, since you read it all).mybura wrote:Might explain why on some hardware it works and other it doesn't. I've found that on some ps2 emulated USB hardware the driver would hang on data from the mouse and keyboard at the same time.
JAL