Memory map


In computer science, a memory map is a structure of data that indicates how memory is laid out. The term "memory map" can have different meanings in different contexts.
The PC BIOS provides a set of routines that can be used by operating system to get memory layout. Some of the available routines are:
BIOS Function: INT 0x15, AX=0xE801 ':
This BIOS interrupt call is used by the running OS to get the memory size for 64MB+ configurations. It is supported by AMI BIOSses dated August 23, 1994 or later. The operating system just sets AX to 0xE801 then calls int 0x15. If some error has happened, the routine returns with CF 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..
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.
EDX0x534D4150
ES:DIsegment:offset location of the buffer for result.

SMAP buffer structure:
OffsetSizeValue Description
0QWORD Base address of memory map region referred to by EBX.
8QWORD Length in bytes.
16DWORD Type of address range.

How used: The operating system shall allocate an SMAP buffer in memory. 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.