A20 Line

From OSDev.wiki
Revision as of 21:09, 23 December 2006 by Tyler (talk | contribs) (Expanded intro and added another method)
Jump to navigation Jump to search
This page is a stub.
You can help the wiki by accurately adding more contents to it.

The A20 Address Line is the physical representation of the 20th bit of any memory access. When the IBM-AT (Intel 286) was introduced, it was able to access up to sixteen megabytes of memory (instead of the 1 MByte of the IBM-XT). But to remain compatible with the IBM-XT, a quirk in the XT architecture (memory wraparound) had to be duplicated in the AT. To achieve this, the 20th line on the address bus (A20) was disabled by default.

The wraparound was caused by the fact XT computers could only access 1 megabyte of memory but because of there segmented memory access method they could effectively address upto 1 megabyte and 63 and a bit kilobytes. Not looking towards the future as always, intel decided to wrap around address above the 1 megabyte mark to the begining of memory. Therefore in order to support XT era programs on there new architectures, this wraparound was set by default on later processors.

For an perating system developer (or bootloader developer) this means the A20 line has to be enabled so that all memory can be accessed. This started off as a simple hack but as simpler methods were added to do it, it became harder to program code that would definetly enable it.

#A20 Pin

On most modern systems the A20 pin allows automatic enabling of the A20 line. Unfortunately this was not implemented until recent processors so it is neccesary to check whether the A20 line is enabled and try alternate methods if it is not.

Keybaord Controller

The traditional method for A20 line enabling is to directly probe the keyboard controller. The reaon for this is that intels 8042 keyboard controller had a spare pin which they decided to route the A20 line through. This seems fullish now given there unrelatedness but at the time coputers weren't quite so standardised. Keyboard controllers are usually derivatives of the 8042 chip. By programming that chip accurately, you can either enable or disable bit #20 on the address bus.

When your PC boots, the A20 gate is always disabled, but some BIOSes do enable it for you, as do some high-memory managers (HIMEM.SYS) or bootloaders (GRUB).

See Also

External links