DOS memory management#The 80286 and the high memory area

The A20 gate is an electronic circuit in a PC, which unlocks or locks the 21st address line for a 80286 compatible CPU.

A20 means " address line 20". This is the 21st address line, as counted from A0. The English term gate is best translated as " gate" or " gate". This is also called the " A20 line" or " A20 line ".

If the gate is "set", then the output from the CPU A20 line to the address of the system (and thus ultimately to the memory) passed, the " deleted " gate, so that from the CPU to the A20 line is output signal is suppressed and always a logic 0 is applied to the system.

A20 by the gate may be a 286 ( and greater ) with processor 20 over address lines 8086 to emulate an older, only 20 address lines (A0 to A19).

Architecture of 8086

The Intel 8086 CPU addresses memory after a segmentation model. Here is the available main memory in 64 KiB units ( so-called segments, in certain contexts also called Paragraphs ) divided. With each of these segments can be addressed 64 KiB memory by an offset is added. Both the segment and the offset is 16- bit values. The 20 -bit address of the addressed memory area is then calculated according to the formula

Resulting in an address space of a little more than 1 MIB.

The 8086 had a physical 20-bit address bus, which is exactly 1 MiB memory can be addressed with the addresses 016 to FFFFF16. If one now based on a segment value of FFFF16 sets, and an offset of 016 to F16, the address range from can

FFFF16 · 1016 016 = FFFF016

To

FFFF16 · 1016 F16 = FFFFF16

Be achieved. If the offset was larger but now, found a carry rather than the 21 bit. Overall, based on as accurate 65520 bytes more address than the 20 address lines can address. The 8086 he ignores this transfer, so that an overflow on the first 65520 bytes of memory takes place. Since overlap the segments, all addresses can be precisely with 4096 combinations of segment and offset represent. The address 1234516 can be represented, for example, with segment and offset 123416 516, but also with segment and offset 34516 120016. When the limit of 1 MiB exceeded, other combinations that access the same memory cell yield. The resulting therefrom ambiguities complicate the use of memory may significantly.

Architecture of 80286

With the introduction of the protection mode ( protected mode ), the address bus of the 80286 CPU was over their predecessors increased to 24 bits. This makes the CPU more than 16 MiB could address instead of just 1 MiB. However, now was the address calculation logic of the CPU no longer simply ignore the unearned as the 21st address line. Consistently gives the bill FFFF16 FFFF16 · 1016 on a 80286 CPU no longer the address FFEF16 but 10FFEF16.

MS- DOS 1:25 and some applications, however, went assume that the transfer to the 21 address line was cut off and otherwise functioned properly. This resulted in a problem that the new PC / AT would not be sufficiently compatible with the PC / XT. Simply but you could disconnect the A20 line either, otherwise you would have been limited further to a maximum of 1 MiB memory, and a major selling point for the PC / AT would have been invalid. As a solution, the A20 gate was invented.

The A20 gate operation

IBM built to comply with the backward compatibility a gate in the A20 address line. In order to save chip, the gate on the already existing keyboard controller was controlled, which it presented an untapped bit of the control register is available.

Problems with the A20- Gate

The first problem is that the keyboard controller is a slow and complicated for PC ratios detour. The second, much more serious problem, however, that the status of the gate was nowhere queried. Only later a way to query through a BIOS function by IBM was installed. When the first external processor caches appeared to more problems began: the cache had to be able to distinguish between the two states to provide non-obsolete data from the wrong memory area. Another problem arose about the exchange between protected mode and real mode. Since there was no provision in the 80286, to switch from protected mode back to real mode, this functionality in the PC / AT was used but, IBM used a more interconnection that made ​​sure that the CPU receives a reset signal, and thus falls back to real mode when it enters the shutdown mode where applicable ( Triple Fault). It could be switched back by targeted Provoke a Triple Fault but in the real mode. Is there, however, the A20 line is masked, the CPU finds its first command to run instead of at the address FFFFF016 to EFFFF016 after the reset - a storage area, who was rarely equipped with RAM or ROM. With the use of the HMA by MS- DOS (version 4 and higher ), the state of the mask had to be changed frequently, which required an elaborate control of the state of the gate.

From the i486 a pin A20M was made available to the processor. About this now, the AT keyboard controller (or be compatible, but faster equivalent) report the need for a Masking directly to the CPU, which then performs the masking itself. The state of the pins is requested and implemented only in real mode of the CPU. In protected mode and virtual - 8086 mode is no masking. The emulated masking of the A20 in the Virtual - 8086 mode can be solved via paging.

Hack options on systems with A20- masking

Xbox

The A20 gate can be to bypass the Secret -ROMs and exploit the applications running in the flash memory. For this, the address line A20 # of the CPU is connected to GND. The Xbox will start from a different address FFFFFFF016 Secret -ROM, but from the address FFEFFFF016 that is in Flash. There, for example, a program may be stored, which reads the Secret -ROM via the I ² C bus.

Future of the A20 gate

All current ( Intel-compatible ) computers have an A20 gate, and also for the near future is not planned abolition in order not to restrict the compatibility. In fact, it is rarely used. To be exact, it is used in any computer to start because it is switched from the operating system. It would be easier, however, to disable the circular memory from the beginning, only DOS would then no longer run ( correctly ) on current computers, which would prevent the use of many startup disks for example. For the first time in 2009 renounced the Nehalem - based Xeon processors on the A20 gate.

21253
de