Physical Memory Layout

  • During initialization kernel builds a physical address map specifying which physical address ranges are usable/unusable by the kernel
    • Unusable physical addresses contain
      1. Addresses containing kernel code and data structures
      2. Hardware devices’ I/O shared memory
      3. BIOS data
  • In general Linux kernel begins at RAM address 0x00100000 the second megabyte

    • Often a typical config only uses 3 mb of RAM for the kernel
  • First megabyte is often reserved for BIOS routines
    • Page frame 0: POST
    • 0x000a0000 to 0x000fffff reserved for BIOS routines and mapping the internal memory of ISA (Industry Standard Architecture) Graphics Cards
      • 640kB to 1MB

Boot Sequence

  • Kernel queries BIOS and learns size of physical memory
  • Kernel invokes BIOS procedure to build a list of physical address ranges and their corresponding memory types
  • Kernel executes the
    machine_specific_memory_setup()

    function which builds the physical address map (discussed above)

    • If the BIOS version is not included in the kernel’s lookup table it marks 0x9f (LOWMEMSIZE()) to 0x100 (HIGH_MEMORY) as reserved by default
  • Kernel executes the
    setup_memory()

    which analyzes physical memory layout (2-10 table)

    • High memory defined by Gilles here.  In anyhow memory addresses is split into user space and kernel space.  If an app exceeds its limit and needs to map to kernel space it can do so.  This temporary map is called “high memory”

Capture.PNG

128 mB RAM Example (2^10*2^10)*2^7=1mB*2^7=1mB*128=128MB

Start End Type
 0x00000000  0x0009ffff  Usable
 0x000f0000  0x000fffff  Reserved
 0x00100000  0x07feffff  Usable
 0x07ff0000  0x07ff2fff  ACPI Data
 0x07ff3000  0x07ffffff  ACPI NVS
 0xffff0000  0xffffffff  Reserved
  • ACPI: Advanced Configuration and Power Interface
    1. perform discovery and configuration of computer hardware components
    2. to perform power management by (sleeping unused components)
    3. status monitoring.
  • NVS: Non Volatile Storage (?)
  • ACPI Data: Information about the hardware devices of system written by BIOS during POST
    • The kernel will copy this data and store it in a kernel data structure and then frees the addresses for use
  • ACPI NVS: Mapped to ROM chips of the hardware devices (which is NVS storage)
  • BIOS ROM: 0xffff0000 to 0xffffffff
  • The reason why the previously mentioned 0x000a0000 to 0x000fffff (640kb to 1mb) range is not in this table is because Linux assumes its reserved

 

3MB Kernel Image Layout

  • Avoid noncontiguous page frames therefore first 1MB is skipped even if there are available memory addresses
  • _text: Start at 0x00100000 first MB.  First byte of kernel code
  • _etext: End of kernel code
  • _edata: End of initialized data
  • _end: End of unintialized data
  • Note the page frame number each of the unspecified ones start at is generated at compilation depending on user options

capture

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s