what's the best way to enable A20?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

what's the best way to enable A20?

Post 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...
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

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

Post 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.
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

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

Post by codemastersnake »

Why not use GRUB it does many things automatically!
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

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

Post 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.
User avatar
Brynet-Inc
Member
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?

Post 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.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

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

Post 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
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.
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

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

Post 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!"
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

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

Post 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
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

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

Post 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 :)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

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

Post 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
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.
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

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

Post 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.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
Post Reply