xref: /linux/Documentation/ABI/testing/sysfs-firmware-memmap (revision 762f99f4f3cb41a775b5157dd761217beba65873)
169ac9cd6SBernhard WalleWhat:		/sys/firmware/memmap/
269ac9cd6SBernhard WalleDate:		June 2008
397bef7ddSBernhard WalleContact:	Bernhard Walle <bernhard.walle@gmx.de>
469ac9cd6SBernhard WalleDescription:
569ac9cd6SBernhard Walle		On all platforms, the firmware provides a memory map which the
669ac9cd6SBernhard Walle		kernel reads. The resources from that memory map are registered
769ac9cd6SBernhard Walle		in the kernel resource tree and exposed to userspace via
869ac9cd6SBernhard Walle		/proc/iomem (together with other resources).
969ac9cd6SBernhard Walle
1069ac9cd6SBernhard Walle		However, on most architectures that firmware-provided memory
1169ac9cd6SBernhard Walle		map is modified afterwards by the kernel itself, either because
1269ac9cd6SBernhard Walle		the kernel merges that memory map with other information or
1369ac9cd6SBernhard Walle		just because the user overwrites that memory map via command
1469ac9cd6SBernhard Walle		line.
1569ac9cd6SBernhard Walle
1669ac9cd6SBernhard Walle		kexec needs the raw firmware-provided memory map to setup the
1769ac9cd6SBernhard Walle		parameter segment of the kernel that should be booted with
1869ac9cd6SBernhard Walle		kexec. Also, the raw memory map is useful for debugging. For
1969ac9cd6SBernhard Walle		that reason, /sys/firmware/memmap is an interface that provides
2069ac9cd6SBernhard Walle		the raw memory map to userspace.
2169ac9cd6SBernhard Walle
2269ac9cd6SBernhard Walle		The structure is as follows: Under /sys/firmware/memmap there
2334433332SMauro Carvalho Chehab		are subdirectories with the number of the entry as their name::
2469ac9cd6SBernhard Walle
2569ac9cd6SBernhard Walle			/sys/firmware/memmap/0
2669ac9cd6SBernhard Walle			/sys/firmware/memmap/1
2769ac9cd6SBernhard Walle			/sys/firmware/memmap/2
2869ac9cd6SBernhard Walle			/sys/firmware/memmap/3
2969ac9cd6SBernhard Walle			...
3069ac9cd6SBernhard Walle
3169ac9cd6SBernhard Walle		The maximum depends on the number of memory map entries provided
3269ac9cd6SBernhard Walle		by the firmware. The order is just the order that the firmware
3369ac9cd6SBernhard Walle		provides.
3469ac9cd6SBernhard Walle
3569ac9cd6SBernhard Walle		Each directory contains three files:
3669ac9cd6SBernhard Walle
3734433332SMauro Carvalho Chehab		========  =====================================================
3834433332SMauro Carvalho Chehab		start	  The start address (as hexadecimal number with the
3969ac9cd6SBernhard Walle			  '0x' prefix).
4034433332SMauro Carvalho Chehab		end	  The end address, inclusive (regardless whether the
4169ac9cd6SBernhard Walle			  firmware provides inclusive or exclusive ranges).
4234433332SMauro Carvalho Chehab		type	  Type of the entry as string. See below for a list of
4369ac9cd6SBernhard Walle			  valid types.
4434433332SMauro Carvalho Chehab		========  =====================================================
4569ac9cd6SBernhard Walle
4634433332SMauro Carvalho Chehab		So, for example::
4769ac9cd6SBernhard Walle
4869ac9cd6SBernhard Walle			/sys/firmware/memmap/0/start
4969ac9cd6SBernhard Walle			/sys/firmware/memmap/0/end
5069ac9cd6SBernhard Walle			/sys/firmware/memmap/0/type
5169ac9cd6SBernhard Walle			/sys/firmware/memmap/1/start
5269ac9cd6SBernhard Walle			...
5369ac9cd6SBernhard Walle
5469ac9cd6SBernhard Walle		Currently following types exist:
5569ac9cd6SBernhard Walle
5669ac9cd6SBernhard Walle		  - System RAM
5769ac9cd6SBernhard Walle		  - ACPI Tables
5869ac9cd6SBernhard Walle		  - ACPI Non-volatile Storage
59*3b1f9415SJianpeng Ma		  - Unusable memory
60*3b1f9415SJianpeng Ma		  - Persistent Memory (legacy)
61*3b1f9415SJianpeng Ma		  - Persistent Memory
62*3b1f9415SJianpeng Ma		  - Soft Reserved
6369ac9cd6SBernhard Walle		  - reserved
6469ac9cd6SBernhard Walle
6569ac9cd6SBernhard Walle		Following shell snippet can be used to display that memory
6634433332SMauro Carvalho Chehab		map in a human-readable format::
6769ac9cd6SBernhard Walle
6869ac9cd6SBernhard Walle		  #!/bin/bash
6969ac9cd6SBernhard Walle		  cd /sys/firmware/memmap
7069ac9cd6SBernhard Walle		  for dir in * ; do
7169ac9cd6SBernhard Walle		      start=$(cat $dir/start)
7269ac9cd6SBernhard Walle		      end=$(cat $dir/end)
7369ac9cd6SBernhard Walle		      type=$(cat $dir/type)
7469ac9cd6SBernhard Walle		      printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
7569ac9cd6SBernhard Walle		  done
76