what's the best way to enable A20?
what's the best way to enable A20?
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...
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?
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.
- codemastersnake
- Member

- Posts: 148
- Joined: Sun Nov 07, 2004 12:00 am
- Contact:
Re: what's the best way to enable A20?
Why not use GRUB it does many things automatically!
Re: what's the best way to enable A20?
I'm designing an operating system that executes from cd-rom and grub can't help here.
What's more, this question interests me.
What's more, this question interests me.
- Brynet-Inc
- Member

- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: what's the best way to enable A20?
Yes it can, see here.zhak wrote:I'm designing an operating system that executes from cd-rom and grub can't help 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?
Hi,
I do the following:
Cheers,
Brendan
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
- - try the BIOS function and assume it worked if the BIOS says it worked
- try the keyboard controller and assume it worked
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: what's the best way to enable A20?
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?
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?Brendan wrote:I do the following:
JAL
Re: what's the best way to enable A20?
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?
Hi,
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
Here's a good web page that will give you an idea of how seriously messed up A20 is.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?
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- Masterkiller
- Member

- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Re: what's the best way to enable A20?
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.
If ignoring portability of the system, unless you have ancient PC, you must try 0x92 port.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
Current state: real-mode kernel-FS reader...

