Document directory
- Address range descriptor Structure
- Assumptions and limitations
- Example address map
- Sample operating system usage
This article is reproduced, Original address: http://www.uruk.org/orig-grub/mem64mb.html
Int 15 h, Ax = e820h-query system address map
Real mode only.
This call returns a memory map of all the installed ram, and of physical
Memory ranges reserved by the BIOS. The address map is returned by making
Successive callto this API, each returning one "run" of physical address
Information. Each run has a type which dictates how this run of physical
Address range shoshould be treated by the operating system.
If the information returned from int 15 h, Ax = e820h in some way differs from
Int 15 h, Ax = e801h or
Int 15 h Ah = 88 h,
Then the information returned from e820h
Supersedes what is returned from these older interfaces.
This allows the BIOS
To return whatever information it wishes to for compatibility reasons.
Input:
EAXFunction CodeE820h
EBXContinuationContains the "continuation value" to get the
next run of physical memory. This is the
value returned by a previous call to this
routine. If this is the first call, EBX
must contain zero.
ES:DIBuffer PointerPointer to an Address Range Descriptor
structure which the BIOS is to fill in.
ECXBuffer SizeThe length in bytes of the structure passed
to the BIOS. The BIOS will fill in at most
ECX bytes of the structure or however much
of the structure the BIOS implements. The
minimum size which must be supported by both
the BIOS and the caller is 20 bytes. Future
implementations may extend this structure.
EDXSignature'SMAP' - Used by the BIOS to verify the
caller is requesting the system map
information to be returned in ES:DI.
Output:
CFCarry FlagNon-Carry - indicates no error
EAXSignature'SMAP' - Signature to verify correct BIOS
revision.
ES:DIBuffer PointerReturned Address Range Descriptor pointer.
Same value as on input.
ECXBuffer SizeNumber of bytes returned by the BIOS in the
address range descriptor. The minimum size
structure returned by the BIOS is 20 bytes.
EBXContinuationContains the continuation value to get the
next address descriptor. The actual
significance of the continuation value is up
to the discretion of the BIOS. The caller
must pass the continuation value unchanged
as input to the next iteration of the E820
call in order to get the next Address Range
Descriptor. A return value of zero means that
this is the last descriptor. Note that the
BIOS indicate that the last valid descriptor
has been returned by either returning a zero
as the continuation value, or by returning
carry.
Address range descriptor Structure
Offset in BytesNameDescription
0 BaseAddrLowLow 32 Bits of Base Address
4 BaseAddrHighHigh 32 Bits of Base Address
8 LengthLowLow 32 Bits of Length in Bytes
12 LengthHighHigh 32 Bits of Length in Bytes
16 TypeAddress type of this range.
TheBaseaddrlowAndBaseaddrhighTogether are the 64 bit
BaseaddressOf this range.Baseaddress
Is the physical address of
Start of the range being specified.
TheLengthlowAndLengthhighTogether are the 64 bit
LengthOf this range.
TheLengthIs the physical contiguous length in bytes of a range being
Specified.
TheTypeField describes the usage of the described address range
Defined in the table below.
ValuePneumonicDescription
1AddressRangeMemoryThis run is available RAM usable by the
operating system.
2AddressRangeReservedThis run of addresses is in use or reserved
by the system, and must not be used by the
operating system.
OtherUndefinedUndefined - Reserved for future use. Any
range of this type must be treated by the
OS as if the type returned was
AddressRangeReserved.
The BIOS can use the addressrangereserved address range type to block out
Various addresses as "not suitable" for use by a programmable device.
Some of the reasons a BIOS wocould do this are:
- The address range contains system ROM.
- The address range contains RAM in use by the Rom.
- The address range is in use by a memory mapped system device.
- The address range is for whatever reason are unsuitable for
Standard Device to use as a device memory space.
Assumptions and limitations
- 1.The BIOS will return address ranges describing base board
Memory and ISA or PCI memory that is contiguous with that baseboard memory.
- 2.The BIOS will not return a range description for the memory
Mapping of PCI devices, ISA option Rom's, and ISA plug & play cards. This
Is because the OS has mechanic ISMs available to detect them.
- 3.The BIOS will return chipset defined address holes that are not
Being used by devices as reserved.
- 4.Address ranges defined for base board memory mapped I/O devices
(For example apics) will be returned as reserved.
- 5.All occurrences of the system BIOS will be mapped as reserved.
This includes des the area below 1 MB, at 16 MB (if present) and
End of the address space (4 gig ).
- 6.Standard PC address ranges will not be reported. example Video
Memory at a0000 to bffff physical will not be described by this
Function. The range from e0000 to effff is base board specific
And will be reported as suits the bas board.
- 7.All of lower memory is reported as normal memory. It IS OS's
Responsibility to handle standard Ram locations reserved
Specific uses, for example: the interrupt vector table (0: 0) and
The BIOS data area (40: 0 ).
Example address map
This sample address map describes a machine which has 128 mb ram, 640 K
Of base memory and 127 MB extended. The base memory has 639 K
Available for the user and 1 K for an extended BIOS data area. There
Is a 4 MB linear frame buffer (LFb) based at 12 Mb. The memory hole
Created by the chipset is from 8 m to 16 M. There are memory mapped
APIC devices in the system. The IO unit is at fec00000 and the local
Unit is at fee00000. the system BIOS is remapped to 4G-64 K.
Note that the 639 K endpoint of the first memory range is also the base
Memory size reported in the BIOS data segment at 40: 13.
Key to types: "arm" is addressrangememory, "arr" is addressrangereserved.
Base (Hex)LengthTypeDescription
0000 0000639KARMAvailable Base memory - typically the same
value as is returned via the INT 12 function.
0009 FC001KARRMemory reserved for use by the BIOS(s).
This area typically includes the Extended
BIOS data area.
000F 000064KARRSystem BIOS
0010 00007MARMExtended memory, this is not limited to
the 64 MB address range.
0080 00008MARRChipset memory hole required to support the
LFB mapping at 12 MB.
0100 0000120MARMBase board RAM relocated above a chipset
memory hole.
FEC0 00004KARRIO APIC memory mapped I/O at FEC00000. Note
the range of addresses required for an APIC
device may vary from base OEM to OEM.
FEE0 00004KARRLocal APIC memory mapped I/O at FEE00000.
FFFF 000064KARRRemapped System BIOS at end of address space.
Sample operating system usage
The following code segment is intended to describe the algorithm needed when
Calling the query system address map function. It is an implementation
Example and uses non standard mechanisms.
E820Present = FALSE;
Regs.ebx = 0;
do {
Regs.eax = 0xE820;
Regs.es = SEGMENT (&Descriptor);
Regs.di = OFFSET (&Descriptor);
Regs.ecx = sizeof (Descriptor);
Regs.edx = 'SMAP';
_int( 0x15, Regs );
if ((Regs.eflags & EFLAG_CARRY) || Regs.eax != 'SMAP') {
break;
}
if (Regs.ecx < 20 || Regs.ecx > sizeof (Descriptor) ) {
// bug in bios - all returned descriptors must be
// at least 20 bytes long, and can not be larger then
// the input buffer.
break;
}
E820Present = TRUE;
.
.
.
Add address range Descriptor.BaseAddress through
Descriptor.BaseAddress + Descriptor.Length
as type Descriptor.Type
.
.
.
} while (Regs.ebx != 0);
if (!E820Present) {
.
.
.
call INT 15h, AX=E801h and/or INT 15h, AH=88h to obtain old style
memory information
.
.
.
}
Int 15 h, Ax = e801h-Get memory size
Large configurations
Real mode only (as far as I know ).
Originally defined for EISA servers, this interface is capable
Reporting up to 4 GB of Ram. While not nearly as flexible as e820h, it
Is present in memory more systems.
Input:
AXFunction CodeE801h
Output:
CFCarry FlagNon-Carry - indicates no error
AXExtended 1Number of contiguous KB between 1 and 16 MB,
maximum 0x3C00 = 15 MB.
BXExtended 2Number of contiguous 64 KB blocks between
16 MB and 4 GB.
CXConfigured 1Number of contiguous KB between 1 and 16 MB,
maximum 0x3C00 = 15 MB.
DXConfigured 2Number of contiguous 64 KB blocks between
16 MB and 4 GB.
Not sure what this difference between the "extended" and "configured"
Numbers are, but they appear to be identical, as reported from the BIOS.
Note: It is possible for a machine using this interface to report a memory
Hole just under 16 MB (count 1 is less than 15 MB, but count 2 is
Non-zero ).
Int 15 h, Ah = 88 h-get extended memory size
Real mode only.
This interface is quite primitive. It returns a single value
Contiguous memory abve 1 MB. The biggest
Limitation is that the value returned is a 16-bit value, in KB,
So it has a maximum saturation of just under 64 MB even presuming
It returns as much as it can. On some systems, it won't return
Anything abve the 16 MB boundary.
The one useful point is that it works on every PC available.
Input:
AHFunction Code88h
Output:
CFCarry FlagNon-Carry - indicates no error
AXMemory CountNumber of contiguous KB above 1 MB.