Page 1 of 1

what's the best way to enable A20?

Posted: Wed Jul 30, 2008 11:05 am
by zhak
Hi, guys! I've read a number of articles about A20 line. It seems to me that they're all a bit out of date. And Ralph Brown's Interrupts... A great manual, but it wasn't updated for a long period of time, as I know. So, my question is:

x86-64 processor based PCs ONLY! What's the best and (maybe) universal way to enable/disable A20?
INT 15h Functions 24xx? Fast Gate A20 enabling via port 92h? Maybe something different? It seems that enabling A20 via keyboard controller is not the best solution. And implementing of 100 different methods in a single bootloader isn't a good idea either (imho). What about Int 15h functions? I'd rather use this method than anything else. But are they surely supported by modern BIOSes? At this time I'm not able to test physical hardware, so all my code runs in Bochs only. Maybe that's why such questions arise...

Re: what's the best way to enable A20?

Posted: Wed Jul 30, 2008 12:34 pm
by bewing
Good luck. AFAIK, A20 has never been standardized in any way -- and the keyboard controller method is the most "generic". I do not think any BIOS function (even when limited to 64 bit machines) is widely available over most BIOSes/platforms. In fact, the most generic thing of all is probably just to assume that A20 is already set during bootup. I suspect that is true for almost all 64 bit machines -- but the only way to find out is to try a bunch of them.

Re: what's the best way to enable A20?

Posted: Wed Jul 30, 2008 1:03 pm
by codemastersnake
Why not use GRUB it does many things automatically!

Re: what's the best way to enable A20?

Posted: Wed Jul 30, 2008 2:23 pm
by zhak
I'm designing an operating system that executes from cd-rom and grub can't help here.
What's more, this question interests me.

Re: what's the best way to enable A20?

Posted: Wed Jul 30, 2008 4:56 pm
by Brynet-Inc
zhak wrote:I'm designing an operating system that executes from cd-rom and grub can't help here.
Yes it can, see here.

@Snake, there is a difference between offering a solution and forcing one... grub isn't the only solution.

Re: what's the best way to enable A20?

Posted: Wed Jul 30, 2008 11:06 pm
by Brendan
Hi,

I do the following:
  • - test if A20 is already enabled
    - try the BIOS function and test if A20 becomes enabled
    - try "fast A20" (using I/O port 0x92) and test if A20 becomes enabled
    - try keyboard controller and test if A20 becomes enabled
    - display a "failed to enable A20" error and abort the boot
GRUB 0.97 does the following:
  • - try the BIOS function and assume it worked if the BIOS says it worked
    - try the keyboard controller and assume it worked
I didn't check any other versions of GRUB.


Cheers,

Brendan

Re: what's the best way to enable A20?

Posted: Thu Jul 31, 2008 1:16 am
by zhak
Yup, Brendan, I thought a bit and decided to do it in similar way. BIOS functions are the first thing to rely on. Then goes fast gate A20, and then kbd controller. Just some 10-20 bytes more, but "Failed to enable A20 address line" error message can be interpreted as "sorry, dude, I tried to do my best!"

Re: what's the best way to enable A20?

Posted: Thu Jul 31, 2008 7:33 am
by jal
Brendan wrote:I do the following:
So is there any reason to use BIOS first? Are there really any systems that do offer the BIOS service, but on which the fast a20 or normal via keyboard don't work? And what is the advantage of the fast a20? Does it ever work while normal via keyboard does not?


JAL

Re: what's the best way to enable A20?

Posted: Thu Jul 31, 2008 8:34 am
by zhak
BIOS uses the appropriate method that will work 100% on the given PC. You don't need to bother with checking if your method gave you expected results. just one int invoke and you're happy :)

Re: what's the best way to enable A20?

Posted: Thu Jul 31, 2008 8:44 am
by Brendan
Hi,
jal wrote:So is there any reason to use BIOS first? Are there really any systems that do offer the BIOS service, but on which the fast a20 or normal via keyboard don't work? And what is the advantage of the fast a20? Does it ever work while normal via keyboard does not?
Here's a good web page that will give you an idea of how seriously messed up A20 is.

Basically there is no sane "non-BIOS" method that works on all computers without causing problems on some computers. The BIOS *should* know the best way to do it for the chipset, and if the BIOS works you avoid all of the insanity... :)


Cheers,

Brendan

Re: what's the best way to enable A20?

Posted: Thu Jul 31, 2008 10:27 am
by Masterkiller
The best way to do things is check them. The newer computer has flash ROM memory, it can be rewritten to version of BIOS that does not support A20 function. Anyway there is a option in some CMOS BIOS how to switch to A20. I suppose this is especially for the BIOS function (FAST should be through 0x92, and the other option - through the keyboard controller). Due to portability if that function fails, you should try 0x92 port. After the writing 1 to enable A20 bit, read the controller again and determine if A20 is enabled, then go to the keyboard controller.
If ignoring portability of the system, unless you have ancient PC, you must try 0x92 port.