Memory Map (x86)

Source: Internet
Author: User
From osdev wikijump:
Navigation, search

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

Contents
  • 1 "low"Memory(<1
    MiB)

    • 1.1 Overview
    • 1.2 BIOS data area (bytes)
    • 1.3 extended BIOS data area (EBDA)
    • 1.4rom Area
  • 2 "upper"Memory(>
    1 MIB)
  • 3 comments
  • 4see also
    • 4.1 External links
"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 accessbios functions. This means that the twoMemory
Workspaces that the BIOS uses (the same 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 same 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
Memory
Somewhere, the bootloader or kernel may exit real mode forever (often by going into 32 bitprotected mode). If the kernel never uses real mode again, then the first 0x500
BytesMemoryIn the PC may be reused and overwritten. (However, It is very common to temporarily return to real mode in order to change thevideo
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 EBDAMemoryArea shocouldNeverBe overwritten.

Note: The EBDA is a variable-sized
Memory
Area (on different BIOSes). If it exists, it is always immediately below 0xa0000 inMemory. It is absolutely guaranteed to be less than 128 kib in size. It is often 1 kib.
Biggest ones ever actually seen are 8 kib. You can determine the size of the EBDA by using BIOS functionint 12 h, or (often) by examining the wordAt
0x40e in the lower (see below). Both of those methods will tell you the location of the bottom of the EBDA.

It shoshould also be noted that your bootloader code is probably loaded and running inMemoryPhysical addresses 0x7c00 through 0x7dff. So thatMemory
Area is likely to also be unusable until execution has been transferred to a second stage bootloader, or to your kernel.

Overview
Start End Size Type Description
LowMemory(The first MIB)
Zero X 00000000 0x000003ff 1 kib Ram-partially unusable (see abve) Real mode IVT (interrupt vector table)
Zero X 00000400 0x000004ff 256 bytes Ram-partially unusable (see abve) BIOS data area)
Zero X 00000500 0x00007bff Almost 30 kib Ram (guaranteed free for use) ConventionalMemory
0x00007c00 (typical location) 0x00007dff 512 bytes Ram-partially unusable (see abve) Your OS bootsector
0x00007e00 0x0007ffff 480.5 kib Ram (guaranteed free for use) ConventionalMemory
Zero X 00080000 0x0009fbff Approximately 120 kib, depending on EBDA size Ram (free for use,If it exists) ConventionalMemory
0x0009fc00 (typical location) 0x0009ffff 1 kib Ram (unusable) EBDA (Extended BIOS data area)
0x000a0000 0x000fffff 384 kib Various (unusable) VideoMemory, Rom Area
BIOS data area (bytes)

The operation 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
Zero X 0449 (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
Zero X 0475 (byte) # Of hard disk drives Detected
0x0480 (word) Keyboard Buffer start
0x0482 (word) Keyboard Buffer end
Zero X 0497 (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. itDoesContain data that your
OS will need, but you must do a bytewise pattern search to find those tables. (seeplug-and-play .)

Rom Area
Start End Size Region/exception Description
Standard usage of the RoM Area
0x000a0000 0x000bffff 128 kib Video RAM VGA displayMemory
0x000c0000 0x000c7fff 32 kib (typically) Rom Video BIOS
0x000c8000 0x000effff 160 kib (typically) Roms and unusable Space Mapped hardware & Misc.
0x000f0000 0x000fffff 64 kib Rom Motherboard BIOS
"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 containMemoryMapped hardware, that nothing but a device driver
Shocould 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 15 h, eax = 0xe820 to get a reliable
Map
Of upper
Memory
.

Start End Size Region/exception Description
HighMemory
Zero X 00100000 0x00efffff 0x00e00000 (14 MIB) Ram -- free for use (if it exists) ExtendedMemory1, 2
0x00f00000 0x00ffffff 0x00100000 (1 MIB) PossibleMemoryMapped hardware IsaMemoryHole 15-16mb3
Zero X 01000000 ???????? ???????? (Whatever exists) Ram -- free for use More extendedMemory1
0xc0000000 (sometimes, depends on motherboard and devices) 0 xffffffff 0x40000000 (1 Gib) Various (typically reserved
Memory
Mapped devices)
MemoryMapped 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 extendedMemory1
???????????????? ???????????????? ???????????????? PossibleMemoryMapped hardware Potentially usable
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 extendedMemoryYou might find will vary and may be anything from
"None" (e.g. An old 80386 system) to "LOTS ".

2: free for use using t that your bootloader (ie. Grub) may have loaded your "modules" here, and you don't have want to overwrite those.

3: The "Isa
Memory
Hole "(from 0x00f00000 to 0x00ffffff) was used
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.

Commentssee also
  • DetectingMemory(X86)
External links
  • Http://www.nondot.org/sabre/ OS /files/Booting/BIOS_SEG.txt -- Detailed BIOS data areaMap
  • Http://www.bioscentral.com/misc/bda.htm -- Another detailed BIOS data areaMap
  • Geezer'sMemoryLayout description
  • Http://stanislavs.org/helppc/bios_data_area.html
Retrieved from "http: // Wiki . Osdev.Org/index. php? Title = Memory_ Map_ (X86) & oldid = 13415 "category:

  • X86

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: info-contact@alibabacloud.com 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.