Experiments with the 8042 keyboard controller
-
- Member
- Posts: 5575
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Experiments with the 8042 keyboard controller
Whoops, my mistake. What the wiki calls the "configuration byte" is called the "command byte" in some really old IBM manuals. You can probably guess I was looking at when I wrote that post...
-
- Member
- Posts: 106
- Joined: Sat Feb 08, 2020 11:11 am
- Libera.chat IRC: sunnysideup
Re: Experiments with the 8042 keyboard controller
Alright! Makes sense!
There's another thing that came across my mind, the PS2 controller seems to have an output port too. Is this the same as the keyboard port that we were talking about? It doesn't seem so because there seem to exist ports called the first PS/2 port and the second PS/2 port
There's another thing that came across my mind, the PS2 controller seems to have an output port too. Is this the same as the keyboard port that we were talking about? It doesn't seem so because there seem to exist ports called the first PS/2 port and the second PS/2 port
This doesn't seem to be any of the registers I know (command/status). Why is this also called a **port**?PS/2 Controller Output Port
Commands 0xD0 and 0xD1 let you read and write the PS/2 Controller Output Port.
-
- Member
- Posts: 106
- Joined: Sat Feb 08, 2020 11:11 am
- Libera.chat IRC: sunnysideup
Re: Experiments with the 8042 keyboard controller
Also I have a question about translation
Okay, so current keyboards (interface compatible with the AT) use set 2 by default right? Why does it say that the keyboard controller enables translation by default??
Or is this too ancient to even talk about now?
Source: [wiki]https://wiki.osdev.org/%228042%22_PS/2_Controller?[/wiki]Translation
The original IBM-PC keyboards (using the old XT interface) used "scan code set 1". The new AT keyboards generated different scan codes, or "scan code set 2". This change would have created compatibility problems for software that was expecting different scan codes from the keyboard. To avoid the compatibility problem, the keyboard controller supports a translation mode. If translation is enabled the controller will translate "scan code set 2" into "scan code set 1".
Whenever this translation is enabled (and by default, it is) there is no way to reverse it in software. For example, if you receive the byte 0xB5 from the controller, then you can't know if the original data (sent to the controller by the device) was the byte 0xB5; or if it was the two bytes 0xF0, 0x33; or if it was the two bytes 0xF0, 0xB3.
Okay, so current keyboards (interface compatible with the AT) use set 2 by default right? Why does it say that the keyboard controller enables translation by default??
Or is this too ancient to even talk about now?
-
- Member
- Posts: 5575
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Experiments with the 8042 keyboard controller
The output port is used to control the signals being output by 8 of the 8042 microcontroller's pins. The name simply comes from the fact that those 8 pins combined are referred to as a "port" in the 8042 datasheet, and they're all configured as outputs instead of inputs.sunnysideup wrote:There's another thing that came across my mind, the PS2 controller seems to have an output port too. Is this the same as the keyboard port that we were talking about? It doesn't seem so because there seem to exist ports called the first PS/2 port and the second PS/2 port
Of course, in computers that don't use a discrete 8042 as the keyboard controller, the pins may no longer exist, but the functionality is still there.
For the same reason port 0x60 and port 0x64 are called ports: Intel liked the name. (Well, that and "port" is a useful metaphor for how they're meant to be used.) It's just an inconvenient coincidence that the physical connectors you plug keyboards into are also called "ports".sunnysideup wrote:Why is this also called a **port**?
The translation is needed to remain backwards-compatible with PC and XT software, which would access the keyboard controller and expect to receive set 1 scan codes instead of the keyboard's set 2 scan codes.sunnysideup wrote:Okay, so current keyboards (interface compatible with the AT) use set 2 by default right? Why does it say that the keyboard controller enables translation by default??
As for why IBM decided translating set 2 into set 1 inside the keyboard controller was the best solution instead of making the keyboard produce set 1 scan codes, I have no idea. I suspect it was done to make the AT keyboard compatible with a serial terminal or something silly like that. (IBM really wanted people to use mainframes with dumb terminals.)
Personally, I think it's useful to learn how the hardware evolved while maintaining backwards compatibility. It helps contextualize the odd design choices. (Plus it's fun to write software for old hardware.)sunnysideup wrote:Or is this too ancient to even talk about now?