# How does FreeBSD work with keyboard?



## BachiloDmitry (Mar 25, 2016)

So, here is the story: I have a laptop Acer Aspire 5100, which has a dead southbridge. In any operating system it predictibly results in non-working audio, usb, keyboard and touchpad. I tried Windows XP, Windows 7, Linux and FreeDOS. They all work ok on it except this minor stuff. I also obvioulsy can't access BIOS since keyboard is dead. And if I install FreeBSD on it ofcouse I cant skip that autoboot delay with the boot menu. But if system boots - the keyboards suddenly works like a charm, and that makes my laptop totally usable and fine (for example to set up ethrenet switches using cardbus serial adapter). That's a miracle! Or is it?

So the question is: what makes FreeBSD so different? How does it work with the keyboard and why no other OS uses this method then?


----------



## SirDice (Mar 25, 2016)

The "Southbridge"/"Northbridge" has been replaced by the PCH since 2008.


----------



## BachiloDmitry (Mar 25, 2016)

SirDice said:


> The "Southbridge"/"Northbridge" has been replaced by the PCH since 2008.


This laptop is from 2005 and has ATI IXP 4XX chip which is a southbridge. I even made the video about this situation and it has an image of it's motherboard.




Anyway, this does not explain how the keyboard works only in FreeBSD.


----------



## aragats (Mar 28, 2016)

That's really interesting!
Maybe other OSes rely on the BIOS ISA PNP functionality (which doesn't work in your case), while FreeBSD is able to detect the keyboard on LPC/ISA independently.
You probably have to look into atkbd(4) driver.
E.g. this site has source codes, call graphs and cross-references:
http://www.leidinger.net/FreeBSD/dox/dev_atkbdc/html/dd/dd3/atkbd_8c.html


----------



## BachiloDmitry (Mar 29, 2016)

Thanks for the link, aragats! As I could see, FreeBSD can poll keyboard by itself, not relying on INT9 (IRQ1). Well, I never doubted that, I just also never doubted that all other OSes can too. At least for last 20 years. Fortunately this was easy to check. If we imagine for a second an unbelievable possibility that every modern operating system including modern versions of Windows, Linux and DOS (i.e. FreeDOS) are so incredibly lame that they still only rely on prehistoric IRQ1 for the mattrer of PS/2 keyboard, than we can write and assembley code for example for DOS to manualy (using TSR) scan 60h address, check for the keyboard status and generate artificial interrupt request. On uncorrupted machine this will result in all input to double. Like if you type "A" in C:\ dos prompt, you will see C:\AA typed in. My friend made a simple .com file on dos assembler that does exactly that and we checked this out. And guess what. The keyboard now works in FreeDOS. Who could possibly imagine that in the whole OS world only FreeBSD allows the possibility for this ancient mechanizm may not be working on some hardware. That's just sad. Anyway, problem solved, southbridge is responsible for keyboard interrupts, but the SuperIO and keyboard buffer are still alive, and FreeBSD is the only OS that checks this exactly with the code you gave me a link to.


----------

