Reference articles on history, science, culture and more
Encyclopedia

Memory map

Data structure

In computer science, a memory map is a data structure, usually residing in memory, that indicates how the computer’s memory is laid out. In the boot process of some computers, a memory map may be passed from the firmware to instruct an operating system kernel about memory layout. It contains the information regarding the size of total memory, any reserved regions and may also provide other details specific to the architecture.

The term memory map also has different meanings in other contexts.

  1. It is the fastest and most flexible cache organization that uses an associative memory. The associative memory stores both the address and content of the memory word.
  2. In virtual memory implementations and memory management units, a memory map refers to page tables or hardware registers, which store the mapping between a process's virtual address space and physical memory addresses.
  3. In native debugger programs, a memory map refers to the mapping between loaded executable or library files and memory regions. These memory maps are used to resolve memory addresses (such as function pointers) to actual symbols.

01PC BIOS memory map

BIOS for the IBM Personal Computer and compatibles provides a set of routines that can be used by the operating system or applications to get the memory layout. Some of the available routines are:

BIOS Function: INT 0x15, AX=0xE801:

This BIOS interrupt call is used to get the memory size for 64MB+ configurations. It is supported by AMI BIOSses dated August 23, 1994 or later. The caller sets AX to 0xE801 then executes int 0x15. If some error has happened, the routine returns with CF (Carry Flag) set to 1. If no error, the routine returns with CF clear and the state of registers is described as following:

RegisterValue description
EAXExtended memory between 1M and 16M, in KB. (Maximum value: 0x3C00 = 15360KB).
EBXCount of 64K blocks above 16M.
ECXConfigured memory 1M to 16M, in KB.
EDXCount of configured 64K blocks above 16M.

BIOS Function: INT 0x15, AX=0xE820 - GET SYSTEM MEMORY MAP:

Input:

RegisterValue description
EAX0x0000E820
EBXContinuation value or 0x0 to start at beginning of map.
ECXSize of buffer for result (20 bytes).
EDX0x534D4150 (ASCII for 'SMAP')
ES:DIsegment:offset location of the buffer for result.

SMAP buffer structure:

OffsetSizeValue description
0QWORD (8 bytes)Base address of memory map region referred to by EBX.
8QWORD (8 bytes)Length in bytes.
16DWORD (4 bytes)Type of address range.

How used: The operating system shall allocate an SMAP buffer in memory (20 bytes buffer). Then set registers as specified in "Input" table. On first call, EBX should be set to 0. Next step is to call INT 0x15. If no error, the interrupt call returns with CF clear and the buffer filled with data representing first region of the memory map. EBX is updated by BIOS so that when the OS calls the routine again, The next region is returned in the buffer. BIOS sets EBX to zero if all done.

02UEFI

The UEFI provides a GetMemoryMap() boot service. A bootloader may use it to obtain the memory map.

Watch videos about Memory mapExplainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article Memory map, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.