DOS Memory Management - The 80286 and The High Memory Area

The 80286 and The High Memory Area

When the IBM PC/AT was introduced, the segmented memory architecture of the Intel family processors had the byproduct of allowing slightly more than 1 megabyte (MiB) of memory to be addressed in the "real" mode. Since the 80286 had more than 20 address lines, certain combinations of segment and offset could point into memory above the 0x0100000 (220) location. The 80286 could address up to 16 MiB of system memory, thus removing the behavior of memory addresses "wrapping around". Since the required address line now existed, the combination F800:8000 would no longer point to the physical address 0x0000000 but the correct address 0x00100000.

As a result some DOS programs would no longer work. To maintain compatibility with the PC and XT behavior, the AT included an A20 line gate (Gate-A20) that made memory addresses on the AT wrap around to low memory as they would have on an 8088 processor. This gate could be controlled, initially through the keyboard controller, to allow running programs which were designed for this to access an additional 64 KiB - 16 bytes of memory in real mode. At boot time, the BIOS first enables A20 when counting and testing all of the system's memory, and disables it before transferring control to the operating system. Enabling the A20 line is one of the first steps a protected mode x86 operating system does in the bootup process, often before control has been passed onto the kernel from the bootstrap (in the case of Linux, for example).

The high memory area (HMA) is the RAM area consisting of the first 64 KiB, minus 16 bytes, of the extended memory on an IBM PC/AT or compatible microcomputer.

Originally, the logic gate was a gate connected to the Intel 8042 keyboard controller. Controlling it was a relatively slow process. Other methods have since been added to allow for more efficient multitasking of programs which require this wrap-around with programs that access all of the system's memory. There was at first a variety of methods, but eventually the industry settled on the PS/2 method of using a bit in port 92h to control the A20 line.

Disconnecting A20 would not wrap all memory accesses above 1 MiB, just those in the 1 MiB-2 MiB, 3 MiB-4 MiB, 5 MiB-6 MiB, etc. ranges. Real mode software only cared about the area slightly above 1 MiB, so Gate-A20 was enough.

Virtual 8086 mode, introduced with the Intel 80386, allows the A20 wrap-around to be simulated by using the virtual memory facilities of the processor: physical memory may be mapped to multiple virtual addresses thus allowing the memory mapped at first mebibyte of virtual memory may be mapped again in the second mebibyte of virtual memory. The operating system may intercept changes to Gate A20 and make corresponding changes to the virtual memory address space, which also makes irrelevant the efficiency of Gate-A20 toggling.

The first user of the HMA among Microsoft products was Windows/286 2.1 in 1988, which introduced the HIMEM.SYS device driver. Starting with versions 5.0 of DR-DOS (1990) and of MS-DOS (1991), parts of the operating system could be loaded into HMA as well, freeing up to 46 KB of conventional memory. Other components, such as device drivers and TSRs, could be loaded into the upper memory area (UMA).

Read more about this topic:  DOS Memory Management

Famous quotes containing the words high, memory and/or area:

    The most useful man in the most useful world, so long as only commodity was served, would remain unsatisfied. But, as fast as he sees beauty, life acquires a very high value.
    Ralph Waldo Emerson (1803–1882)

    Remember thee?
    Ay, thou poor ghost, whiles memory holds a seat
    In this distracted globe. Remember thee?
    Yea, from the table of my memory
    I’ll wipe away all trivial fond records,
    All saws of books, all forms, all pressures past
    That youth and observation copied there,
    And thy commandment all alone shall live
    Within the book and volume of my brain,
    William Shakespeare (1564–1616)

    Prestige is the shadow of money and power. Where these are, there it is. Like the national market for soap or automobiles and the enlarged arena of federal power, the national cash-in area for prestige has grown, slowly being consolidated into a truly national system.
    C. Wright Mills (1916–1962)