James Harris
2021-04-21 14:19:30 UTC
In all the years I've been posting to this newsgroup and all the deep
discussions we used to have about A20 I don't recall us ever discussing
the info below about what AFAICS is another way to enable the A20 gate.
Alright, it's not a method one would choose as a matter of course but it
has interesting implications.
But some people knew about it all along. The page at
https://www.os2museum.com/wp/ibm-pcat-8042-keyboard-controller-commands/
says there that when the KBC is told to test itself with 0xAA, "the self
test command also effectively resets the KBC and puts it into a known
state. That means, among other things, that the A20 address line is
enabled, keyboard interface is disabled, and scan code translation is
enabled."
So the 0xAA selftest command doesn't just test the KBC, as one might be
led to believe from its name, but reinitialises the KBC as well. And as
part of the reinitialisation it enables A20. OK!
It turns out to be correct if I understand
http://halicery.com/8042/8042_1503033.TXT which includes:
; Entry point when Host sends Command AA
0700: 89 FF ORL P1,#$FF
0702: 23 CF MOV A,#$CF
0704: 3A OUTL P2,A
0705: C5 SEL RB0
Note the out of 0xCF (2x1100_1111) to P2 (port 2) setting bit 1 (the A20
gate enable) and others.
If that's what the keyboard controller sets on bootup then 'A20 enabled'
would be the default state.
That makes sense when you think that the BIOS can do a lot of memory
testing and other stuff before it hands us control. To initialise the PC
fully it would naturally need access to all memory addresses.
As at http://aodfaq.wikidot.com/mc-a20-boot we found that at the point
when we get control the state of the A20 gate varies: some machines
start our code with A20 enabled, others with it disabled. But where a
machine starts up with the gate disabled it certainly looks as though
the BIOS would have had to have taken deliberate steps to do so.
Basically, the BIOS must do a load of work in normal mode then, shortly
before it hands control to a boot sector, it would disable A20.
As for whether I would issue 0xAA to the KBC I don't know. I might.
discussions we used to have about A20 I don't recall us ever discussing
the info below about what AFAICS is another way to enable the A20 gate.
Alright, it's not a method one would choose as a matter of course but it
has interesting implications.
But some people knew about it all along. The page at
https://www.os2museum.com/wp/ibm-pcat-8042-keyboard-controller-commands/
says there that when the KBC is told to test itself with 0xAA, "the self
test command also effectively resets the KBC and puts it into a known
state. That means, among other things, that the A20 address line is
enabled, keyboard interface is disabled, and scan code translation is
enabled."
So the 0xAA selftest command doesn't just test the KBC, as one might be
led to believe from its name, but reinitialises the KBC as well. And as
part of the reinitialisation it enables A20. OK!
It turns out to be correct if I understand
http://halicery.com/8042/8042_1503033.TXT which includes:
; Entry point when Host sends Command AA
0700: 89 FF ORL P1,#$FF
0702: 23 CF MOV A,#$CF
0704: 3A OUTL P2,A
0705: C5 SEL RB0
Note the out of 0xCF (2x1100_1111) to P2 (port 2) setting bit 1 (the A20
gate enable) and others.
If that's what the keyboard controller sets on bootup then 'A20 enabled'
would be the default state.
That makes sense when you think that the BIOS can do a lot of memory
testing and other stuff before it hands us control. To initialise the PC
fully it would naturally need access to all memory addresses.
As at http://aodfaq.wikidot.com/mc-a20-boot we found that at the point
when we get control the state of the A20 gate varies: some machines
start our code with A20 enabled, others with it disabled. But where a
machine starts up with the gate disabled it certainly looks as though
the BIOS would have had to have taken deliberate steps to do so.
Basically, the BIOS must do a load of work in normal mode then, shortly
before it hands control to a boot sector, it would disable A20.
As for whether I would issue 0xAA to the KBC I don't know. I might.
--
James Harris
James Harris