int 15/ax=e820h, int 15/ax=e801h_reference

Source: Internet
Author: User
Tags reserved

The Int 15/ax=e820h is used to get the memory-mapped address descriptor in the system, which is used by the operating system to get the memory size.

PS: Memory (Memory) can be what we normally call the memory on the motherboard, we call it base Memory, or it can be an edge
Base Memory memory that is extended as normal memory.

First, take a look at the relevant data structures:

Format of Phoenix BIOS system memory map address range descriptor
(BIOS system memory-mapped address descriptor format, usually called entry in English, a entry describes a system memory information):

Offset Size Description
00h Qword Base Address #系统内存块基地址
08h qword length in bytes #系统内存大小
10h DWORD type of address range #内存类型, see below (Values for System Memory Map address type)

The size of this structure block is 20


AX = e820h
EAX = 0000e820h
EDX = 534d4150h (' SMAP ')
EBX = continuation value or 00000000h to start at Beginnin G of Map
The duration value or equal to 00000000h so that the beginning of the heavy map starts scan ECX = size of buffer for result, in bytes (should to >=)

CF clear If successful EAX = 534d4150h (' SMAP ') es:di buffer filled EBX = Next offset from which to copy or 00000000h if a ll done ECX = the size of the entry transmitted to the buffer buf, typically 20 bytes, ecx=20 CF set On Error AH = error code (86H)

In addition to base memory, he returns the chipset-defined system memory address hole, which is not used and is
The motherboard memory-mapped device and the BIOS retain it.
Values for System Memory Map address type:
01h    Memory, available to OS
02h    reserved, not available (e.g. s  Ystem ROM, memory-mapped device)
03h    ACPI Reclaim memory (usable by OS after reading ACPI tables)
04h    ACPI NVS Memory (OS is required to save this Memory between NVS sessions), not defined  yet-treat as Reser Ved
Principle Description:
This feature can be invoked from one place in the system (here is a list of lists), which are stored in one
Entry) by setting the value of ebx (multiples of 20), and then calling int 0x15, you can tell the Entry copy that EBX is pointing to
To the memory area to which Es:di is pointing)
LINUX2.4.10-SETUP.S about memory Detection (E820H) Comments and procedures:
First, find out what empty_zero_page is storing:
 offset type  description 
------ ----  -----------
    0  32 bytes struct screen_info, Screen_info
   attention, overlaps the following!!!
    2 unsigned short ext_mem_k, extended memory size in Kb (from int 0x15)
 0x20& nbsp;unsigned short cl_magic, commandline MAGIC number (=0xa33f)
 0x22 unsigned Short cl_ Offset, commandline offset
   address of commandline is calculated:
     0x90000 + contents of Cl_offset
    (only taken, when cl_magic = 0xa33f)
 0x40 20 bytes& Nbsp;struct Apm_bios_info, Apm_bios_info
 0x80 16 bytes hd0-disk-parameter from Intvector 0x41
 0x90 16 bytes hd1-disk-parameter from Intvector 0x46
0xa0 bytes System Description table truncated to bytes.
(struct sys_desc_table_struct)
0XB0-0X1DF free. ADD more parameters here if you really need them.

0x1f1 char size of Setup. S, number of sectors
0X1F2 unsigned short mount_root_rdonly (if!=0)
0X1F4 unsigned short size of compressed kernel-part in the
(b) Zimage-file (in-byte units, rounded up)
0x1f6 unsigned short Swap_dev (unused AFAIK)
0x1f8 unsigned short ramdisk_flags
0X1FA unsigned short vga-mode (old one)
0X1FC unsigned short Orig_root_dev (high=major, Low=minor)
0x1ff Char Aux_device_info
0x200 short jump to start of the setup code aka "Reserved" field.
0x202 4 bytes Signature for setup-header, = "HdrS"
0x206 unsigned short Version number of header format
Current version is 0x0201 ...
0x208 8 bytes (used by Setup. S for communication with boot loaders,
Look there)
0x210 char Loader_type, = 0, old one
Else it is set by the loader:
0xtv:t=0 for LILO
1 for Loadlin
2 for Bootsect-loader
3 for Syslinux
4 for Etherboot
V = version
0x211 Char Loadflags:
Bit0 = 1:kernel is loaded high (bzimage)
BIT7 = 1:heap and pointer (below) set by boot
0x212 unsigned short (setup. S
0x214 unsigned long kernel_start, where the loader started the KERNEL
0x218 unsigned long initrd_start, address of loaded RAMDisk image
0x21c unsigned long initrd_size, SIZE in bytes of RAMDisk image
0x220 4 bytes (Setup. S
0x224 unsigned short setup. S Heap End Pointer
0x800 string, 2K Max Command_line, the kernel commandline as
Copied using Cl_offset.
Note:this would be copied once more by setup.c
into a the local buffer which was only 256 bytes long.
(#define COMMAND_LINE_SIZE 256)
# Get memory Size (extended mem, KB)

#ifndef Standard_memory_bios_call
Movb%al, (E820NR) # E820nr=0x1e8 number of entries in E820map
# Try three different memory detection schemes. A try
# e820h, which lets us assemble a memory map, then try E801h,
# which returns a 32-bit memory size, and finally 88h, which
# returns 0-64M
# method E820h:
# The memory map from hell. E820H returns memory classified into
# a whole bunch of different types, and allows memory holes and
# everything. We scan through this memory map and build a list
# of the The memory areas, which we return at [E820map].
#define SMAP 0x534d4150
Xorl%EBX,%EBX # Continuation counter
MOVW $E 820MAP,%di # Point into the whitelist
# so we can have the BIOS
# directly write into it.
Movl $0x0000e820,%eax # e820, Upper Word zeroed
Movl $SMAP,%edx # ASCII ' SMAP '
MOVL $,%ECX # size of the E820rec
PUSHW%ds # data record.
int $0x15 # make the call
JC bail820 # Fall to e801 if it fails
Cmpl $SMAP,%eax # Check the return is ' SMAP '
Jne bail820 # Fall to e801 if it fails
# Cmpl $%di # is this usable memory?
# jne again820
# If this are usable memory, we save it by simply advancing%di by
# sizeof (E820REC).
Movb (E820NR),%al # up to entries
CMPB $E 820MAX,%al
Jnl bail820
ADDW $,%ax
Cmpl $%EBX # Check to If
Jne jmpe820 #%EBX is set to EOF
Using the assembly instructions above, the entry description block order of the available memory is placed in the Empty_zero_page
. Then it is not difficult to calculate the memory size.
Phoenix BIOS v4.0-get MEMORY SIZE for >64m configurations
AX = e801h

CF clear If successful AX = extended memory between 1M and 16M, in K (max 3c00h = 15MB) BX = extended memory above 16M, in 64K Blocks CX = configured memory 1M to 16M, in K DX = configured memory above 16M, in 64K blocks CF set On Error

Notes:supported by the A03 level (6/14/94) and later XPS P90 BIOSes, as OK as

Supported by AMI BIOSes dated 8/23/94 or later. On some systems, the BIOS returns
ax=bx=0000h; In the, use CX and DX instead of AX and BX. This interface is

Versions if ax=e820h is not supported. This function isn't used by MS-DOS 6.0
HIMEM. SYS when a EISA machine (for example with Parameter/eisa)

STC # Fix to work around buggy
XORW%cx,%cx # bioses which dont clear/set
XORW%DX,%DX # Carry on Pass/error of
# e801h Memory Size Call
# or merely pass CX,DX though
# without changing them.
MOVW $0xe801,%ax
int $0x15
JC Mem88
CMPW $0x0,%CX # kludge to handle BIOSes
Jne E801USECXDX # which their extended
CMPW $0x0,%DX # Memory in AX/BX rather than
Jne E801USECXDX # CX/DX. The spec I have read

MOVW%BX,%DX # are more reasonable anyway ...
Andl $0xffff,%edx # clear sign Extend
Shll $,%edx # and go from 64k to 1k chunks
Movl%edx, (0X1E0) # Store extended memory size
Andl $0xffff,%ECX # clear sign Extend
Addl%ecx, (0X1E0) # and add lower memory into
# Total size.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.