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

 

Memory Map (x86)



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

Contents

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

"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.

Overview

(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.


Comments

See Also

External Links

本文转自:http://wiki.osdev.org/Memory_Map_(x86)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值