162306a36Sopenharmony_ciWhat:		/sys/firmware/memmap/
262306a36Sopenharmony_ciDate:		June 2008
362306a36Sopenharmony_ciContact:	Bernhard Walle <bernhard.walle@gmx.de>
462306a36Sopenharmony_ciDescription:
562306a36Sopenharmony_ci		On all platforms, the firmware provides a memory map which the
662306a36Sopenharmony_ci		kernel reads. The resources from that memory map are registered
762306a36Sopenharmony_ci		in the kernel resource tree and exposed to userspace via
862306a36Sopenharmony_ci		/proc/iomem (together with other resources).
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci		However, on most architectures that firmware-provided memory
1162306a36Sopenharmony_ci		map is modified afterwards by the kernel itself, either because
1262306a36Sopenharmony_ci		the kernel merges that memory map with other information or
1362306a36Sopenharmony_ci		just because the user overwrites that memory map via command
1462306a36Sopenharmony_ci		line.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci		kexec needs the raw firmware-provided memory map to setup the
1762306a36Sopenharmony_ci		parameter segment of the kernel that should be booted with
1862306a36Sopenharmony_ci		kexec. Also, the raw memory map is useful for debugging. For
1962306a36Sopenharmony_ci		that reason, /sys/firmware/memmap is an interface that provides
2062306a36Sopenharmony_ci		the raw memory map to userspace.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci		The structure is as follows: Under /sys/firmware/memmap there
2362306a36Sopenharmony_ci		are subdirectories with the number of the entry as their name::
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci			/sys/firmware/memmap/0
2662306a36Sopenharmony_ci			/sys/firmware/memmap/1
2762306a36Sopenharmony_ci			/sys/firmware/memmap/2
2862306a36Sopenharmony_ci			/sys/firmware/memmap/3
2962306a36Sopenharmony_ci			...
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci		The maximum depends on the number of memory map entries provided
3262306a36Sopenharmony_ci		by the firmware. The order is just the order that the firmware
3362306a36Sopenharmony_ci		provides.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci		Each directory contains three files:
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci		========  =====================================================
3862306a36Sopenharmony_ci		start	  The start address (as hexadecimal number with the
3962306a36Sopenharmony_ci			  '0x' prefix).
4062306a36Sopenharmony_ci		end	  The end address, inclusive (regardless whether the
4162306a36Sopenharmony_ci			  firmware provides inclusive or exclusive ranges).
4262306a36Sopenharmony_ci		type	  Type of the entry as string. See below for a list of
4362306a36Sopenharmony_ci			  valid types.
4462306a36Sopenharmony_ci		========  =====================================================
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci		So, for example::
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci			/sys/firmware/memmap/0/start
4962306a36Sopenharmony_ci			/sys/firmware/memmap/0/end
5062306a36Sopenharmony_ci			/sys/firmware/memmap/0/type
5162306a36Sopenharmony_ci			/sys/firmware/memmap/1/start
5262306a36Sopenharmony_ci			...
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci		Currently following types exist:
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci		  - System RAM
5762306a36Sopenharmony_ci		  - ACPI Tables
5862306a36Sopenharmony_ci		  - ACPI Non-volatile Storage
5962306a36Sopenharmony_ci		  - Unusable memory
6062306a36Sopenharmony_ci		  - Persistent Memory (legacy)
6162306a36Sopenharmony_ci		  - Persistent Memory
6262306a36Sopenharmony_ci		  - Soft Reserved
6362306a36Sopenharmony_ci		  - reserved
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci		Following shell snippet can be used to display that memory
6662306a36Sopenharmony_ci		map in a human-readable format::
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci		  #!/bin/bash
6962306a36Sopenharmony_ci		  cd /sys/firmware/memmap
7062306a36Sopenharmony_ci		  for dir in * ; do
7162306a36Sopenharmony_ci		      start=$(cat $dir/start)
7262306a36Sopenharmony_ci		      end=$(cat $dir/end)
7362306a36Sopenharmony_ci		      type=$(cat $dir/type)
7462306a36Sopenharmony_ci		      printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
7562306a36Sopenharmony_ci		  done
76