James Harris
2021-04-14 14:15:26 UTC
Are you up for a challenge?
How well do you know what the keyboard controller does? By KBC I mean
the chip which is the middle part of
host <---> KBC <---> keyboard
where the host is the CPU which runs our code and the link from the KBC
to the keyboard could be a PS/2 cable.
Some background on the KBC can be found at
http://aodfaq.wikidot.com/kbc-commands.
KBC operations have always been a bit of a black box to me with /many/
uncertain areas. And from the vagueness of what I've read in supposedly
authoritative sources it has seemed that others are also unsure of the
details.
Perhaps part of the problem is that the 8042 chip which was used as a
KBC is not really a KBC. It is, in fact, a microcontroller. It only
becomes a KBC when it runs a certain piece of firmware. As a result, the
KBC's operation is not documented in a datasheet such as it would be if
it was a dedicated chip.
Thankfully, some brave soul has made an effort to understand the
firmware in the ROM of an early incarnation and posted his findings at
http://www.halicery.com/8042/8042_1503033.TXT
http://www.halicery.com/8042/8042_INTERN.TXT
I've been reading the disassembly to try to find out the answers to some
knotty questions.
Before I post my interpretations (and I wouldn't claim them to be more
than that as reading the 8042 code is far from easy) you might fancy the
challenge of trying your hand at some of the questions. Feel free to
post what you think happens or what you think /should/ happen. Hopefully
us having a discussion about it will give us all a better understanding
of how to handle KBC and keyboard in an OS.
Here are the questions.
What does command 0x20 do?
What does command 0x00 do?
Command 0xAA (self test) returns 0x55 on success but what does it return
if the self test fails?
If the KBC is sent a command which it doesn't recognise what does it do?
As the KBC is not multitasking what happens if the host sends it a
command while it is in the middle of receiving a byte from the keyboard?
If the KBC gets a parity error when receiving a byte from the keyboard
what does it do?
What does the KBC do if it detects a failure when sending a byte to the
keyboard?
We know that when the KBC receives a byte from the keyboard it signals
an interrupt on IRQ1 but is an interrupt generated when the KBC itself
has something to send the host, perhaps in response to a command?
It was trying to find an answer to the last question which led to me
reading more of the disassembly.
How well do you know what the keyboard controller does? By KBC I mean
the chip which is the middle part of
host <---> KBC <---> keyboard
where the host is the CPU which runs our code and the link from the KBC
to the keyboard could be a PS/2 cable.
Some background on the KBC can be found at
http://aodfaq.wikidot.com/kbc-commands.
KBC operations have always been a bit of a black box to me with /many/
uncertain areas. And from the vagueness of what I've read in supposedly
authoritative sources it has seemed that others are also unsure of the
details.
Perhaps part of the problem is that the 8042 chip which was used as a
KBC is not really a KBC. It is, in fact, a microcontroller. It only
becomes a KBC when it runs a certain piece of firmware. As a result, the
KBC's operation is not documented in a datasheet such as it would be if
it was a dedicated chip.
Thankfully, some brave soul has made an effort to understand the
firmware in the ROM of an early incarnation and posted his findings at
http://www.halicery.com/8042/8042_1503033.TXT
http://www.halicery.com/8042/8042_INTERN.TXT
I've been reading the disassembly to try to find out the answers to some
knotty questions.
Before I post my interpretations (and I wouldn't claim them to be more
than that as reading the 8042 code is far from easy) you might fancy the
challenge of trying your hand at some of the questions. Feel free to
post what you think happens or what you think /should/ happen. Hopefully
us having a discussion about it will give us all a better understanding
of how to handle KBC and keyboard in an OS.
Here are the questions.
What does command 0x20 do?
What does command 0x00 do?
Command 0xAA (self test) returns 0x55 on success but what does it return
if the self test fails?
If the KBC is sent a command which it doesn't recognise what does it do?
As the KBC is not multitasking what happens if the host sends it a
command while it is in the middle of receiving a byte from the keyboard?
If the KBC gets a parity error when receiving a byte from the keyboard
what does it do?
What does the KBC do if it detects a failure when sending a byte to the
keyboard?
We know that when the KBC receives a byte from the keyboard it signals
an interrupt on IRQ1 but is an interrupt generated when the KBC itself
has something to send the host, perhaps in response to a command?
It was trying to find an answer to the last question which led to me
reading more of the disassembly.
--
James Harris
James Harris