Page 1 of 1
Simple question about A20 gate
Posted: Sun Oct 23, 2005 2:56 pm
by Peter
Hi,
I'm back in OS development and also back with stupid questions.
I got an example about 'how to open the A20 gate'. I got the useful tool helppc21 but I stuck with a little thing.
Am I right that you need to put 0xD0 in the input registers before you can read the status of the registers?
example:
call a20wait
mov al, 0xD0 ;; Why does I need to do this??
out 0x64, al
call a20wait2
in al, 0x60 ;; Read register status.
...
Thank you,
Peter.
Re:Simple question about A20 gate
Posted: Mon Oct 24, 2005 4:46 am
by JoeKayzA
According to
this tutorial, the command 0xd0 tells the controller to load the status word into an io register, which we can then access through port 0x60. Just as you have to give it the command 0xd1 before you write the status word back (after setting the a20 enable bit).
That's because the port 0x60 is used by the keyboard controller for other things too, remember that you also read the scancodes from there.
cheers Joe
Re:Simple question about A20 gate
Posted: Mon Oct 24, 2005 4:57 am
by Peter
Thanks for your reply it's all clear know, I feel a little bit stupid...
Thank you.
Re:Simple question about A20 gate
Posted: Mon Oct 24, 2005 6:44 am
by Xardfir
No need to feel stupid! It's A20 that's wierd. I remember back in the mid 80's when Intel released it's Above board 386 to upgrade your 286 with 32 bit power, it had a completely different way of switching the A20 gate. As a result real and protected mode code had to detect the machine and use different code for each. If I recall correctly the HIMEM driver for DOS (which uses protected mode) had no less than 14 different ways of enabling the A20 gate!
Fortunately with the Pentium onwards, the processor has a FAST A20 option. System Control Port A, bit 2
mov al, 0x92
or al, 2
out 0x92, al
This bypasses the keyboard port altogether.
A quick google search pulled up:
http://www.win.tue.nl/~aeb/linux/kbd/A20.html
This has lots of gory details about the A20 and some more info about System Port A.
Hope this helps.
Note to anyone else reading this: I've added it to the OSFAQ