Initializing the PS/2 controller: yes or no?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DaviUnic
Posts: 9
Joined: Tue Aug 12, 2014 4:49 am

Initializing the PS/2 controller: yes or no?

Post by DaviUnic »

Looking at some existing code and posts here on the forum, it seems that the BIOS or GRUB will initialize the PS/2 controller and keyboard, so there's not much left for you to do in order to use the keyboard, aside from setting up interrupts and writing a keyboard handler.

But the wiki page says the controller could be left in an unreliable state and it's thus better to (re)initialize it yourself.

I'm working on a simple kernel for a college assignment that requires the keyboard to work and boots with GRUB. Should I bother with the controller or not?
nullplan
Member
Member
Posts: 1801
Joined: Wed Aug 30, 2017 8:24 am

Re: Initializing the PS/2 controller: yes or no?

Post by nullplan »

Yes, you should reinitialize the controller. By the time you gain control of the machine, you don't know what the thing has been initialized to do, or if it was initialized at all. You should probably initialize the USB controllers before that, though, due to USB legacy support (without initializing the USB controllers, you can never be sure if you actually are speaking to a PS/2 controller or to the BIOS via SMIs. You can't even tell the difference without asking the chipset itself, and even then, some chipsets won't even let themselves be asked about these things).

For instance, is the controller set up for translation or not? If you have a BIOS computer, chances are it is. With UEFI, who knows? And GRUB does something new each version.

Also, you need to initialize the controller to be able to tell which ports it has and which of these ports have devices attached to them. And which devices they have. Unless you're cool with just assuming the user will have done the right thing.

Typing this on a PS/2 keyboard, by the way, because I have discovered that's just how the keyboard of this laptop is wired up. So that's a thing as well: Statically attached peripherals.
Carpe diem!
DaviUnic
Posts: 9
Joined: Tue Aug 12, 2014 4:49 am

Re: Initializing the PS/2 controller: yes or no?

Post by DaviUnic »

Well, I got it working. Thanks. :)
Post Reply