x86内存映射

Contents 

 
  • 1 "Low" memory (< 1 MiB) 
  • 2 "Upper" Memory (> 1 MiB)
  • 3 See Also
  • 3.1 External Links

    这篇文章主要内容是计算机启动时,BIOS跳转到你的bootloader代码后的计算机的物理内存。

    1,“低”内存(<1M)
    x86计算机启动的时候进入实时模式,包括一个可用的BIOS。在CPU处于实时模式期间。IRQ0。时钟中断会反复的引发,用于启动的盘比方软盘,硬盘等都会引起中断,这就意味着,在CPU启动的过程,中断向量表(IVT)要被好好保存,由于它一直实用。
    其中断发生时,会跳到中断向量表中调用BIOS的对应程序去处理这个中断。

    bootloader也能够訪问BIOS的程序。这就意味着在bootloader执行期间要好好保存BIOS的两块内存空间,BDA和EBDA。并且每次BIOS发生时钟中断的时候。BIOS会更新BDA的一些数据。不要试图去存储不论什么数据到BDA。


    在全部的BIOS的功能已经被调用,你的操作系统已经被载入到内存里面,bootloader或者内核可能要永久的退出实时模式了。一般进入32位的保护模式。

    假设内核不再使用实时模式,開始的0x500字节能够被反复使用。可是常见的回到实时模式操作。就是处理视频显示模式的时候。


    当CPU处于保护模式的时候,系统管理模式在无形之中被激活,不能关闭,系统管理模式会使用EBDA的区域,多以EBDA不能被覆盖。
    注意:EBDA是变量区内存。对于不同的BIOS。假设它存在。它的地址低于0xa000。它保证小于128K个字节。

    通常是1K个字节。最大的一个其实才8K。

    你能够通过BIOS的12H的中断确定EBDA的大小,或者通过測试0x40e。这两个方法都能够获得EBDA的最低的位置。


    你的bootloader的代码最好载入到0x7c00-0x7dff这512b中。这段区域不能够被占用。知道运行进入了bootloader的第二阶段或者进入了你的内核。

    Overview

    startendsizetypedescription
    Low Memory (the first MiB)
    0x000000000x000003FF1 KiBRAM - partially unusable (see above)Real Mode IVT (Interrupt Vector Table)
    0x000004000x000004FF256 bytesRAM - partially unusable (see above)BDA (BIOS data area)
    0x000005000x00007BFFalmost 30 KiBRAM (guaranteed free for use)Conventional memory
    0x00007C00 (typical location)0x00007DFF512 bytesRAM - partially unusable (see above)Your OS BootSector
    0x00007E000x0007FFFF480.5 KiBRAM (guaranteed free for use)Conventional memory
    0x000800000x0009FBFFapproximately 120 KiB, depending on EBDA sizeRAM (free for use, if it exists)Conventional memory
    0x0009FC00 (typical location)0x0009FFFF1 KiBRAM (unusable)EBDA (Extended BIOS Data Area)
    0x000A00000x000FFFFF384 KiBvarious (unusable)Video memory, ROM Area

    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
    0x0400 (4 words)IO ports for COM1-COM4 serial (each address is 1 word, zero if none)
    0x0408 (3 words)IO ports for LPT1-LPT3 parallel (each address is 1 word, zero if none)
    0x040E (word)EBDA base address >> 4 (usually!)
    0x0410 (word)packed bit flags for detected hardware
    0x0417 (word)keyboard state flags
    0x041E (32 bytes)keyboard buffer
    0x0449 (byte)Display Mode
    0x044A (word)number of columns in text mode
    0x0463 (2 bytes, taken as a word)base IO port for video
    0x046C (word)# of IRQ0 timer ticks since boot
    0x0475 (byte)# of hard disk drives detected
    0x0480 (word)keyboard buffer start
    0x0482 (word)keyboard buffer end
    0x0497 (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 Plug-and-Play.)

    ROM Area

    startendsizeregion/exceptiondescription
    Standard usage of the ROM Area
    0x000A00000x000BFFFF128 KiBvideo RAMVGA display memory
    0x000C00000x000C7FFF32 KiB (typically)ROMVideo BIOS
    0x000C80000x000EFFFF160 KiB (typically)ROMs and unusable spaceMapped hardware & Misc.
    0x000F00000x000FFFFF64 KiBROMMotherboard BIOS

    2,“高内存 ”(>1M
    >1M的内存区域并没有规范的,非常好的定义。或者说不连续。区域包含内存映射硬件,设备驱动能够訪问的;  ACPI表。初始化代码非常可能会读取的,然后能够被又一次利用; 32位计算机的硬件能够被扩展为4G。

    使用BIOS的中断

    INT 15h, EAX=0xE820 能够获得可靠的高内存映射表。
    startendsizeregion/exceptiondescription
    High Memory
    0x001000000x00EFFFFF0x00E00000 (14 MiB)RAM -- free for use (if it exists)Extended memory 1, 2
    0x00F000000x00FFFFFF0x00100000 (1 MiB)Possible memory mapped hardwareISA Memory Hole 15-16MB 3
    0x01000000 ????

    ?

    ?

    ??

     ?

    ?

    ??

    ?

    ??? (whatever exists)

    RAM -- free for useMore Extended memory 1
    0xC0000000 (sometimes, depends on motherboard and devices)0xFFFFFFFF0x40000000 (1 GiB)various (typically reserved for memory mapped devices)Memory mapped PCI devices, PnP NVRAM?, IO APIC/s, local APIC/s, BIOS, ...
    0x0000000100000000 (possible memory above 4 GiB) ???

    ?

    ?

    ?????

    ?????

    ?

     ??

    ?

    ??

    ??

    ?

    ????

    ???? (whatever exists)

    RAM -- free for use (PAE/64bit)More Extended memory 1
     ?

    ????

    ?????

    ????

    ??

     ???

    ?

    ?????

    ?

    ??

    ????

     ????

    ?

    ????

    ????

    ???

    Possible memory mapped hardwarePotentially usable for memory mapped PCI devices in modern hardware (but typically not, due to backward compatibility)

    1: Different computers have different amounts of RAM, therefore the amount of extended memory you might find will vary and may be anything from "none" (e.g. an old 80386 system) to "lots".

    2: Free for use except that your bootloader (ie. GRUB) may have loaded your "modules" here, and you don't want to overwrite those.能够任意使用包含了。你的bootloader如GRUB,非常可能调入你的模块在这里,所以你不想覆盖它。

    3: The "ISA Memory Hole" (from 0x00F00000 to 0x00FFFFFF) was used for memory mapped ISA devices (e.g. video cards). Modern computers have no need for this hole, but some chipsets still support it (as an optional feature) and some motherboards may still allow it to be enabled with BIOS options, so it may exist in a modern computers with no ISA devices.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值