Memory Map (x86)

转载 2011年01月12日 14:12:00

This article describes the contents of the computer's physical memory at the moment that the BIOS jumps to your bootloader code.



< type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); }

"Low" memory (< 1 MiB)

When a typical x86 PC boots it will be in Real Mode, with an active BIOS. During the time the CPU remains in Real Mode, IRQ0 (the clock) will fire repeatedly, and the hardware that is used to boot the PC (floppy, hard disk, CD, Network card, USB) will also generate IRQs. This means that during the PC boot process, the Real Mode IVT (see below) must be carefully preserved, because it is being used.

When the IVT is activated by an IRQ, it will call a BIOS routine to handle the IRQ. Bootloaders will also access BIOS functions. This means that the two memory workspaces that the BIOS uses (the BDA and the EBDA) must also be carefully preserved during boot. Also, every time the BIOS handles an IRQ0 (18 times a second), several bytes in the BDA get overwritten by the BIOS -- so do not attempt to store anything there while IRQs are active in Real Mode.

After all the BIOS functions have been called, and your kernel is loaded into memory somewhere, the bootloader or kernel may exit Real Mode forever (often by going into 32bit Protected Mode). If the kernel never uses Real Mode again, then the first 0x500 bytes of memory in the PC may be reused and overwritten. (However, it is very common to temporarily return to Real Mode in order to change the Video Display Mode.)

When the CPU is in Protected Mode, System Management Mode (SMM) is still invisibly active, and cannot be shut off. SMM also seems to use the EBDA. So the EBDA memory area should never be overwritten.

Note: the EBDA is a variable-sized memory area (on different BIOSes). If it exists, it is always immediately below 0xA0000 in memory. It is absolutely guaranteed to be less than 128 KiB in size. It is often 1 KiB. The biggest ones ever actually seen are 8 KiB. You can determine the size of the EBDA by using BIOS function INT 12h, or (often) by examining the word at 0x40E in the BDA (see below). Both of those methods will tell you the location of the bottom of the EBDA.

It should also be noted that your bootloader code is probably loaded and running in memory at physical addresses 0x7C00 through 0x7DFF. So that memory area is likely to also be unusable until execution has been transferred to a second stage bootloader, or to your kernel.


(all values except KiBs are in hex)

start end size type description
Low Memory (the first MiB)
00000000 000003FF 400 (1 KiB) RAM - partially unusable (see above) Real Mode IVT (Interrupt Vector Table)
00000400 000004FF 100 RAM - partially unusable (see above) BDA (BIOS data area)
00000500 00007BFF 7700 (almost 30 KiB) RAM (guaranteed free for use) Conventional memory
00007C00 (typical location) 00007DFF 200 RAM - partially unusable (see above) Your OS BootSector
00007E00 0007FFFF 7FB00 (481 KiB) RAM (guaranteed free for use) Conventional memory
00080000 0009FBFF 1FC00 (approximately 120 KiB) RAM (free for use, if it exists) Conventional memory
0009FC00 (typical location) 0009FFFF 400 RAM (unusable) EBDA (Extended BIOS Data Area)
000A0000 000FFFFF 60000 various (unusable) ROM Area (384 KiB)


BIOS Data Area (BDA)

The BDA is only partially standardized, and almost all the values stored there are completely obsolete and uninteresting. The following is a partial list. See the External Links references below for more detail.

address (size) description
400 (word) IO port for COM1 serial
408 (word) IO port for LPT1 parallel
40E (word) EBDA base address >> 4 (usually!)
410 (word) packed bit flags for detected hardware
449 (byte) Display Mode
463 (2 bytes, taken as a word) base IO port for video
46C (word) # of IRQ0 timer ticks since boot
475 (byte) # of hard disk drives detected
497 (byte) last keyboard LED/Shift key state


Extended BIOS Data Area (EBDA)

You may see "maps" of the EBDA if you search the web. However, those maps are for the original IBM BIOS EBDA. They do not apply to any current EBDA, used by any current BIOS. The EBDA area is not standardized. It does contain data that your OS will need, but you must do a bytewise pattern search to find those tables. (See PlugNPlay.)


ROM Area

start end size region/exception description
Standard usage of the ROM Area
000A0000 000AFFFF 10000 video RAM VGA framebuffer (64 KiB)
000B0000 000B7FFF 8000 video RAM VGA text monochrome (32 KiB)
000B8000 000BFFFF 8000 video RAM VGA text color (32 KiB)
000C0000 000C7FFF 8000 ROM Video BIOS (32 KiB is typical size)
000C8000 000EFFFF 28000 ROMs and unusable space Mapped hardware & Misc.
000F0000 000FFFFF 10000 ROM Motherboard BIOS (64 KiB is typical size)


"Upper" Memory (> 1 MiB)

The region of RAM above 1 MiB is not standardized, well-defined, or contiguous. There are likely to be regions of it that contain memory mapped hardware, that nothing but a device driver should ever access. There are likely to be regions of it that contain ACPI tables which your initialization code will probably want to read, and that then can be overwritten and reused. Some ACPI areas cannot be "reclaimed" this way. Some of the computer's RAM may extend above 4 GiB.

Use the BIOS function INT 15h, EAX=0xE820 to get a reliable map of Upper Memory.


start end size region/exception description
High Memory
00100000 003FFFFF 00300000 RAM -- guaranteed free for use1 Extended memory
00400000 00EFFFFF 00900000 (if it all exists) RAM -- free for use Extended memory
00F00000 00FFFFFF 100000 Possible memory mapped hardware ISA Memory Hole 15-16MB (only with ISA bus?)
01000000  ????????  ???????? (whatever exists) RAM -- free for use More Extended memory
C000000 (sometimes) FFFFFFF 4000000 various (unusable except by drivers) PnP NVRAM?, LAPIC, BIOS, ...
10000000 (possible mem above 4 GiB)  ????????  ???????? (whatever exists) RAM -- free for use (PAE/64bit) More Extended memory

1: Free for use except that your bootloader (ie. GRUB) may have loaded your "modules" here, and you don't want to overwrite those.



See Also

External Links

Memory Map (x86)

Memory Map (x86) Revision as of 05:41, 22 May 2012 by Amirsaniyan (Talk | contribs) (diff) ← Olde...
  • bian1029
  • bian1029
  • 2015年10月13日 15:26
  • 336

【Linux】Linux Kernel--Memory Management(一)

  • moxiaomomo
  • moxiaomomo
  • 2013年12月03日 23:23
  • 1534

Robust Object Tracking via Sparsity-based Collaborative Model

Robust Object Tracking via Sparsity-based Collaborative Model
  • Quincuntial
  • Quincuntial
  • 2016年02月03日 16:14
  • 798

Memory Map (x86) ,X86计算机内存映射

 Memory Map (x86) This article describes the contents of the computers physical memory at the mome...
  • lovehappystudy
  • lovehappystudy
  • 2008年10月25日 14:18
  • 1204

X86 内存布局分析(Memory map) This article describes the contents of...
  • cassienj
  • cassienj
  • 2015年07月15日 14:02
  • 135

Memory Map

Memory Map --- 存储器映射        引言 随着半导体工艺技术与处理器设计技术的不断提高,嵌入式处理器的速度愈来愈快;而非易失性存储器的读取速度却远远跟不上CPU的发展。...
  • tom__mao__
  • tom__mao__
  • 2016年06月20日 11:24
  • 2390

Memory Map(Linux 存储映射IO)

本文主要总结自UNIX环境高级编程以及RedHat6.5系统man函数 存储映射IO函数说明 mmap#include void *mmap(void *addr,//指定映射区的起始地址。通常设置...
  • a931040
  • a931040
  • 2016年07月19日 14:40
  • 2227

STMP3770内存映射(Memory map)小结

在做底层开发的时候,我们经常会关注到内存映射的问题,今天我们讨论的就是STMP3770内存映射方面话题,并且会结合.map文档一起来看看。 首先,我们来看一张STMP3770的内存映射图,如下 ...
  • jgw2008
  • jgw2008
  • 2016年11月14日 10:30
  • 802

[ARM7--LPC2478]Memory Map

简述ARM7的Memory空间为4G(32 bit寻址空间决定)。不过对于嵌入式的这种MCU而言,其实很多空间都是保留的,只使用了其中的一小部分。Memory Map先看总体的图: AHBAHB部分...
  • suxiang198
  • suxiang198
  • 2015年10月25日 15:03
  • 1054


  • girlkoo
  • girlkoo
  • 2012年10月10日 17:39
  • 6430
您举报文章:Memory Map (x86)