^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) What: /sys/firmware/memmap/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) Date: June 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Contact: Bernhard Walle <bernhard.walle@gmx.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) On all platforms, the firmware provides a memory map which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) kernel reads. The resources from that memory map are registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) in the kernel resource tree and exposed to userspace via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /proc/iomem (together with other resources).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) However, on most architectures that firmware-provided memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) map is modified afterwards by the kernel itself, either because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) the kernel merges that memory map with other information or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) just because the user overwrites that memory map via command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) kexec needs the raw firmware-provided memory map to setup the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) parameter segment of the kernel that should be booted with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) kexec. Also, the raw memory map is useful for debugging. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) that reason, /sys/firmware/memmap is an interface that provides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) the raw memory map to userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) The structure is as follows: Under /sys/firmware/memmap there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) are subdirectories with the number of the entry as their name::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /sys/firmware/memmap/0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /sys/firmware/memmap/1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /sys/firmware/memmap/2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /sys/firmware/memmap/3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) The maximum depends on the number of memory map entries provided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) by the firmware. The order is just the order that the firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) provides.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Each directory contains three files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ======== =====================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) start The start address (as hexadecimal number with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) '0x' prefix).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) end The end address, inclusive (regardless whether the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) firmware provides inclusive or exclusive ranges).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) type Type of the entry as string. See below for a list of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) valid types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ======== =====================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) So, for example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /sys/firmware/memmap/0/start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /sys/firmware/memmap/0/end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /sys/firmware/memmap/0/type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /sys/firmware/memmap/1/start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Currently following types exist:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) - System RAM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) - ACPI Tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) - ACPI Non-volatile Storage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) - reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) Following shell snippet can be used to display that memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) map in a human-readable format::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) cd /sys/firmware/memmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) for dir in * ; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) start=$(cat $dir/start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) end=$(cat $dir/end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) type=$(cat $dir/type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) done