mtbro wrote:
But in step #3 we disabled both ports, it's expected both bits4,5 will be set to 1(disabled) as we did so in step 3.
Did I miss something here?
Despite the article's name, it actually covers two types of keyboard controllers: PS/2 keyboard controllers and AT keyboard controllers. A PS/2 keyboard controller uses bit 5 to enable or disable the mouse port, and commands 0xA7 and 0xA8 will change bit 5. An AT keyboard controller uses bit 5 to switch between XT and AT keyboard compatibility, and commands 0xA7 and 0xA8 will not change bit 5.
On an AT keyboard controller with an AT (or PS/2) keyboard plugged in, bit 5 will be 0, so this is the step where you'll usually be able to tell whether the keyboard controller is AT or PS/2.
mtbro wrote:
There seems to be more ways how one can disable a port. On ctrl side I can send direct command 0xAD to ctrl, I can send confbyte with proper bit mask set. I can even do so by sending encoder (0x60) command 0xf5. It does confuse me a bit. Are those first two approaches the same?
Yes, the first two approaches both set bit 4 of the keyboard controller's configuration byte. Sending 0xF5 to the keyboard tells the keyboard to stop sending scan codes, but does not affect the keyboard controller.
mtbro wrote:
I thought encoder would be in its "cold" state and it gets enabled again. It doesn't. Does this mean that even doing the 0xf5 command does the same as those two above?
The keyboard may have detected an error while you were plugging it in, which will stop scanning. Also, if the keyboard is old enough, it may automatically switch between XT and AT mode, and hotplug may have caused it to incorrectly switch to XT mode while the keyboard controller is still expecting an AT keyboard.